mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Reverting permissions.all changes except delete
This commit is contained in:
parent
6751fca848
commit
609c150b7d
26 changed files with 51 additions and 57 deletions
|
@ -113,7 +113,7 @@ describe('AddComment ', () => {
|
|||
).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should hide the component when the user does not have create permissions', () => {
|
||||
it('should hide the component when the user does not have all permissions', () => {
|
||||
useCreateAttachmentsMock.mockImplementation(() => ({
|
||||
...defaultResponse,
|
||||
isLoading: true,
|
||||
|
|
|
@ -147,7 +147,7 @@ export const AddComment = React.memo(
|
|||
return (
|
||||
<span id="add-comment-permLink">
|
||||
{isLoading && showLoading && <MySpinner data-test-subj="loading-spinner" size="xl" />}
|
||||
{permissions.create && (
|
||||
{permissions.all && (
|
||||
<Form form={form}>
|
||||
<UseField
|
||||
path={fieldName}
|
||||
|
|
|
@ -319,7 +319,7 @@ export const useCasesColumns = ({
|
|||
return (
|
||||
<StatusContextMenu
|
||||
currentStatus={theCase.status}
|
||||
disabled={!permissions.update || isLoadingUpdateCase}
|
||||
disabled={!permissions.all || isLoadingUpdateCase}
|
||||
onStatusChanged={(status) =>
|
||||
handleDispatchUpdate({
|
||||
updateKey: 'status',
|
||||
|
|
|
@ -24,7 +24,7 @@ describe('CasesTableHeader', () => {
|
|||
expect(result.getByTestId('createNewCaseBtn')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not display the create new case button when the user does not have create or update privileges', () => {
|
||||
it('does not display the create new case button when the user does not have all privileges', () => {
|
||||
appMockRender = createAppMockRenderer({
|
||||
permissions: buildCasesPermissions({ create: false, update: false }),
|
||||
});
|
||||
|
|
|
@ -22,8 +22,6 @@ type Props = OwnProps;
|
|||
export const CasesTableHeader: FunctionComponent<Props> = ({ actionsErrors }) => {
|
||||
const { permissions } = useCasesContext();
|
||||
|
||||
const showNavButtons = permissions.create && permissions.update;
|
||||
|
||||
return (
|
||||
<HeaderPage title={i18n.PAGE_TITLE} border data-test-subj="cases-all-title">
|
||||
<EuiFlexGroup
|
||||
|
@ -32,7 +30,7 @@ export const CasesTableHeader: FunctionComponent<Props> = ({ actionsErrors }) =>
|
|||
wrap={true}
|
||||
data-test-subj="all-cases-header"
|
||||
>
|
||||
{showNavButtons ? (
|
||||
{permissions.all ? (
|
||||
<EuiFlexItem>
|
||||
<NavButtons actionsErrors={actionsErrors} />
|
||||
</EuiFlexItem>
|
||||
|
|
|
@ -109,11 +109,11 @@ export const CasesTable: FunctionComponent<CasesTableProps> = ({
|
|||
<EuiEmptyPrompt
|
||||
title={<h3>{i18n.NO_CASES}</h3>}
|
||||
titleSize="xs"
|
||||
body={permissions.create ? i18n.NO_CASES_BODY : i18n.NO_CASES_BODY_READ_ONLY}
|
||||
body={permissions.all ? i18n.NO_CASES_BODY : i18n.NO_CASES_BODY_READ_ONLY}
|
||||
actions={
|
||||
permissions.create && (
|
||||
permissions.all && (
|
||||
<LinkButton
|
||||
isDisabled={!permissions.create}
|
||||
isDisabled={!permissions.all}
|
||||
fill
|
||||
size="s"
|
||||
onClick={navigateToCreateCaseClick}
|
||||
|
|
|
@ -90,7 +90,7 @@ describe('Cases routes', () => {
|
|||
expect(screen.getByText('Create case')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows the no privileges page if the user does not have create privileges', () => {
|
||||
it('shows the no privileges page if the user does not have all privileges', () => {
|
||||
renderWithRouter(['/cases/create'], noCreateCasesPermissions());
|
||||
expect(screen.getByText('Privileges required')).toBeInTheDocument();
|
||||
});
|
||||
|
@ -102,7 +102,7 @@ describe('Cases routes', () => {
|
|||
expect(screen.getByText('Configure cases')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows the no privileges page if the user does not have update privileges', () => {
|
||||
it('shows the no privileges page if the user does not have all privileges', () => {
|
||||
renderWithRouter(['/cases/configure'], noUpdateCasesPermissions());
|
||||
expect(screen.getByText('Privileges required')).toBeInTheDocument();
|
||||
});
|
||||
|
|
|
@ -58,7 +58,7 @@ const CasesRoutesComponent: React.FC<CasesRoutesProps> = ({
|
|||
</Route>
|
||||
|
||||
<Route path={getCreateCasePath(basePath)}>
|
||||
{permissions.create ? (
|
||||
{permissions.all ? (
|
||||
<CreateCase
|
||||
onSuccess={onCreateCaseSuccess}
|
||||
onCancel={navigateToAllCases}
|
||||
|
@ -70,8 +70,7 @@ const CasesRoutesComponent: React.FC<CasesRoutesProps> = ({
|
|||
</Route>
|
||||
|
||||
<Route path={getCasesConfigurePath(basePath)}>
|
||||
{/* TODO: should we add push here?*/}
|
||||
{permissions.update ? (
|
||||
{permissions.all ? (
|
||||
<ConfigureCases />
|
||||
) : (
|
||||
<NoPrivilegesPage pageName={i18n.CONFIGURE_CASES_PAGE_NAME} />
|
||||
|
|
|
@ -189,7 +189,7 @@ describe('CaseActionBar', () => {
|
|||
expect(getByText('Case opened')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should show the change status text when the user has update privileges', () => {
|
||||
it('should show the change status text when the user has all privileges', () => {
|
||||
render(
|
||||
<TestProviders>
|
||||
<CaseActionBar {...defaultProps} />
|
||||
|
@ -199,7 +199,7 @@ describe('CaseActionBar', () => {
|
|||
expect(screen.getByTitle('Change status')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should not show the change status text when the user does not have update privileges', () => {
|
||||
it('should not show the change status text when the user does not have all privileges', () => {
|
||||
render(
|
||||
<TestProviders permissions={noUpdateCasesPermissions()}>
|
||||
<CaseActionBar {...defaultProps} />
|
||||
|
@ -209,7 +209,7 @@ describe('CaseActionBar', () => {
|
|||
expect(screen.queryByTitle('Change status')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should not show the sync alerts toggle when the user does not have update privileges', () => {
|
||||
it('should not show the sync alerts toggle when the user does not have all privileges', () => {
|
||||
const { queryByText } = render(
|
||||
<TestProviders permissions={noUpdateCasesPermissions()}>
|
||||
<CaseActionBar {...defaultProps} />
|
||||
|
|
|
@ -107,7 +107,7 @@ const CaseActionBarComponent: React.FC<CaseActionBarProps> = ({
|
|||
<EuiDescriptionListDescription>
|
||||
<StatusContextMenu
|
||||
currentStatus={caseData.status}
|
||||
disabled={!permissions.update || isLoading}
|
||||
disabled={!permissions.all || isLoading}
|
||||
onStatusChanged={onStatusChanged}
|
||||
/>
|
||||
</EuiDescriptionListDescription>
|
||||
|
@ -134,7 +134,7 @@ const CaseActionBarComponent: React.FC<CaseActionBarProps> = ({
|
|||
responsive={false}
|
||||
justifyContent="spaceBetween"
|
||||
>
|
||||
{permissions.update && isSyncAlertsEnabled && (
|
||||
{permissions.all && isSyncAlertsEnabled && (
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiDescriptionListTitle>
|
||||
<EuiFlexGroup
|
||||
|
@ -172,7 +172,6 @@ const CaseActionBarComponent: React.FC<CaseActionBarProps> = ({
|
|||
</EuiButtonEmpty>
|
||||
</span>
|
||||
</EuiFlexItem>
|
||||
{/* currently just delete should we limit it to that? */}
|
||||
{permissions.all && (
|
||||
<EuiFlexItem grow={false} data-test-subj="case-view-actions">
|
||||
<Actions
|
||||
|
|
|
@ -114,7 +114,7 @@ describe('Case View Page activity tab', () => {
|
|||
expect(useGetCaseUserActionsMock).toHaveBeenCalledWith(caseData.id, caseData.connector.id);
|
||||
});
|
||||
|
||||
it('should not render the case view status button when the user does not have update permissions', () => {
|
||||
it('should not render the case view status button when the user does not have all permissions', () => {
|
||||
appMockRender = createAppMockRenderer({ permissions: noUpdateCasesPermissions() });
|
||||
|
||||
const result = appMockRender.render(<CaseViewActivity {...caseProps} />);
|
||||
|
@ -126,7 +126,7 @@ describe('Case View Page activity tab', () => {
|
|||
expect(useGetCaseUserActionsMock).toHaveBeenCalledWith(caseData.id, caseData.connector.id);
|
||||
});
|
||||
|
||||
it('should disable the severity selector when the user does not have update permissions', () => {
|
||||
it('should disable the severity selector when the user does not have all permissions', () => {
|
||||
appMockRender = createAppMockRenderer({ permissions: noUpdateCasesPermissions() });
|
||||
|
||||
const result = appMockRender.render(<CaseViewActivity {...caseProps} />);
|
||||
|
|
|
@ -133,7 +133,7 @@ export const CaseViewActivity = ({
|
|||
onShowAlertDetails={onShowAlertDetails}
|
||||
onUpdateField={onUpdateField}
|
||||
statusActionButton={
|
||||
permissions.update ? (
|
||||
permissions.all ? (
|
||||
<StatusActionButton
|
||||
status={caseData.status}
|
||||
onStatusChanged={changeStatus}
|
||||
|
@ -149,7 +149,7 @@ export const CaseViewActivity = ({
|
|||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={2}>
|
||||
<SeveritySidebarSelector
|
||||
isDisabled={!permissions.update}
|
||||
isDisabled={!permissions.all}
|
||||
isLoading={isLoading}
|
||||
selectedSeverity={caseData.severity}
|
||||
onSeverityChange={onUpdateSeverity}
|
||||
|
|
|
@ -188,7 +188,7 @@ describe('ConfigureCases', () => {
|
|||
expect(wrapper.find('[data-test-subj="edit-connector-flyout"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
test('it disables correctly when the user cannot update', () => {
|
||||
test('it disables correctly when the user does not have all privileges', () => {
|
||||
const newWrapper = mount(<ConfigureCases />, {
|
||||
wrappingComponent: TestProviders,
|
||||
wrappingComponentProps: { permissions: noUpdateCasesPermissions() },
|
||||
|
|
|
@ -222,11 +222,10 @@ export const ConfigureCases: React.FC = React.memo(() => {
|
|||
</EuiCallOut>
|
||||
</SectionWrapper>
|
||||
)}
|
||||
{/* should these include push? */}
|
||||
<SectionWrapper>
|
||||
<ClosureOptions
|
||||
closureTypeSelected={closureType}
|
||||
disabled={persistLoading || isLoadingConnectors || !permissions.update}
|
||||
disabled={persistLoading || isLoadingConnectors || !permissions.all}
|
||||
onChangeClosureType={onChangeClosureType}
|
||||
/>
|
||||
</SectionWrapper>
|
||||
|
@ -234,13 +233,13 @@ export const ConfigureCases: React.FC = React.memo(() => {
|
|||
<Connectors
|
||||
actionTypes={actionTypes}
|
||||
connectors={connectors ?? []}
|
||||
disabled={persistLoading || isLoadingConnectors || !permissions.update}
|
||||
disabled={persistLoading || isLoadingConnectors || !permissions.all}
|
||||
handleShowEditFlyout={onClickUpdateConnector}
|
||||
isLoading={isLoadingAny}
|
||||
mappings={mappings}
|
||||
onChangeConnector={onChangeConnector}
|
||||
selectedConnector={connector}
|
||||
updateConnectorDisabled={updateConnectorDisabled || !permissions.update}
|
||||
updateConnectorDisabled={updateConnectorDisabled || !permissions.all}
|
||||
/>
|
||||
</SectionWrapper>
|
||||
{ConnectorAddFlyout}
|
||||
|
|
|
@ -363,7 +363,7 @@ describe('EditConnector ', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('does not show the push button if the user does not have push permissions', async () => {
|
||||
it('does not show the push button if the user does not have all permissions', async () => {
|
||||
const defaultProps = getDefaultProps();
|
||||
|
||||
appMockRender = createAppMockRenderer({ permissions: noPushCasesPermissions() });
|
||||
|
|
|
@ -288,7 +288,7 @@ export const EditConnector = React.memo(
|
|||
<h4>{i18n.CONNECTORS}</h4>
|
||||
</EuiFlexItem>
|
||||
{isLoading && <EuiLoadingSpinner data-test-subj="connector-loading" />}
|
||||
{!isLoading && !editConnector && permissions.update && actionsReadCapabilities && (
|
||||
{!isLoading && !editConnector && permissions.all && actionsReadCapabilities && (
|
||||
<EuiFlexItem data-test-subj="connector-edit" grow={false}>
|
||||
<EuiButtonIcon
|
||||
data-test-subj="connector-edit-button"
|
||||
|
@ -316,7 +316,7 @@ export const EditConnector = React.memo(
|
|||
connectors,
|
||||
dataTestSubj: 'caseConnectors',
|
||||
defaultValue: selectedConnector,
|
||||
disabled: !permissions.update,
|
||||
disabled: !permissions.all,
|
||||
idAria: 'caseConnectors',
|
||||
isEdit: editConnector,
|
||||
isLoading,
|
||||
|
@ -372,7 +372,7 @@ export const EditConnector = React.memo(
|
|||
{pushCallouts == null &&
|
||||
!isLoading &&
|
||||
!editConnector &&
|
||||
permissions.push &&
|
||||
permissions.all &&
|
||||
actionsReadCapabilities && (
|
||||
<EuiFlexItem data-test-subj="has-data-to-push-button" grow={false}>
|
||||
<span>{pushButton}</span>
|
||||
|
|
|
@ -118,7 +118,7 @@ const EditableTitleComponent: React.FC<EditableTitleProps> = ({ onSubmit, isLoad
|
|||
) : (
|
||||
<Title title={title} releasePhase={releasePhase}>
|
||||
{isLoading && <MySpinner data-test-subj="editable-title-loading" />}
|
||||
{!isLoading && permissions.update && (
|
||||
{!isLoading && permissions.all && (
|
||||
<MyEuiButtonIcon
|
||||
aria-label={i18n.EDIT_TITLE_ARIA(title as string)}
|
||||
iconType="pencil"
|
||||
|
|
|
@ -25,7 +25,7 @@ describe('NoCases', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('displays a message without a link to create a case when the user does not have create permissions', () => {
|
||||
it('displays a message without a link to create a case when the user does not have all permissions', () => {
|
||||
const wrapper = mount(
|
||||
<TestProviders permissions={readCasesPermissions()}>
|
||||
<NoCases />
|
||||
|
|
|
@ -24,7 +24,7 @@ const NoCasesComponent = () => {
|
|||
[navigateToCreateCase]
|
||||
);
|
||||
|
||||
return permissions.create ? (
|
||||
return permissions.all ? (
|
||||
<>
|
||||
<span>{i18n.NO_CASES}</span>
|
||||
<LinkAnchor
|
||||
|
|
|
@ -107,7 +107,7 @@ describe('TagList ', () => {
|
|||
expect(wrapper.find(`[data-test-subj="tag-pepsi"]`).last().exists()).toBeTruthy();
|
||||
});
|
||||
|
||||
it('does not render when the user does not have update permissions', () => {
|
||||
it('does not render when the user does not have all permissions', () => {
|
||||
const wrapper = mount(
|
||||
<TestProviders permissions={readCasesPermissions()}>
|
||||
<TagList {...defaultProps} />
|
||||
|
|
|
@ -104,7 +104,7 @@ export const TagList = React.memo(({ isLoading, onSubmit, tags }: TagListProps)
|
|||
<h4>{i18n.TAGS}</h4>
|
||||
</EuiFlexItem>
|
||||
{isLoading && <EuiLoadingSpinner data-test-subj="tag-list-loading" />}
|
||||
{!isLoading && permissions.update && (
|
||||
{!isLoading && permissions.all && (
|
||||
<EuiFlexItem data-test-subj="tag-list-edit" grow={false}>
|
||||
<EuiButtonIcon
|
||||
data-test-subj="tag-list-edit-button"
|
||||
|
|
|
@ -280,7 +280,7 @@ describe('usePushToService', () => {
|
|||
});
|
||||
|
||||
describe('user does not have write permissions', () => {
|
||||
it('disables the push button when the user does not have push permissions', async () => {
|
||||
it('disables the push button when the user does not have all permissions', async () => {
|
||||
await act(async () => {
|
||||
const { result, waitForNextUpdate } = renderHook<UsePushToService, ReturnUsePushToService>(
|
||||
() => usePushToService(defaultArgs),
|
||||
|
|
|
@ -76,7 +76,7 @@ export const usePushToService = ({
|
|||
|
||||
// these message require that the user do some sort of write action as a result of the message, readonly users won't
|
||||
// be able to perform such an action so let's not display the error to the user in that situation
|
||||
if (!permissions.update) {
|
||||
if (!permissions.all) {
|
||||
return errors;
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ export const usePushToService = ({
|
|||
|
||||
return errors;
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [actionLicense, caseStatus, connectors.length, connector, loadingLicense, permissions.update]);
|
||||
}, [actionLicense, caseStatus, connectors.length, connector, loadingLicense, permissions.all]);
|
||||
|
||||
const pushToServiceButton = useMemo(
|
||||
() => (
|
||||
|
@ -126,7 +126,7 @@ export const usePushToService = ({
|
|||
isLoading ||
|
||||
loadingLicense ||
|
||||
errorsMsg.length > 0 ||
|
||||
!permissions.push ||
|
||||
!permissions.all ||
|
||||
!isValidConnector ||
|
||||
!hasDataToPush
|
||||
}
|
||||
|
@ -146,13 +146,13 @@ export const usePushToService = ({
|
|||
hasDataToPush,
|
||||
isLoading,
|
||||
loadingLicense,
|
||||
permissions.push,
|
||||
permissions.all,
|
||||
isValidConnector,
|
||||
]
|
||||
);
|
||||
|
||||
const objToReturn = useMemo(() => {
|
||||
const hidePushButton = errorsMsg.length > 0 || !hasDataToPush || !permissions.push;
|
||||
const hidePushButton = errorsMsg.length > 0 || !hasDataToPush || !permissions.all;
|
||||
|
||||
return {
|
||||
pushButton: hidePushButton ? (
|
||||
|
@ -184,7 +184,7 @@ export const usePushToService = ({
|
|||
hasLicenseError,
|
||||
onEditClick,
|
||||
pushToServiceButton,
|
||||
permissions.push,
|
||||
permissions.all,
|
||||
]);
|
||||
|
||||
return objToReturn;
|
||||
|
|
|
@ -230,7 +230,7 @@ export const UserActions = React.memo(
|
|||
|
||||
const { permissions } = useCasesContext();
|
||||
|
||||
const bottomActions = permissions.create
|
||||
const bottomActions = permissions.all
|
||||
? [
|
||||
{
|
||||
username: (
|
||||
|
|
|
@ -117,10 +117,10 @@ describe('UserActionPropertyActions ', () => {
|
|||
</TestProviders>
|
||||
);
|
||||
|
||||
userEvent.click(renderResult.getByTestId('property-actions-ellipses'));
|
||||
expect(renderResult.queryByTestId('property-actions-ellipses')).not.toBeInTheDocument();
|
||||
expect(renderResult.queryByTestId('property-actions-trash')).not.toBeInTheDocument();
|
||||
expect(renderResult.queryByTestId('property-actions-pencil')).toBeInTheDocument();
|
||||
expect(renderResult.queryByTestId('property-actions-quote')).toBeInTheDocument();
|
||||
expect(renderResult.queryByTestId('property-actions-pencil')).not.toBeInTheDocument();
|
||||
expect(renderResult.queryByTestId('property-actions-quote')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not show the pencil icon when the user does not have update permissions', () => {
|
||||
|
@ -133,7 +133,7 @@ describe('UserActionPropertyActions ', () => {
|
|||
userEvent.click(renderResult.getByTestId('property-actions-ellipses'));
|
||||
expect(renderResult.queryByTestId('property-actions-trash')).toBeInTheDocument();
|
||||
expect(renderResult.queryByTestId('property-actions-pencil')).not.toBeInTheDocument();
|
||||
expect(renderResult.queryByTestId('property-actions-quote')).toBeInTheDocument();
|
||||
expect(renderResult.queryByTestId('property-actions-quote')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not show the quote icon when the user does not have create permissions', () => {
|
||||
|
@ -145,7 +145,7 @@ describe('UserActionPropertyActions ', () => {
|
|||
|
||||
userEvent.click(renderResult.getByTestId('property-actions-ellipses'));
|
||||
expect(renderResult.queryByTestId('property-actions-trash')).toBeInTheDocument();
|
||||
expect(renderResult.queryByTestId('property-actions-pencil')).toBeInTheDocument();
|
||||
expect(renderResult.queryByTestId('property-actions-pencil')).not.toBeInTheDocument();
|
||||
expect(renderResult.queryByTestId('property-actions-quote')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
|
|
@ -60,10 +60,10 @@ const UserActionPropertyActionsComponent = ({
|
|||
}, []);
|
||||
|
||||
const propertyActions = useMemo(() => {
|
||||
const showEditPencilIcon = permissions.update;
|
||||
const showEditPencilIcon = permissions.all;
|
||||
const showTrashIcon = permissions.delete && deleteLabel && onDelete;
|
||||
const showQuoteIcon = permissions.create;
|
||||
const showLensEditor = permissions.update && canUseEditor && actionConfig;
|
||||
const showQuoteIcon = permissions.all;
|
||||
const showLensEditor = permissions.all && canUseEditor && actionConfig;
|
||||
|
||||
return [
|
||||
...(showEditPencilIcon
|
||||
|
@ -96,9 +96,8 @@ const UserActionPropertyActionsComponent = ({
|
|||
...(showLensEditor ? [actionConfig] : []),
|
||||
];
|
||||
}, [
|
||||
permissions.update,
|
||||
permissions.all,
|
||||
permissions.delete,
|
||||
permissions.create,
|
||||
deleteLabel,
|
||||
onDelete,
|
||||
canUseEditor,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue