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

[Cases] RBAC Bugs #101325

Merged
merged 141 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from 139 commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
7f1a7dd
Adding feature flag for auth
jonathan-buttner Mar 9, 2021
164582d
Hiding SOs and adding consumer field
jonathan-buttner Mar 9, 2021
7eaf41e
First pass at adding security changes
jonathan-buttner Mar 9, 2021
f8e62c6
Consumer as the app's plugin ID
cnasikas Mar 10, 2021
09589c3
Create addConsumerToSO migration helper
cnasikas Mar 10, 2021
eb75eb0
Fix mapping's SO consumer
cnasikas Mar 10, 2021
a930f03
Add test for CasesActions
cnasikas Mar 10, 2021
d6f3b09
Declare hidden types on SO client
cnasikas Mar 10, 2021
b82e686
Restructure integration tests
cnasikas Mar 10, 2021
4d05175
Init spaces_only integration tests
cnasikas Mar 10, 2021
75d72ae
Implementing the cases security string
jonathan-buttner Mar 10, 2021
e65838b
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner Mar 10, 2021
1fd66af
Adding security plugin tests for cases
jonathan-buttner Mar 10, 2021
4560d42
Rough concept for authorization class
jonathan-buttner Mar 10, 2021
ef9b3b2
Adding comments
jonathan-buttner Mar 10, 2021
b22a032
Fix merge
cnasikas Mar 11, 2021
ddc2280
Get requiredPrivileges for classes
cnasikas Mar 11, 2021
9d008d8
Check privillages
cnasikas Mar 11, 2021
7bb23dd
Ensure that all classes are available
cnasikas Mar 11, 2021
65d4c6b
Success if hasAllRequested is true
cnasikas Mar 11, 2021
59e4045
Failure if hasAllRequested is false
cnasikas Mar 11, 2021
4092733
Adding schema updates for feature plugin
jonathan-buttner Mar 11, 2021
311e3f4
Seperate basic from trial
cnasikas Mar 16, 2021
f2a50d3
Enable SIR on integration tests
cnasikas Mar 16, 2021
00d89ca
Starting the plumbing for authorization in plugin
jonathan-buttner Mar 16, 2021
40cfcce
Merge branch 'master' into cases-rbac-poc
cnasikas Mar 17, 2021
644a7ac
Unit tests working
jonathan-buttner Mar 17, 2021
9bb1b86
Merge branch 'cases-rbac-poc-plugin-changes' into cases-rbac-poc
jonathan-buttner Mar 17, 2021
12d6e2e
Move find route logic to case client
cnasikas Mar 17, 2021
84d9167
Create integration test helper functions
cnasikas Mar 17, 2021
4bed458
Adding auth to create call
jonathan-buttner Mar 17, 2021
ecb3135
Create getClassFilter helper
cnasikas Mar 18, 2021
fe1d8c8
Add class attribute to find request
cnasikas Mar 18, 2021
22e7752
Create getFindAuthorizationFilter
cnasikas Mar 18, 2021
96f81a4
Ensure savedObject is authorized in find method
cnasikas Mar 18, 2021
e3ae097
Merge branch 'master' into cases-rbac-poc
cnasikas Mar 22, 2021
06d7c64
Include fields for authorization
cnasikas Mar 22, 2021
2ca4134
Combine authorization filter with cases & subcases filter
cnasikas Mar 22, 2021
17110b1
Fix isAuthorized flag
cnasikas Mar 22, 2021
bc06264
Fix merge issue
cnasikas Mar 22, 2021
a04e0d7
Create/delete spaces & users before and after tests
cnasikas Mar 22, 2021
7fe4e40
Add more user and roles
cnasikas Mar 22, 2021
2847861
[Cases] Convert filters from strings to KueryNode (#95288)
cnasikas Mar 24, 2021
a2e1da8
[Cases] RBAC: Rename class to scope (#95535)
cnasikas Mar 26, 2021
9263d7d
Merge branch 'master' into cases-rbac-poc
cnasikas Mar 26, 2021
afff0cc
Merge branch 'master' into cases-rbac-poc
cnasikas Apr 1, 2021
7cf9172
[Cases][RBAC] Rename scope to owner (#96035)
cnasikas Apr 1, 2021
0a95e55
[Cases] RBAC: Create & Find integration tests (#95511)
cnasikas Apr 2, 2021
1a895e5
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner Apr 5, 2021
9ffc3db
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner Apr 6, 2021
4f3c37e
[Cases] Cases client enchantment (#95923)
cnasikas Apr 6, 2021
36781db
[Cases] Authorization and Client Audit Logger (#95477)
jonathan-buttner Apr 6, 2021
73a4bfc
[Cases] Migrate sub cases routes to a client (#96461)
jonathan-buttner Apr 8, 2021
ae918cc
Merge branch 'master' into cases-rbac-poc
cnasikas Apr 12, 2021
e59602c
Merge branch 'cases-rbac-poc' of github.com:elastic/kibana into cases…
cnasikas Apr 12, 2021
34f2d86
[Cases] RBAC: Migrate routes' unit tests to integration tests (#96374)
cnasikas Apr 14, 2021
613e859
[Cases] Move remaining HTTP functionality to client (#96507)
jonathan-buttner Apr 14, 2021
676173e
[Cases] Refactoring authorization (#97483)
jonathan-buttner Apr 20, 2021
6cdfa84
[Cases] Add authorization to configuration & cases routes (#97228)
cnasikas Apr 26, 2021
7b21b7a
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner Apr 27, 2021
103388e
[Cases] Attachments RBAC (#97756)
jonathan-buttner Apr 30, 2021
18e75d9
[Cases] Add RBAC to remaining Cases APIs (#98762)
jonathan-buttner May 4, 2021
d99d9f8
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 4, 2021
b121662
Fixing some type errors
jonathan-buttner May 4, 2021
42162e3
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 6, 2021
298ba34
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 6, 2021
c0fb868
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 7, 2021
21d173d
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 10, 2021
b910889
[Cases] Add space only tests (#99409)
jonathan-buttner May 10, 2021
78dfac4
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 10, 2021
bf583a8
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 11, 2021
3fd893f
[Cases] Add security only tests (#99679)
jonathan-buttner May 11, 2021
86568ed
Adding sub feature
jonathan-buttner May 12, 2021
952e2a3
[Cases] Cleaning up the services and TODOs (#99723)
jonathan-buttner May 14, 2021
e26de43
Integration tests for cases privs and fixes (#100038)
jonathan-buttner May 14, 2021
2d8601b
[Cases] RBAC on UI (#99478)
cnasikas May 14, 2021
570cddb
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 14, 2021
3c7670b
Fixing case ids by alert id route call
jonathan-buttner May 14, 2021
dafb4fe
[Cases] Fixing UI feature permissions and adding UI tests (#100074)
jonathan-buttner May 14, 2021
b7c5ebd
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 14, 2021
698e8e2
Fixing type error
jonathan-buttner May 14, 2021
22abf1f
Merge branch 'master' into cases-rbac-poc
kibanamachine May 17, 2021
71225eb
Adding some comments
jonathan-buttner May 17, 2021
f7a816b
Validate cases features
cnasikas May 18, 2021
2ed0a99
Merge branch 'master' into cases-rbac-poc
cnasikas May 18, 2021
fd39b25
Fix new schema
cnasikas May 18, 2021
a193138
Merge branch 'master' into cases-rbac-poc
kibanamachine May 18, 2021
1f9059c
Merge branch 'master' into cases-rbac-poc
kibanamachine May 20, 2021
2085a3b
Merge branch 'master' into cases-rbac-poc
kibanamachine May 24, 2021
66c1d43
Adding owner param for the status stats
jonathan-buttner May 24, 2021
018dcb5
Merge branch 'master' into cases-rbac-poc
kibanamachine May 24, 2021
34b16c5
Fix get case status tests
cnasikas May 25, 2021
9ba1243
Adjusting permissions text and fixing status
jonathan-buttner May 25, 2021
315a6e4
Address PR feedback
jonathan-buttner May 26, 2021
02ad6a4
Adding top level feature back
jonathan-buttner May 26, 2021
e8c3532
Merge branch 'master' into cases-rbac-poc
kibanamachine May 26, 2021
8881899
Fixing feature privileges
jonathan-buttner May 27, 2021
dd62656
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 27, 2021
acf550b
Renaming
jonathan-buttner May 27, 2021
148623e
Removing uneeded else
jonathan-buttner May 27, 2021
7acf83a
Fixing tests and adding cases merge tests
jonathan-buttner May 27, 2021
b03fa4c
Merge branch 'master' into cases-rbac-poc
kibanamachine May 28, 2021
445c846
[Cases][Security Solution] Basic license security solution API tests …
jonathan-buttner Jun 1, 2021
c08ac43
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner Jun 1, 2021
373cd68
Merge branch 'master' into cases-rbac-poc
kibanamachine Jun 2, 2021
d59dbad
renaming to unsecuredSavedObjectsClient (#101215)
jonathan-buttner Jun 3, 2021
7ef02f4
Merge branch 'master' into cases-rbac-poc
kibanamachine Jun 3, 2021
739fd6f
[Cases] RBAC Refactoring audit logging (#100952)
jonathan-buttner Jun 3, 2021
86f5540
conditional rendering the recently created cases
jonathan-buttner Jun 3, 2021
599ddb9
Merge branch 'cases-rbac-poc' of github.com:elastic/kibana into cases…
jonathan-buttner Jun 3, 2021
eadbfd8
Remove unnecessary Array.from
jonathan-buttner Jun 3, 2021
c32dc14
Cleaning up overview page for permissions
jonathan-buttner Jun 3, 2021
56a9a3d
Fixing log message for attachments
jonathan-buttner Jun 3, 2021
d5bd11b
hiding add to cases button
jonathan-buttner Jun 3, 2021
dee17f5
Disable the Cases app from the global nav
jonathan-buttner Jun 4, 2021
bca5793
Hide the add to cases button from detections
jonathan-buttner Jun 4, 2021
ab2632c
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-bugs
jonathan-buttner Jun 7, 2021
4f28947
Fixing merge
jonathan-buttner Jun 7, 2021
60efdf0
Making progress on removing icons
jonathan-buttner Jun 7, 2021
b46a94e
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-bugs
jonathan-buttner Jun 9, 2021
f80b88d
Hding edit icons on detail view
jonathan-buttner Jun 9, 2021
7c27b47
Trying to get connector error msg tests working
jonathan-buttner Jun 9, 2021
b7cf87a
Removing test
jonathan-buttner Jun 10, 2021
5dea976
Disable error callouts
jonathan-buttner Jun 10, 2021
4ba1123
Fixing spacing and removing cases tab one no read
jonathan-buttner Jun 10, 2021
1296193
Adding read only badge
jonathan-buttner Jun 10, 2021
22e35e1
Resolver merge conflicts
jonathan-buttner Jun 10, 2021
c4dfebd
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-bugs
jonathan-buttner Jun 14, 2021
423286a
Cleaning up and adding badge
jonathan-buttner Jun 14, 2021
1a84ed5
Wrapping in use effect
jonathan-buttner Jun 14, 2021
187a2bf
Default toasting permissions errors
jonathan-buttner Jun 14, 2021
301c191
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-bugs
jonathan-buttner Jun 15, 2021
c5c6e49
Merge branch 'master' into cases-rbac-bugs
kibanamachine Jun 15, 2021
c0b9c7c
Removing actions icon on comments
jonathan-buttner Jun 16, 2021
fa5d183
Addressing feedback
jonathan-buttner Jun 16, 2021
5f816fc
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-bugs
jonathan-buttner Jun 16, 2021
7c965c9
Fixing type
jonathan-buttner Jun 16, 2021
4f8ac35
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-bugs
jonathan-buttner Jun 17, 2021
320621e
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-bugs
jonathan-buttner Jun 17, 2021
0b6b50c
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-bugs
jonathan-buttner Jun 21, 2021
be52548
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-bugs
jonathan-buttner Jun 21, 2021
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
26 changes: 18 additions & 8 deletions x-pack/plugins/cases/public/components/add_comment/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { TestProviders } from '../../common/mock';

import { CommentRequest, CommentType, SECURITY_SOLUTION_OWNER } from '../../../common';
import { usePostComment } from '../../containers/use_post_comment';
import { AddComment, AddCommentRefObject } from '.';
import { AddComment, AddCommentProps, AddCommentRefObject } from '.';
import { CasesTimelineIntegrationProvider } from '../timeline_context';
import { timelineIntegrationMock } from '../__mock__/timeline';

Expand All @@ -25,10 +25,9 @@ const onCommentSaving = jest.fn();
const onCommentPosted = jest.fn();
const postComment = jest.fn();

const addCommentProps = {
const addCommentProps: AddCommentProps = {
caseId: '1234',
disabled: false,
insertQuote: null,
userCanCrud: true,
onCommentSaving,
onCommentPosted,
showLoading: false,
Expand Down Expand Up @@ -94,11 +93,11 @@ describe('AddComment ', () => {
).toBeTruthy();
});

it('should disable submit button when disabled prop passed', () => {
it('should disable submit button when isLoading is true', () => {
usePostCommentMock.mockImplementation(() => ({ ...defaultPostComment, isLoading: true }));
const wrapper = mount(
<TestProviders>
<AddComment {...{ ...addCommentProps, disabled: true }} />
<AddComment {...addCommentProps} />
</TestProviders>
);

Expand All @@ -107,12 +106,23 @@ describe('AddComment ', () => {
).toBeTruthy();
});

it('should hide the component when the user does not have crud permissions', () => {
usePostCommentMock.mockImplementation(() => ({ ...defaultPostComment, isLoading: true }));
const wrapper = mount(
<TestProviders>
<AddComment {...{ ...addCommentProps, userCanCrud: false }} />
</TestProviders>
);

expect(wrapper.find(`[data-test-subj="add-comment"]`).exists()).toBeFalsy();
});

it('should insert a quote', async () => {
const sampleQuote = 'what a cool quote';
const ref = React.createRef<AddCommentRefObject>();
const wrapper = mount(
<TestProviders>
<AddComment {...{ ...addCommentProps }} ref={ref} />
<AddComment {...addCommentProps} ref={ref} />
</TestProviders>
);

Expand Down Expand Up @@ -143,7 +153,7 @@ describe('AddComment ', () => {
const wrapper = mount(
<TestProviders>
<CasesTimelineIntegrationProvider timelineIntegration={mockTimelineIntegration}>
<AddComment {...{ ...addCommentProps }} />
<AddComment {...addCommentProps} />
</CasesTimelineIntegrationProvider>
</TestProviders>
);
Expand Down
58 changes: 30 additions & 28 deletions x-pack/plugins/cases/public/components/add_comment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ export interface AddCommentRefObject {
addQuote: (quote: string) => void;
}

interface AddCommentProps {
export interface AddCommentProps {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exporting so I can use it in the test above to ensure that the props stay inline with the definition.

caseId: string;
disabled?: boolean;
userCanCrud?: boolean;
onCommentSaving?: () => void;
onCommentPosted: (newCase: Case) => void;
showLoading?: boolean;
Expand All @@ -45,7 +45,7 @@ interface AddCommentProps {
export const AddComment = React.memo(
forwardRef<AddCommentRefObject, AddCommentProps>(
(
{ caseId, disabled, onCommentPosted, onCommentSaving, showLoading = true, subCaseId },
{ caseId, userCanCrud, onCommentPosted, onCommentSaving, showLoading = true, subCaseId },
ref
) => {
const owner = useOwnerContext();
Expand Down Expand Up @@ -91,31 +91,33 @@ export const AddComment = React.memo(
return (
<span id="add-comment-permLink">
{isLoading && showLoading && <MySpinner data-test-subj="loading-spinner" size="xl" />}
<Form form={form}>
<UseField
path={fieldName}
component={MarkdownEditorForm}
componentProps={{
idAria: 'caseComment',
isDisabled: isLoading,
dataTestSubj: 'add-comment',
placeholder: i18n.ADD_COMMENT_HELP_TEXT,
bottomRightContent: (
<EuiButton
data-test-subj="submit-comment"
iconType="plusInCircle"
isDisabled={isLoading || disabled}
isLoading={isLoading}
onClick={onSubmit}
size="s"
>
{i18n.ADD_COMMENT}
</EuiButton>
),
}}
/>
<InsertTimeline fieldName="comment" />
</Form>
{userCanCrud && (
<Form form={form}>
<UseField
path={fieldName}
component={MarkdownEditorForm}
componentProps={{
idAria: 'caseComment',
isDisabled: isLoading,
dataTestSubj: 'add-comment',
placeholder: i18n.ADD_COMMENT_HELP_TEXT,
bottomRightContent: (
<EuiButton
data-test-subj="submit-comment"
iconType="plusInCircle"
isDisabled={isLoading}
isLoading={isLoading}
onClick={onSubmit}
size="s"
>
{i18n.ADD_COMMENT}
</EuiButton>
),
}}
/>
<InsertTimeline fieldName="comment" />
</Form>
)}
</span>
);
}
Expand Down
32 changes: 21 additions & 11 deletions x-pack/plugins/cases/public/components/all_cases/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,27 @@ export const CasesTableHeader: FunctionComponent<Props> = ({
wrap={true}
data-test-subj="all-cases-header"
>
<FlexItemDivider grow={false}>
<Count refresh={refresh} />
</FlexItemDivider>
<EuiFlexItem grow={false}>
<NavButtons
actionsErrors={actionsErrors}
configureCasesNavigation={configureCasesNavigation}
createCaseNavigation={createCaseNavigation}
userCanCrud={userCanCrud}
/>
</EuiFlexItem>
{userCanCrud ? (
<>
<FlexItemDivider grow={false}>
<Count refresh={refresh} />
</FlexItemDivider>

<EuiFlexItem grow={false}>
<NavButtons
actionsErrors={actionsErrors}
configureCasesNavigation={configureCasesNavigation}
createCaseNavigation={createCaseNavigation}
/>
</EuiFlexItem>
</>
) : (
// doesn't include the horizontal bar that divides the buttons and other padding since we don't have any buttons
// to the right
<EuiFlexItem>
<Count refresh={refresh} />
</EuiFlexItem>
)}
</EuiFlexGroup>
</CaseHeaderPage>
);
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ interface OwnProps {
actionsErrors: ErrorMessage[];
configureCasesNavigation: CasesNavigation;
createCaseNavigation: CasesNavigation;
userCanCrud: boolean;
}

type Props = OwnProps;
Expand All @@ -26,22 +25,20 @@ export const NavButtons: FunctionComponent<Props> = ({
actionsErrors,
configureCasesNavigation,
createCaseNavigation,
userCanCrud,
}) => (
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<ConfigureCaseButton
configureCasesNavigation={configureCasesNavigation}
label={i18n.CONFIGURE_CASES_BUTTON}
isDisabled={!isEmpty(actionsErrors) || !userCanCrud}
isDisabled={!isEmpty(actionsErrors)}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to rely on userCanCrud because this component shouldn't be rendered at all if the user doesn't have permissions.

showToolTip={!isEmpty(actionsErrors)}
msgTooltip={!isEmpty(actionsErrors) ? actionsErrors[0].description : <></>}
titleTooltip={!isEmpty(actionsErrors) ? actionsErrors[0].title : ''}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<LinkButton
isDisabled={!userCanCrud}
fill
onClick={createCaseNavigation.onClick}
href={createCaseNavigation.href}
Expand Down
26 changes: 14 additions & 12 deletions x-pack/plugins/cases/public/components/all_cases/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,21 @@ export const CasesTable: FunctionComponent<CasesTableProps> = ({
<EuiEmptyPrompt
title={<h3>{i18n.NO_CASES}</h3>}
titleSize="xs"
body={i18n.NO_CASES_BODY}
body={userCanCrud ? i18n.NO_CASES_BODY : i18n.NO_CASES_BODY_READ_ONLY}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The NO_CASES_BODY_READ_ONLY doesn't state anything about creating a case since the readonly user won't be able to do that.

actions={
<LinkButton
isDisabled={!userCanCrud}
fill
size="s"
onClick={goToCreateCase}
href={createCaseNavigation.href}
iconType="plusInCircle"
data-test-subj="cases-table-add-case"
>
{i18n.ADD_NEW_CASE}
</LinkButton>
userCanCrud && (
<LinkButton
isDisabled={!userCanCrud}
fill
size="s"
onClick={goToCreateCase}
href={createCaseNavigation.href}
iconType="plusInCircle"
data-test-subj="cases-table-add-case"
>
{i18n.ADD_NEW_CASE}
</LinkButton>
)
}
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ export * from '../../common/translations';
export const NO_CASES = i18n.translate('xpack.cases.caseTable.noCases.title', {
defaultMessage: 'No Cases',
});

export const NO_CASES_BODY = i18n.translate('xpack.cases.caseTable.noCases.body', {
defaultMessage:
'There are no cases to display. Please create a new case or change your filter settings above.',
});

export const NO_CASES_BODY_READ_ONLY = i18n.translate(
'xpack.cases.caseTable.noCases.readonly.body',
{
defaultMessage: 'There are no cases to display. Please change your filter settings above.',
}
);

export const ADD_NEW_CASE = i18n.translate('xpack.cases.caseTable.addNewCase', {
defaultMessage: 'Add New Case',
});
Expand Down
11 changes: 0 additions & 11 deletions x-pack/plugins/cases/public/components/callout/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,7 @@
* 2.0.
*/

import React from 'react';
import md5 from 'md5';

import * as i18n from './translations';
import { ErrorMessage } from './types';

export const permissionsReadOnlyErrorMessage: ErrorMessage = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer referenced.

id: 'read-only-privileges-error',
title: i18n.READ_ONLY_FEATURE_TITLE,
description: <>{i18n.READ_ONLY_FEATURE_MSG}</>,
errorType: 'warning',
};

export const createCalloutId = (ids: string[], delimiter: string = '|'): string =>
md5(ids.join(delimiter));
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@

import { i18n } from '@kbn/i18n';

export const READ_ONLY_FEATURE_TITLE = i18n.translate('xpack.cases.readOnlyFeatureTitle', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heads up, we're going to have a few conflicts between this and my Cases Cleanup PR #102103

defaultMessage: 'You cannot open new or update existing cases',
});

export const READ_ONLY_FEATURE_MSG = i18n.translate('xpack.cases.readOnlyFeatureDescription', {
defaultMessage:
'You only have privileges to view cases. If you need to open and update cases, contact your Kibana administrator.',
});

export const DISMISS_CALLOUT = i18n.translate('xpack.cases.dismissErrorsPushServiceCallOutTitle', {
defaultMessage: 'Dismiss',
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ interface CaseViewActions {
allCasesNavigation: CasesNavigation;
caseData: Case;
currentExternalIncident: CaseService | null;
disabled?: boolean;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is hidden by the parent component if it is a readonly user.

}

const ActionsComponent: React.FC<CaseViewActions> = ({
allCasesNavigation,
caseData,
currentExternalIncident,
disabled = false,
}) => {
// Delete case
const {
Expand All @@ -39,7 +37,6 @@ const ActionsComponent: React.FC<CaseViewActions> = ({
const propertyActions = useMemo(
() => [
{
disabled,
iconType: 'trash',
label: i18n.DELETE_CASE(),
onClick: handleToggleModal,
Expand All @@ -54,7 +51,7 @@ const ActionsComponent: React.FC<CaseViewActions> = ({
]
: []),
],
[disabled, handleToggleModal, currentExternalIncident]
[handleToggleModal, currentExternalIncident]
);

if (isDeleted) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('CaseActionBar', () => {
onRefresh,
onUpdateField,
currentExternalIncident: null,
userCanCrud: true,
};

beforeEach(() => {
Expand Down
Loading