Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
cd8a1b0
register addToNewCase lens action
angorayc Apr 13, 2023
ea900ad
update app id
angorayc Apr 13, 2023
fe89da7
move to cases plugin
angorayc Apr 21, 2023
9ddfb2c
add cases context
angorayc Apr 21, 2023
f6c7b30
revert change
angorayc Apr 24, 2023
cebc21e
open flyout
angorayc Apr 24, 2023
16a0dc7
add to existing case
angorayc Apr 24, 2023
f381a43
add to existing case
angorayc Apr 25, 2023
2524a71
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Apr 25, 2023
c79477f
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Apr 25, 2023
202a037
Merge branch 'main' into lens-actions
cnasikas Apr 25, 2023
564709f
Use internal cases components to show the flyout
cnasikas Apr 25, 2023
1e335e2
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Apr 25, 2023
d21d00f
add to existing case
angorayc Apr 25, 2023
fc294cb
Merge branch 'lens-actions' of github.com:angorayc/kibana into lens-a…
angorayc Apr 25, 2023
43cbb98
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Apr 25, 2023
938a94e
add to existing case
angorayc Apr 26, 2023
9d495c4
Merge branch 'lens-actions' of github.com:angorayc/kibana into lens-a…
angorayc Apr 26, 2023
89e0e1d
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Apr 26, 2023
f2a1b24
update owner
angorayc Apr 26, 2023
f180907
Merge branch 'lens-actions' of github.com:angorayc/kibana into lens-a…
angorayc Apr 26, 2023
709672d
Switch to hooks
cnasikas Apr 27, 2023
a2e6c43
Pass storage to the KibanaContext
cnasikas Apr 27, 2023
dc9179e
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Apr 27, 2023
2b2d93a
Wrap actions with router
cnasikas Apr 27, 2023
60fc53e
Merge branch 'lens-actions' of github.com:angorayc/kibana into lens-a…
cnasikas Apr 27, 2023
a1c2f4c
Merge branch 'main' of github.com:elastic/kibana into lens-actions
angorayc May 22, 2023
21b0702
create cases from existing case modal
angorayc May 22, 2023
a518515
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine May 22, 2023
4566eea
unit tests
angorayc May 23, 2023
84192a4
Merge branch 'lens-actions' of github.com:angorayc/kibana into lens-a…
angorayc May 23, 2023
cda3b4e
clean up
angorayc May 23, 2023
bc5db5b
clean up
angorayc May 23, 2023
9f60eb9
Merge branch 'main' into lens-actions
angorayc May 24, 2023
dd901cb
create case
angorayc May 24, 2023
4427622
Merge branch 'lens-actions' of github.com:angorayc/kibana into lens-a…
angorayc May 24, 2023
dc5b953
fixup
angorayc May 24, 2023
8e201dc
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine May 24, 2023
dd908a8
fixup
angorayc May 24, 2023
4b84fde
Merge branch 'lens-actions' of github.com:angorayc/kibana into lens-a…
angorayc May 24, 2023
0a25f2a
fixup
angorayc May 24, 2023
9e5dc76
fixup
angorayc May 24, 2023
1a211ca
fix add to existing case twitch
angorayc May 25, 2023
c3694df
unit tests
angorayc May 25, 2023
8f66588
unit tests
angorayc May 25, 2023
e15d635
Fix issue with owner
cnasikas May 29, 2023
bfa8c6d
Merge branch 'main' into lens-actions
cnasikas May 29, 2023
876cc23
review
angorayc May 30, 2023
e9fbd42
Increase limits
cnasikas Jun 1, 2023
4e6dd86
Fix issue with permissions
cnasikas Jun 1, 2023
e1e671c
add unit tests and fix create case from cases page
angorayc Jun 1, 2023
b870216
Merge branch 'main' into lens-actions
angorayc Jun 1, 2023
f7fb35f
Merge branch 'main' into lens-actions
cnasikas Jun 2, 2023
4f5290d
Use dark mode from user profile
cnasikas Jun 2, 2023
a40a244
Merge branch 'lens-actions' of github.com:angorayc/kibana into lens-a…
cnasikas Jun 2, 2023
0a66940
Add tests
cnasikas Jun 2, 2023
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
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: 175000
cases: 180000
Copy link
Copy Markdown
Member

@cnasikas cnasikas Jun 1, 2023

Choose a reason for hiding this comment

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

I could not find a way to reduce the bundle size. The imports from @kbn/embeddable-plugin/public and @kbn/ui-actions-plugin/public increased it. I tried to import only what we need by setting the path of the import to the folder we need but I got this error

Module not found: Error: import [@kbn/embeddable-plugin/public/lib/embeddables/error_embeddable references a non-public export of the [embeddable] bundle and must point to one of the public directories: [public,common].

This PR #157492 will reduce the limit substantially.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Works for me. Thanks for looking into it.

charts: 55000
cloud: 21076
cloudChat: 19894
Expand Down
28 changes: 21 additions & 7 deletions x-pack/plugins/cases/common/utils/owner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,30 @@
*/

import { OWNER_INFO } from '../constants';
import { isValidOwner } from './owner';
import { getCaseOwnerByAppId, isValidOwner } from './owner';

describe('isValidOwner', () => {
const owners = Object.keys(OWNER_INFO) as Array<keyof typeof OWNER_INFO>;
describe('owner utils', () => {
describe('isValidOwner', () => {
const owners = Object.keys(OWNER_INFO) as Array<keyof typeof OWNER_INFO>;

it.each(owners)('returns true for valid owner: %s', (owner) => {
expect(isValidOwner(owner)).toBe(true);
it.each(owners)('returns true for valid owner: %s', (owner) => {
expect(isValidOwner(owner)).toBe(true);
});

it('return false for invalid owner', () => {
expect(isValidOwner('not-valid')).toBe(false);
});
});

it('return false for invalid owner', () => {
expect(isValidOwner('not-valid')).toBe(false);
describe('getCaseOwnerByAppId', () => {
const tests = Object.values(OWNER_INFO).map((info) => [info.id, info.appId]);

it.each(tests)('for owner %s it returns %s', (owner, appId) => {
expect(getCaseOwnerByAppId(appId)).toBe(owner);
});

it('return undefined for invalid application ID', () => {
expect(getCaseOwnerByAppId('not-valid')).toBe(undefined);
});
});
});
3 changes: 3 additions & 0 deletions x-pack/plugins/cases/common/utils/owner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ import { OWNER_INFO } from '../constants';

export const isValidOwner = (owner: string): owner is keyof typeof OWNER_INFO =>
Object.keys(OWNER_INFO).includes(owner);

export const getCaseOwnerByAppId = (currentAppId?: string) =>
Object.values(OWNER_INFO).find((info) => info.appId === currentAppId)?.id;
3 changes: 2 additions & 1 deletion x-pack/plugins/cases/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"ruleRegistry",
"files",
"savedObjectsFinder",
"savedObjectsManagement"
"savedObjectsManagement",
"uiActions",
],
"optionalPlugins": [
"home",
Expand Down
8 changes: 5 additions & 3 deletions x-pack/plugins/cases/public/common/lib/kibana/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@
import type { CoreStart } from '@kbn/core/public';
import type { CasesUiConfigType } from '../../../../common/ui/types';

type GlobalServices = Pick<CoreStart, 'http'>;
type GlobalServices = Pick<CoreStart, 'application' | 'http' | 'theme'>;

export class KibanaServices {
private static kibanaVersion?: string;
private static services?: GlobalServices;
private static config?: CasesUiConfigType;

public static init({
application,
config,
http,
kibanaVersion,
config,
theme,
}: GlobalServices & {
kibanaVersion: string;
config: CasesUiConfigType;
}) {
this.services = { http };
this.services = { application, http, theme };
this.kibanaVersion = kibanaVersion;
this.config = config;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const useKibanaMock = useKibana as jest.MockedFunction<typeof useKibana>;
const useGetConnectorsMock = useGetSupportedActionConnectors as jest.Mock;
const useUpdateCaseMock = useUpdateCase as jest.Mock;
const useLicenseMock = useLicense as jest.Mock;

const mockTriggersActionsUiService = triggersActionsUiMock.createStart();

const mockKibana = () => {
Expand Down Expand Up @@ -165,7 +164,6 @@ describe('AllCasesListGeneric', () => {

it('should render AllCasesList', async () => {
useLicenseMock.mockReturnValue({ isAtLeastPlatinum: () => true });

appMockRenderer.render(<AllCasesList />);

await waitFor(() => {
Expand Down Expand Up @@ -260,6 +258,21 @@ describe('AllCasesListGeneric', () => {
});
});

it('should not call onCreateCasePressed if onRowClick is not provided when create case from case page', async () => {
useGetCasesMock.mockReturnValue({
...defaultGetCases,
data: {
...defaultGetCases.data,
cases: [],
},
});
appMockRenderer.render(<AllCasesList isSelectorView={false} />);
userEvent.click(screen.getByTestId('cases-table-add-case'));
await waitFor(() => {
expect(onRowClick).not.toHaveBeenCalled();
});
});

it('should tableHeaderSortButton AllCasesList', async () => {
appMockRenderer.render(<AllCasesList />);

Expand Down Expand Up @@ -347,9 +360,10 @@ describe('AllCasesListGeneric', () => {
it('should call onRowClick with no cases and isSelectorView=true when create case is clicked', async () => {
appMockRenderer.render(<AllCasesList isSelectorView={true} onRowClick={onRowClick} />);
userEvent.click(screen.getByTestId('cases-table-add-case-filter-bar'));

const isCreateCase = true;
await waitFor(() => {
expect(onRowClick).toHaveBeenCalled();
expect(onRowClick).toBeCalledWith(undefined, isCreateCase);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const mapToReadableSolutionName = (solution: string): Solution => {
export interface AllCasesListProps {
hiddenStatuses?: CaseStatusWithAllStatus[];
isSelectorView?: boolean;
onRowClick?: (theCase?: CaseUI) => void;
onRowClick?: (theCase?: CaseUI, isCreateCase?: boolean) => void;
}

export const AllCasesList = React.memo<AllCasesListProps>(
Expand Down Expand Up @@ -250,6 +250,10 @@ export const AllCasesList = React.memo<AllCasesListProps>(
mapToReadableSolutionName(solution)
);

const onCreateCasePressed = useCallback(() => {
onRowClick?.(undefined, true);
}, [onRowClick]);

return (
<>
<ProgressLoader
Expand All @@ -276,15 +280,15 @@ export const AllCasesList = React.memo<AllCasesListProps>(
severity: filterOptions.severity,
}}
hiddenStatuses={hiddenStatuses}
onCreateCasePressed={onRowClick}
onCreateCasePressed={onCreateCasePressed}
isSelectorView={isSelectorView}
isLoading={isLoadingCurrentUserProfile}
currentUserProfile={currentUserProfile}
/>
<CasesTable
columns={columns}
data={data}
goToCreateCase={onRowClick}
goToCreateCase={onRowClick ? onCreateCasePressed : undefined}
isCasesLoading={isLoadingCases}
isCommentUpdating={isLoadingCases}
isDataEmpty={isDataEmpty}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import { AllCasesList } from '../all_cases_list';
export interface AllCasesSelectorModalProps {
hiddenStatuses?: CaseStatusWithAllStatus[];
onRowClick?: (theCase?: CaseUI) => void;
onClose?: () => void;
onClose?: (theCase?: CaseUI, isCreateCase?: boolean) => void;
onCreateCaseClicked?: () => void;
}

const Modal = styled(EuiModal)`
Expand All @@ -37,20 +38,18 @@ export const AllCasesSelectorModal = React.memo<AllCasesSelectorModalProps>(
({ hiddenStatuses, onRowClick, onClose }) => {
const [isModalOpen, setIsModalOpen] = useState<boolean>(true);
const closeModal = useCallback(() => {
if (onClose) {
onClose();
}
onClose?.();
setIsModalOpen(false);
}, [onClose]);

const onClick = useCallback(
(theCase?: CaseUI) => {
closeModal();
if (onRowClick) {
onRowClick(theCase);
}
(theCase?: CaseUI, isCreateCase?: boolean) => {
onClose?.(theCase, isCreateCase);
setIsModalOpen(false);

onRowClick?.(theCase);
},
[closeModal, onRowClick]
[onClose, onRowClick]
);

return isModalOpen ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ export const useCasesAddToExistingCaseModal = (props: AddToExistingCaseModalProp
}
},
[
props,
appId,
casesToasts,
closeModal,
createAttachments,
createNewCaseFlyout,
props,
startTransaction,
appId,
createAttachments,
casesToasts,
]
);

Expand All @@ -130,11 +130,11 @@ export const useCasesAddToExistingCaseModal = (props: AddToExistingCaseModalProp
onRowClick: (theCase?: CaseUI) => {
handleOnRowClick(theCase, getAttachments);
},
onClose: () => {
onClose: (theCase?: CaseUI, isCreateCase?: boolean) => {
closeModal();

if (props.onClose) {
return props.onClose();
return props.onClose(theCase, isCreateCase);
}
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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 React from 'react';

export const ActionWrapper = jest
.fn()
.mockImplementation(({ children }) => <div data-test-subj="action-wrapper">{children}</div>);
Loading