Skip to content

Commit

Permalink
[Cases] Disable deletion of cases files in stack mgmt. (#155683)
Browse files Browse the repository at this point in the history
## Summary

Since #155179 was merged we can
now disable the deletion of Cases files in the Files page in Stack
management.



https://user-images.githubusercontent.com/1533137/234191683-8f768520-f842-413e-b922-200d01e2df28.mov

---------

Co-authored-by: Jonathan Buttner <[email protected]>
  • Loading branch information
adcoelho and jonathan-buttner authored Apr 25, 2023
1 parent ccd9d14 commit 933bca2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pageLoadAssetSize:
banners: 17946
bfetch: 22837
canvas: 1066647
cases: 170000
cases: 175000
charts: 55000
cloud: 21076
cloudChat: 19894
Expand Down
28 changes: 27 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,42 @@

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 {
GENERAL_CASES_OWNER,
MAX_FILE_SIZE,
OBSERVABILITY_OWNER,
OWNERS,
SECURITY_SOLUTION_OWNER,
} 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 getOwnerUIName = (owner: Owner) => {
switch (owner) {
case SECURITY_SOLUTION_OWNER:
return 'Security';
case OBSERVABILITY_OWNER:
return 'Observability';
case GENERAL_CASES_OWNER:
return 'Stack Management';
default:
return owner;
}
};

const buildFileKind = (config: FilesConfig, owner: Owner): FileKindBrowser => {
return {
id: constructFileKindIdByOwner(owner),
allowedMimeTypes: config.allowedMimeTypes,
maxSizeBytes: config.maxSize ?? MAX_FILE_SIZE,
managementUiActions: {
delete: {
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.',
});

0 comments on commit 933bca2

Please sign in to comment.