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] Disable deletion of cases files in stack mgmt. #155683

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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
13 changes: 13 additions & 0 deletions x-pack/plugins/cases/common/constants/owners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ export const GENERAL_CASES_OWNER = APP_ID;

export const OWNERS = [GENERAL_CASES_OWNER, OBSERVABILITY_OWNER, SECURITY_SOLUTION_OWNER] as const;

export const getOwnerUIName = (owner: Owner) => {
Copy link
Member

Choose a reason for hiding this comment

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

The OWNER_INFO contains an attribute called label. Maybe we can use it. The names are a bit different but we can change it to match what you have here. They are being shown in the case flyout and in the cases modal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed those but, what is this OWNER_INFO used for? Is it safe to just extend?

switch (owner) {
case SECURITY_SOLUTION_OWNER:
return 'Security Solution';
case OBSERVABILITY_OWNER:
return 'Observability';
case GENERAL_CASES_OWNER:
return 'Stack Management';
default:
return owner;
}
};

interface RouteInfo {
id: Owner;
appId: string;
Expand Down
10 changes: 9 additions & 1 deletion x-pack/plugins/cases/public/files/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,24 @@

import type { FilesSetup } from '@kbn/files-plugin/public';
import type { FileKindBrowser } from '@kbn/shared-ux-file-types';
import { MAX_FILE_SIZE, OWNERS } from '../../common/constants';
import { MAX_FILE_SIZE, OWNERS, getOwnerUIName } from '../../common/constants';
import type { Owner } from '../../common/constants/types';
import { constructFileKindIdByOwner } from '../../common/files';
import type { CaseFileKinds, FilesConfig } from './types';

import * as i18n from './translations';

const buildFileKind = (config: FilesConfig, owner: Owner): FileKindBrowser => {
return {
id: constructFileKindIdByOwner(owner),
allowedMimeTypes: config.allowedMimeTypes,
maxSizeBytes: config.maxSize ?? MAX_FILE_SIZE,
managementUiActions: {
delete: {
cnasikas marked this conversation as resolved.
Show resolved Hide resolved
enabled: false,
reason: i18n.FILE_DELETE_REASON(getOwnerUIName(owner)),
},
},
};
};

Expand Down
15 changes: 15 additions & 0 deletions x-pack/plugins/cases/public/files/translations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

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

export const FILE_DELETE_REASON = (owner: string) =>
i18n.translate('xpack.cases.files.deleteReason', {
values: { owner },
defaultMessage:
'This file is managed by Cases. Navigate to the Cases page under {owner} to delete it.',
});