[Cases] Disable deletion of cases files in stack mgmt. (#155683)

## Summary

Since https://github.com/elastic/kibana/pull/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 <jonathan.buttner@elastic.co>
This commit is contained in:
Antonio 2023-04-25 22:01:55 +02:00 committed by GitHub
parent ccd9d1484b
commit 933bca2537
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 2 deletions

View file

@ -7,7 +7,7 @@ pageLoadAssetSize:
banners: 17946
bfetch: 22837
canvas: 1066647
cases: 170000
cases: 175000
charts: 55000
cloud: 21076
cloudChat: 19894

View file

@ -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)),
},
},
};
};

View file

@ -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.',
});