mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 01:18:42 +00:00
conditionally show add label button (#854)
This commit is contained in:
parent
d3932d736d
commit
c018823abf
2 changed files with 18 additions and 9 deletions
|
|
@ -19,6 +19,7 @@ class HostSidePanel extends Component {
|
|||
onLabelClick: PropTypes.func,
|
||||
selectedFilter: PropTypes.string,
|
||||
statusLabels: statusLabelsInterface,
|
||||
canAddNewLabel: PropTypes.bool,
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
|
|
@ -41,6 +42,7 @@ class HostSidePanel extends Component {
|
|||
onLabelClick,
|
||||
selectedFilter,
|
||||
statusLabels,
|
||||
canAddNewLabel,
|
||||
} = this.props;
|
||||
const { labelFilter } = this.state;
|
||||
const { onFilterLabels } = this;
|
||||
|
|
@ -100,14 +102,15 @@ class HostSidePanel extends Component {
|
|||
selectedFilter={selectedFilter}
|
||||
type="label"
|
||||
/>
|
||||
|
||||
<Button
|
||||
variant="grey"
|
||||
onClick={onAddLabelClick}
|
||||
className={`${baseClass}__add-label-btn`}
|
||||
>
|
||||
Add new label
|
||||
</Button>
|
||||
{canAddNewLabel ? (
|
||||
<Button
|
||||
variant="grey"
|
||||
onClick={onAddLabelClick}
|
||||
className={`${baseClass}__add-label-btn`}
|
||||
>
|
||||
Add new label
|
||||
</Button>
|
||||
) : null}
|
||||
</SecondarySidePanelContainer>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ import NoHosts from "./components/NoHosts";
|
|||
import EmptyHosts from "./components/EmptyHosts";
|
||||
import EditColumnsModal from "./components/EditColumnsModal/EditColumnsModal";
|
||||
import TransferHostModal from "./components/TransferHostModal";
|
||||
|
||||
import EditColumnsIcon from "../../../../assets/images/icon-edit-columns-16x12@2x.png";
|
||||
|
||||
const NEW_LABEL_HASH = "#new_label";
|
||||
|
|
@ -68,6 +67,7 @@ export class ManageHostsPage extends PureComponent {
|
|||
hosts: PropTypes.arrayOf(hostInterface),
|
||||
loadingHosts: PropTypes.bool,
|
||||
canAddNewHosts: PropTypes.bool,
|
||||
canAddNewLabels: PropTypes.bool,
|
||||
teams: PropTypes.arrayOf(teamInterface),
|
||||
isGlobalAdmin: PropTypes.bool,
|
||||
currentUser: userInterface,
|
||||
|
|
@ -523,6 +523,7 @@ export class ManageHostsPage extends PureComponent {
|
|||
selectedFilter,
|
||||
selectedOsqueryTable,
|
||||
statusLabels,
|
||||
canAddNewLabels,
|
||||
} = this.props;
|
||||
const { onAddLabelClick, onLabelClick, onOsqueryTableSelect } = this;
|
||||
|
||||
|
|
@ -543,6 +544,7 @@ export class ManageHostsPage extends PureComponent {
|
|||
onLabelClick={onLabelClick}
|
||||
selectedFilter={selectedFilter}
|
||||
statusLabels={statusLabels}
|
||||
canAddNewLabel={canAddNewLabels}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -680,6 +682,9 @@ const mapStateToProps = (state, { location, params }) => {
|
|||
const canAddNewHosts =
|
||||
permissionUtils.isGlobalAdmin(currentUser) ||
|
||||
permissionUtils.isGlobalMaintainer(currentUser);
|
||||
const canAddNewLabels =
|
||||
permissionUtils.isGlobalAdmin(currentUser) ||
|
||||
permissionUtils.isGlobalMaintainer(currentUser);
|
||||
const isGlobalAdmin = permissionUtils.isGlobalAdmin(currentUser);
|
||||
const teams = memoizedGetEntity(state.entities.teams.data);
|
||||
|
||||
|
|
@ -699,6 +704,7 @@ const mapStateToProps = (state, { location, params }) => {
|
|||
hosts,
|
||||
loadingHosts,
|
||||
canAddNewHosts,
|
||||
canAddNewLabels,
|
||||
isGlobalAdmin,
|
||||
teams,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue