Skip to content

Commit

Permalink
finish responding to PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelolo24 committed Oct 11, 2024
1 parent 8ec412d commit bff940f
Show file tree
Hide file tree
Showing 41 changed files with 299 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import type { CasesFeatureParams } from './types';
export const getCasesBaseKibanaSubFeatureIds = (): CasesSubFeatureId[] => [
CasesSubFeatureId.deleteCases,
CasesSubFeatureId.casesSettings,
CasesSubFeatureId.addComment,
CasesSubFeatureId.reopenCases,
CasesSubFeatureId.createComment,
CasesSubFeatureId.reopenCase,
];

/**
Expand Down Expand Up @@ -131,9 +131,9 @@ export const getCasesSubFeaturesMap = ({
},
],
};
const casesReopenCasesSubFeature: SubFeatureConfig = {
const casesreopenCaseubFeature: SubFeatureConfig = {
name: i18n.translate(
'securitySolutionPackages.features.featureRegistry.reopenCasesSubFeatureName',
'securitySolutionPackages.features.featureRegistry.reopenCaseubFeatureName',
{
defaultMessage: 'Reopen Closed Cases',
}
Expand All @@ -144,9 +144,9 @@ export const getCasesSubFeaturesMap = ({
privileges: [
{
api: apiTags.all,
id: 'reopen_cases',
id: 'case_reopen',
name: i18n.translate(
'securitySolutionPackages.features.featureRegistry.reopenCasesSubFeatureDetails',
'securitySolutionPackages.features.featureRegistry.reopenCaseubFeatureDetails',
{
defaultMessage: 'Reopen closed cases',
}
Expand All @@ -157,9 +157,9 @@ export const getCasesSubFeaturesMap = ({
read: [],
},
cases: {
reopenCases: [APP_ID],
reopenCase: [APP_ID],
},
ui: uiCapabilities.reopenCases,
ui: uiCapabilities.reopenCase,
},
],
},
Expand All @@ -169,7 +169,7 @@ export const getCasesSubFeaturesMap = ({
return new Map<CasesSubFeatureId, SubFeatureConfig>([
[CasesSubFeatureId.deleteCases, deleteCasesSubFeature],
[CasesSubFeatureId.casesSettings, casesSettingsCasesSubFeature],
[CasesSubFeatureId.addComment, casesAddCommentsCasesSubFeature],
[CasesSubFeatureId.reopenCases, casesReopenCasesSubFeature],
[CasesSubFeatureId.createComment, casesAddCommentsCasesSubFeature],
[CasesSubFeatureId.reopenCase, casesreopenCaseubFeature],
]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ export enum SecuritySubFeatureId {
export enum CasesSubFeatureId {
deleteCases = 'deleteCasesSubFeature',
casesSettings = 'casesSettingsSubFeature',
addComment = 'addCommentSubFeature',
reopenCases = 'reopenCasesSubFeature',
createComment = 'createCommentSubFeature',
reopenCase = 'reopenCaseubFeature',
}

/** Sub-features IDs for Security Assistant */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type CasesSupportedOperations = (typeof allOperations)[number];
*/

const pushOperations = ['pushCase'] as const;
const createOperations = ['createCase', 'createComment'] as const;
const createOperations = ['createCase'] as const;
const readOperations = [
'getCase',
'getComment',
Expand All @@ -31,11 +31,12 @@ const readOperations = [
'getUserActions',
'findConfigurations',
] as const;
// Update operations do not currently include the ability to re-open a case
const updateOperations = ['updateCase', 'updateComment'] as const;
const deleteOperations = ['deleteCase', 'deleteComment'] as const;
const settingsOperations = ['createConfiguration', 'updateConfiguration'] as const;
const createCommentOperations = ['createComment'] as const;
const reopenOperations = ['reopenCases'] as const;
const reopenOperations = ['reopenCase'] as const;
const allOperations = [
...pushOperations,
...createOperations,
Expand Down Expand Up @@ -69,7 +70,7 @@ export class FeaturePrivilegeCasesBuilder extends BaseFeaturePrivilegeBuilder {
...getCasesPrivilege(deleteOperations, privilegeDefinition.cases?.delete),
...getCasesPrivilege(settingsOperations, privilegeDefinition.cases?.settings),
...getCasesPrivilege(createCommentOperations, privilegeDefinition.cases?.createComment),
...getCasesPrivilege(reopenOperations, privilegeDefinition.cases?.reopenCases),
...getCasesPrivilege(reopenOperations, privilegeDefinition.cases?.reopenCase),
]);
}
}
2 changes: 1 addition & 1 deletion x-pack/plugins/cases/common/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export const DELETE_CASES_CAPABILITY = 'delete_cases' as const;
export const PUSH_CASES_CAPABILITY = 'push_cases' as const;
export const CASES_SETTINGS_CAPABILITY = 'cases_settings' as const;
export const CASES_CONNECTORS_CAPABILITY = 'cases_connectors' as const;
export const REOPEN_CASES_CAPABILITY = 'reopen_cases' as const;
export const CASES_REOPEN_CAPABILITY = 'case_reopen' as const;
export const CREATE_COMMENT_CAPABILITY = 'create_comment' as const;

