Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #36549 - params tab show buttons only with premissions #9762

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ export const EditParametersTableRow = ({
</>
</Td>
)}
<RowActions hostId={hostId} param={param} />
<RowActions
hostId={hostId}
param={param}
editHostsPermission={editHostsPermission}
/>
</Tr>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ export const ParametersTable = ({
/>
</ToolbarItem>
<ToolbarItem>
<Button
ouiaId="add-parameter-btn"
onClick={() => setShowNewRow(true)}
>
{__('Add parameter')}
</Button>
{editHostsPermission && (
<Button
ouiaId="add-parameter-btn"
onClick={() => setShowNewRow(true)}
>
{__('Add parameter')}
</Button>
)}
</ToolbarItem>
<ToolbarItem>
{status === STATUS.PENDING && <Spinner loading size="sm" />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { HOST_PARAM } from './ParametersConstants';
import { openConfirmModal } from '../../../ConfirmModal';
import { updateHost } from '../../ActionsBar/actions';

export const RowActions = ({ hostId, param }) => {
export const RowActions = ({ hostId, param, editHostsPermission }) => {
const dispatch = useDispatch();
const onDelete = () =>
dispatch(
Expand All @@ -27,23 +27,24 @@ export const RowActions = ({ hostId, param }) => {
})
);
const rowActions = [
param.associated_type === HOST_PARAM && {
title: __('Delete'),
onClick: () => {
dispatch(
openConfirmModal({
title: sprintf(__('Delete %s'), param.name),
message: __(
'This will change the delete the parameter, are you sure?'
),
isWarning: true,
onConfirm: () => {
onDelete();
},
})
);
editHostsPermission &&
param.associated_type === HOST_PARAM && {
title: __('Delete'),
onClick: () => {
dispatch(
openConfirmModal({
title: sprintf(__('Delete %s'), param.name),
message: __(
'This will change the delete the parameter, are you sure?'
),
isWarning: true,
onConfirm: () => {
onDelete();
},
})
);
},
},
},
].filter(a => a);
return (
<Td isActionCell className="parameters-actions">
Expand All @@ -63,4 +64,5 @@ RowActions.propTypes = {
associated_type: PropTypes.string,
}).isRequired,
hostId: PropTypes.number.isRequired,
editHostsPermission: PropTypes.bool.isRequired,
};
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ export const ViewParametersTableRow = ({
</Tooltip>
</Td>
)}
<RowActions hostId={hostId} param={param} />
<RowActions
hostId={hostId}
param={param}
editHostsPermission={editHostsPermission}
/>
</Tr>
);

Expand Down