Remove automations view for observers (#4594)

Co-authored-by: Luke Heath <luke@fleetdm.com>
This commit is contained in:
gillespi314 2022-03-15 10:48:31 -05:00 committed by GitHub
parent 48f85cfb17
commit 3aa66aaf31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 43 deletions

View File

@ -102,7 +102,7 @@ const PoliciesListWrapper = ({
resultsTitle={resultsTitle || "policies"}
columns={generateTableHeaders({
selectedTeamId: currentTeam?.id,
showSelectionColumn: canAddOrRemovePolicy,
canAddOrRemovePolicy,
tableType,
})}
data={generateDataSet(policiesList, currentAutomatedPolicies)}

View File

@ -70,10 +70,10 @@ interface IDataColumn {
// more info here https://react-table.tanstack.com/docs/api/useTable#cell-properties
const generateTableHeaders = (options: {
selectedTeamId: number | undefined | null;
showSelectionColumn: boolean | undefined;
canAddOrRemovePolicy: boolean | undefined;
tableType: string | undefined;
}): IDataColumn[] => {
const { selectedTeamId, tableType, showSelectionColumn } = options;
const { selectedTeamId, tableType, canAddOrRemovePolicy } = options;
switch (tableType) {
case "inheritedPolicies":
@ -154,6 +154,33 @@ const generateTableHeaders = (options: {
),
},
];
if (!canAddOrRemovePolicy) {
return tableHeaders;
}
tableHeaders.unshift({
id: "selection",
Header: (cellProps: IHeaderProps): JSX.Element => {
const props = cellProps.getToggleAllRowsSelectedProps();
const checkboxProps = {
value: props.checked,
indeterminate: props.indeterminate,
onChange: () => cellProps.toggleAllRowsSelected(),
};
return <Checkbox {...checkboxProps} />;
},
Cell: (cellProps: ICellProps): JSX.Element => {
const props = cellProps.row.getToggleRowSelectedProps();
const checkboxProps = {
value: props.checked,
onChange: () => cellProps.row.toggleRowSelected(),
};
return <Checkbox {...checkboxProps} />;
},
disableHidden: true,
});
if (!selectedTeamId) {
tableHeaders.push({
title: "Automations",
@ -165,29 +192,7 @@ const generateTableHeaders = (options: {
),
});
}
if (showSelectionColumn) {
tableHeaders.splice(0, 0, {
id: "selection",
Header: (cellProps: IHeaderProps): JSX.Element => {
const props = cellProps.getToggleAllRowsSelectedProps();
const checkboxProps = {
value: props.checked,
indeterminate: props.indeterminate,
onChange: () => cellProps.toggleAllRowsSelected(),
};
return <Checkbox {...checkboxProps} />;
},
Cell: (cellProps: ICellProps): JSX.Element => {
const props = cellProps.row.getToggleRowSelectedProps();
const checkboxProps = {
value: props.checked,
onChange: () => cellProps.row.toggleRowSelected(),
};
return <Checkbox {...checkboxProps} />;
},
disableHidden: true,
});
}
return tableHeaders;
}
}

View File

@ -1,4 +1,4 @@
.policy-list-wrapper {
.policies-list-wrapper {
border-collapse: collapse;
a {
@ -23,23 +23,11 @@
font-weight: $bold;
text-align: left;
padding: $pad-medium $pad-large;
&:nth-child(2) {
width: calc(49% - 20px);
}
&:nth-child(3) {
&:not(.name__header) {
width: 20%;
max-width: 150px;
}
&:nth-last-child(2) {
border-right: 0;
}
&:last-child {
width: 150px;
border-left: 0;
@media (min-width: $medium-width) {
width: 15%;
}
}
}
}