/**
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/cases/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export {
GET_CONNECTORS_CONFIGURE_API_TAG,
CASES_SETTINGS_CAPABILITY,
CREATE_COMMENT_CAPABILITY,
REOPEN_CASES_CAPABILITY,
CASES_REOPEN_CAPABILITY,
} from './constants';

export type { AttachmentAttributes } from './types/domain';
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/cases/common/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
READ_CASES_CAPABILITY,
UPDATE_CASES_CAPABILITY,
CREATE_COMMENT_CAPABILITY,
REOPEN_CASES_CAPABILITY,
CASES_REOPEN_CAPABILITY,
} from '..';
import type {
CASES_CONNECTORS_CAPABILITY,
Expand Down Expand Up @@ -307,7 +307,7 @@ export interface CasesPermissions {
push: boolean;
connectors: boolean;
settings: boolean;
reopenCases: boolean;
reopenCase: boolean;
createComment: boolean;
}

Expand All @@ -320,5 +320,5 @@ export interface CasesCapabilities {
[CASES_CONNECTORS_CAPABILITY]: boolean;
[CASES_SETTINGS_CAPABILITY]: boolean;
[CREATE_COMMENT_CAPABILITY]: boolean;
[REOPEN_CASES_CAPABILITY]: boolean;
[CASES_REOPEN_CAPABILITY]: boolean;
}
4 changes: 2 additions & 2 deletions x-pack/plugins/cases/common/utils/capabilities.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ describe('createUICapabilities', () => {
"read_cases",
"cases_connectors",
],
"reopenCases": Array [
"reopen_cases",
"reopenCase": Array [
"case_reopen",
],
"settings": Array [
"cases_settings",
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/cases/common/utils/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
READ_CASES_CAPABILITY,
UPDATE_CASES_CAPABILITY,
CASES_SETTINGS_CAPABILITY,
REOPEN_CASES_CAPABILITY,
CASES_REOPEN_CAPABILITY,
CREATE_COMMENT_CAPABILITY,
} from '../constants';

Expand All @@ -22,7 +22,7 @@ export interface CasesUiCapabilities {
read: readonly string[];
delete: readonly string[];
settings: readonly string[];
reopenCases: readonly string[];
reopenCase: readonly string[];
createComment: readonly string[];
}
/**
Expand All @@ -40,6 +40,6 @@ export const createUICapabilities = (): CasesUiCapabilities => ({
read: [READ_CASES_CAPABILITY, CASES_CONNECTORS_CAPABILITY] as const,
delete: [DELETE_CASES_CAPABILITY] as const,
settings: [CASES_SETTINGS_CAPABILITY] as const,
reopenCases: [REOPEN_CASES_CAPABILITY] as const,
reopenCase: [CASES_REOPEN_CAPABILITY] as const,
createComment: [CREATE_COMMENT_CAPABILITY] as const,
});
6 changes: 3 additions & 3 deletions x-pack/plugins/cases/public/client/helpers/can_use_cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const canUseCases =
acc.push = acc.push || userCapabilitiesForOwner.push;
acc.connectors = acc.connectors || userCapabilitiesForOwner.connectors;
acc.settings = acc.settings || userCapabilitiesForOwner.settings;
acc.reopenCases = acc.reopenCases || userCapabilitiesForOwner.reopenCases;
acc.reopenCase = acc.reopenCase || userCapabilitiesForOwner.reopenCase;
acc.createComment = acc.createComment || userCapabilitiesForOwner.createComment;

const allFromAcc =
Expand All @@ -53,7 +53,7 @@ export const canUseCases =
acc.push &&
acc.connectors &&
acc.settings &&
acc.reopenCases &&
acc.reopenCase &&
acc.createComment;

acc.all = acc.all || userCapabilitiesForOwner.all || allFromAcc;
Expand All @@ -69,7 +69,7 @@ export const canUseCases =
push: false,
connectors: false,
settings: false,
reopenCases: false,
reopenCase: false,
createComment: false,
}
);
Expand Down
18 changes: 9 additions & 9 deletions x-pack/plugins/cases/public/client/helpers/capabilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('getUICapabilities', () => {
"delete": false,
"push": false,
"read": false,
"reopenCases": false,
"reopenCase": false,
"settings": false,
"update": false,
}
Expand All @@ -35,7 +35,7 @@ describe('getUICapabilities', () => {
"delete": false,
"push": false,
"read": false,
"reopenCases": false,
"reopenCase": false,
"settings": false,
"update": false,
}
Expand All @@ -52,7 +52,7 @@ describe('getUICapabilities', () => {
"delete": false,
"push": false,
"read": false,
"reopenCases": false,
"reopenCase": false,
"settings": false,
"update": false,
}
Expand All @@ -78,7 +78,7 @@ describe('getUICapabilities', () => {
"delete": false,
"push": false,
"read": false,
"reopenCases": false,
"reopenCase": false,
"settings": false,
"update": false,
}
Expand All @@ -95,7 +95,7 @@ describe('getUICapabilities', () => {
"delete": false,
"push": false,
"read": false,
"reopenCases": false,
"reopenCase": false,
"settings": false,
"update": false,
}
Expand All @@ -121,7 +121,7 @@ describe('getUICapabilities', () => {
"delete": true,
"push": true,
"read": true,
"reopenCases": false,
"reopenCase": false,
"settings": false,
"update": true,
}
Expand All @@ -148,7 +148,7 @@ describe('getUICapabilities', () => {
"delete": true,
"push": true,
"read": true,
"reopenCases": false,
"reopenCase": false,
"settings": true,
"update": true,
}
Expand All @@ -175,7 +175,7 @@ describe('getUICapabilities', () => {
"delete": true,
"push": true,
"read": true,
"reopenCases": false,
"reopenCase": false,
"settings": false,
"update": true,
}
Expand All @@ -192,7 +192,7 @@ describe('getUICapabilities', () => {
"delete": false,
"push": false,
"read": false,
"reopenCases": false,
"reopenCase": false,
"settings": true,
"update": false,
}
Expand Down
8 changes: 4 additions & 4 deletions x-pack/plugins/cases/public/client/helpers/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
PUSH_CASES_CAPABILITY,
READ_CASES_CAPABILITY,
UPDATE_CASES_CAPABILITY,
REOPEN_CASES_CAPABILITY,
CASES_REOPEN_CAPABILITY,
CREATE_COMMENT_CAPABILITY,
} from '../../../common/constants';

Expand All @@ -28,7 +28,7 @@ export const getUICapabilities = (
const push = !!featureCapabilities?.[PUSH_CASES_CAPABILITY];
const connectors = !!featureCapabilities?.[CASES_CONNECTORS_CAPABILITY];
const settings = !!featureCapabilities?.[CASES_SETTINGS_CAPABILITY];
const reopenCases = !!featureCapabilities?.[REOPEN_CASES_CAPABILITY];
const reopenCase = !!featureCapabilities?.[CASES_REOPEN_CAPABILITY];
const createComment = !!featureCapabilities?.[CREATE_COMMENT_CAPABILITY];

const all =
Expand All @@ -39,7 +39,7 @@ export const getUICapabilities = (
push &&
connectors &&
settings &&
reopenCases &&
reopenCase &&
createComment;

return {
Expand All @@ -51,7 +51,7 @@ export const getUICapabilities = (
push,
connectors,
settings,
reopenCases,
reopenCase,
createComment,
};
};
4 changes: 2 additions & 2 deletions x-pack/plugins/cases/public/common/lib/kibana/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export const useApplicationCapabilities = (): UseApplicationCapabilities => {
push: permissions.push,
connectors: permissions.connectors,
settings: permissions.settings,
reopenCases: permissions.reopenCases,
reopenCase: permissions.reopenCase,
createComment: permissions.createComment,
},
visualize: { crud: !!capabilities.visualize?.save, read: !!capabilities.visualize?.show },
Expand All @@ -217,7 +217,7 @@ export const useApplicationCapabilities = (): UseApplicationCapabilities => {
permissions.push,
permissions.connectors,
permissions.settings,
permissions.reopenCases,
permissions.reopenCase,
permissions.createComment,
]
);
Expand Down
Loading

0 comments on commit bff940f

Please sign in to comment.