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

[ResponseOps][Cases] User assignment #140208

Merged
merged 24 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
504bac6
[ResponseOps][Cases] Assign users on cases sidebar section (#138108)
cnasikas Aug 24, 2022
939f52b
Merge branch 'main' of github.com:elastic/kibana into cases-user-assi…
jonathan-buttner Aug 31, 2022
72d0ee9
[ResponseOps][Cases] Add assignee user actions (#139392)
jonathan-buttner Aug 31, 2022
15f2279
Merge branch 'main' of github.com:elastic/kibana into cases-user-assi…
jonathan-buttner Sep 1, 2022
1c4942f
Merge branch 'cases-user-assignment' of github.com:elastic/kibana int…
jonathan-buttner Sep 1, 2022
622fbdc
Merge branch 'main' of github.com:elastic/kibana into cases-user-assi…
jonathan-buttner Sep 2, 2022
0657743
Merge branch 'main' into cases-user-assignment
cnasikas Sep 6, 2022
301770e
Detect when user is typing
cnasikas Sep 6, 2022
8103bd3
Use select to tranform data
cnasikas Sep 6, 2022
01006bf
[Cases] Assign users when creating a case (#139754)
cnasikas Sep 6, 2022
8251340
[ResponseOps][Cases] Filter by assignees (#139441)
jonathan-buttner Sep 7, 2022
41a44c6
Merge branch 'main' of github.com:elastic/kibana into cases-user-assi…
jonathan-buttner Sep 7, 2022
da1b4a8
Fixing type error
jonathan-buttner Sep 7, 2022
80f847f
Fixing tests
jonathan-buttner Sep 7, 2022
729f072
Sort users and improve loading
cnasikas Sep 8, 2022
57beeef
Fix ml security dependecies
cnasikas Sep 8, 2022
76cb3ab
Fix permissions when fetching suggestions
cnasikas Sep 8, 2022
49f2a54
Merge branch 'main' into cases-user-assignment
kibanamachine Sep 8, 2022
6b24a17
Fixing read permissions and suggest api
jonathan-buttner Sep 8, 2022
d85963e
Hiding assignee delete icon
jonathan-buttner Sep 8, 2022
63ca0a7
Hiding the assign yourself text when undefined
jonathan-buttner Sep 8, 2022
854523f
Merge branch 'main' into cases-user-assignment
kibanamachine Sep 9, 2022
45829cd
Merge branch 'main' into cases-user-assignment
kibanamachine Sep 12, 2022
50e417a
Create page fixes
cnasikas Sep 12, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

import { shallow } from 'enzyme';
import React from 'react';
import { UserProfile } from './user_profile';

import { UserProfilesPopover } from './user_profiles_popover';

const userProfiles = [
const userProfiles: UserProfile[] = [
{
uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0',
enabled: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

import { mount } from 'enzyme';
import React from 'react';
import { UserProfile } from './user_profile';

import { UserProfilesSelectable } from './user_profiles_selectable';

const userProfiles = [
const userProfiles: UserProfile[] = [
{
uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0',
enabled: true,
Expand Down
18 changes: 0 additions & 18 deletions x-pack/plugins/cases/common/api/cases/suggest_user_profiles.ts

This file was deleted.

13 changes: 8 additions & 5 deletions x-pack/plugins/cases/common/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@

import * as rt from 'io-ts';

export const UserRT = rt.type({
email: rt.union([rt.undefined, rt.null, rt.string]),
full_name: rt.union([rt.undefined, rt.null, rt.string]),
username: rt.union([rt.undefined, rt.null, rt.string]),
});
export const UserRT = rt.intersection([
rt.type({
email: rt.union([rt.undefined, rt.null, rt.string]),
full_name: rt.union([rt.undefined, rt.null, rt.string]),
username: rt.union([rt.undefined, rt.null, rt.string]),
}),
rt.partial({ profile_uid: rt.string }),
]);

export const UsersRt = rt.array(UserRT);

Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/cases/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,8 @@ export const PUSH_CASES_CAPABILITY = 'push_cases' as const;
*/

export const DEFAULT_USER_SIZE = 10;

/**
* Delays
*/
export const SEARCH_DEBOUNCE_MS = 500;
3 changes: 2 additions & 1 deletion x-pack/plugins/cases/common/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export interface FilterOptions {
severity: CaseSeverityWithAll;
status: CaseStatusWithAllStatus;
tags: string[];
assignees: string[];
reporters: User[];
owner: string[];
}
Expand Down Expand Up @@ -162,7 +163,7 @@ export interface FieldMappings {

export type UpdateKey = keyof Pick<
CasePatchRequest,
'connector' | 'description' | 'status' | 'tags' | 'title' | 'settings' | 'severity'
'connector' | 'description' | 'status' | 'tags' | 'title' | 'settings' | 'severity' | 'assignees'
>;

export interface UpdateByKey {
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/cases/public/common/mock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
*/

export * from './test_providers';
export * from './permissions';
69 changes: 69 additions & 0 deletions x-pack/plugins/cases/public/common/mock/permissions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* 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 { CasesCapabilities, CasesPermissions } from '../../containers/types';

export const allCasesPermissions = () => buildCasesPermissions();
export const noCasesPermissions = () =>
buildCasesPermissions({ read: false, create: false, update: false, delete: false, push: false });
export const readCasesPermissions = () =>
buildCasesPermissions({ read: true, create: false, update: false, delete: false, push: false });
export const noCreateCasesPermissions = () => buildCasesPermissions({ create: false });
export const noUpdateCasesPermissions = () => buildCasesPermissions({ update: false });
export const noPushCasesPermissions = () => buildCasesPermissions({ push: false });
export const noDeleteCasesPermissions = () => buildCasesPermissions({ delete: false });
export const writeCasesPermissions = () => buildCasesPermissions({ read: false });

export const buildCasesPermissions = (overrides: Partial<Omit<CasesPermissions, 'all'>> = {}) => {
const create = overrides.create ?? true;
const read = overrides.read ?? true;
const update = overrides.update ?? true;
const deletePermissions = overrides.delete ?? true;
const push = overrides.push ?? true;
const all = create && read && update && deletePermissions && push;

return {
all,
create,
read,
update,
delete: deletePermissions,
push,
};
};

export const allCasesCapabilities = () => buildCasesCapabilities();
export const noCasesCapabilities = () =>
buildCasesCapabilities({
create_cases: false,
read_cases: false,
update_cases: false,
delete_cases: false,
push_cases: false,
});
export const readCasesCapabilities = () =>
buildCasesCapabilities({
create_cases: false,
update_cases: false,
delete_cases: false,
push_cases: false,
});
export const writeCasesCapabilities = () => {
return buildCasesCapabilities({
read_cases: false,
});
};

export const buildCasesCapabilities = (overrides?: Partial<CasesCapabilities>) => {
return {
create_cases: overrides?.create_cases ?? true,
read_cases: overrides?.read_cases ?? true,
update_cases: overrides?.update_cases ?? true,
delete_cases: overrides?.delete_cases ?? true,
push_cases: overrides?.push_cases ?? true,
};
};
85 changes: 23 additions & 62 deletions x-pack/plugins/cases/public/common/mock/test_providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* 2.0.
*/

/* eslint-disable no-console */

import React from 'react';
import { euiDarkVars } from '@kbn/ui-theme';
import { I18nProvider } from '@kbn/i18n-react';
Expand All @@ -14,7 +16,7 @@ import { render as reactRender, RenderOptions, RenderResult } from '@testing-lib
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { SECURITY_SOLUTION_OWNER } from '../../../common/constants';
import { CasesCapabilities, CasesFeatures, CasesPermissions } from '../../../common/ui/types';
import { CasesFeatures, CasesPermissions } from '../../../common/ui/types';
import { CasesProvider } from '../../components/cases_context';
import {
createKibanaContextProviderMock,
Expand All @@ -25,6 +27,7 @@ import { StartServices } from '../../types';
import { ReleasePhase } from '../../components/types';
import { ExternalReferenceAttachmentTypeRegistry } from '../../client/attachment_framework/external_reference_registry';
import { PersistableStateAttachmentTypeRegistry } from '../../client/attachment_framework/persistable_state_registry';
import { allCasesPermissions } from './permissions';

interface TestProviderProps {
children: React.ReactNode;
Expand Down Expand Up @@ -56,6 +59,11 @@ const TestProvidersComponent: React.FC<TestProviderProps> = ({
retry: false,
},
},
logger: {
log: console.log,
warn: console.warn,
error: () => {},
},
});

return (
Expand Down Expand Up @@ -98,69 +106,17 @@ export const testQueryClient = new QueryClient({
retry: false,
},
},
/**
* React query prints the errors in the console even though
* all tests are passings. We turn them off for testing.
*/
logger: {
log: console.log,
warn: console.warn,
error: () => {},
},
});

export const allCasesPermissions = () => buildCasesPermissions();
export const noCasesPermissions = () =>
buildCasesPermissions({ read: false, create: false, update: false, delete: false, push: false });
export const readCasesPermissions = () =>
buildCasesPermissions({ read: true, create: false, update: false, delete: false, push: false });
export const noCreateCasesPermissions = () => buildCasesPermissions({ create: false });
export const noUpdateCasesPermissions = () => buildCasesPermissions({ update: false });
export const noPushCasesPermissions = () => buildCasesPermissions({ push: false });
export const noDeleteCasesPermissions = () => buildCasesPermissions({ delete: false });
export const writeCasesPermissions = () => buildCasesPermissions({ read: false });

export const buildCasesPermissions = (overrides: Partial<Omit<CasesPermissions, 'all'>> = {}) => {
const create = overrides.create ?? true;
const read = overrides.read ?? true;
const update = overrides.update ?? true;
const deletePermissions = overrides.delete ?? true;
const push = overrides.push ?? true;
const all = create && read && update && deletePermissions && push;

return {
all,
create,
read,
update,
delete: deletePermissions,
push,
};
};

export const allCasesCapabilities = () => buildCasesCapabilities();
export const noCasesCapabilities = () =>
buildCasesCapabilities({
create_cases: false,
read_cases: false,
update_cases: false,
delete_cases: false,
push_cases: false,
});
export const readCasesCapabilities = () =>
buildCasesCapabilities({
create_cases: false,
update_cases: false,
delete_cases: false,
push_cases: false,
});
export const writeCasesCapabilities = () => {
return buildCasesCapabilities({
read_cases: false,
});
};

export const buildCasesCapabilities = (overrides?: Partial<CasesCapabilities>) => {
return {
create_cases: overrides?.create_cases ?? true,
read_cases: overrides?.read_cases ?? true,
update_cases: overrides?.update_cases ?? true,
delete_cases: overrides?.delete_cases ?? true,
push_cases: overrides?.push_cases ?? true,
};
};

export const createAppMockRenderer = ({
features,
owner = [SECURITY_SOLUTION_OWNER],
Expand All @@ -176,6 +132,11 @@ export const createAppMockRenderer = ({
retry: false,
},
},
logger: {
log: console.log,
warn: console.warn,
error: () => {},
},
});

const AppWrapper: React.FC<{ children: React.ReactElement }> = ({ children }) => (
Expand Down
Loading