-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into user-internal-repository-for-so-access
- Loading branch information
Showing
144 changed files
with
4,311 additions
and
4,479 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
x-pack/plugins/cases/public/components/user_actions/settings.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* 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 { EuiCommentList } from '@elastic/eui'; | ||
import React from 'react'; | ||
import { Actions } from '../../../common/api'; | ||
import { AppMockRenderer, createAppMockRenderer } from '../../common/mock'; | ||
import { getUserAction } from '../../containers/mock'; | ||
import { getMockBuilderArgs } from './mock'; | ||
import { createSettingsUserActionBuilder } from './settings'; | ||
|
||
jest.mock('../../common/lib/kibana'); | ||
jest.mock('../../common/navigation/hooks'); | ||
|
||
describe('createStatusUserActionBuilder ', () => { | ||
const builderArgs = getMockBuilderArgs(); | ||
let appMock: AppMockRenderer; | ||
|
||
beforeEach(() => { | ||
appMock = createAppMockRenderer(); | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
const tests = [ | ||
[false, 'disabled'], | ||
[true, 'enabled'], | ||
]; | ||
|
||
it.each(tests)( | ||
'renders correctly when changed setting sync-alerts to %s', | ||
async (syncAlerts, label) => { | ||
const userAction = getUserAction('settings', Actions.update, { | ||
payload: { settings: { syncAlerts } }, | ||
}); | ||
const builder = createSettingsUserActionBuilder({ | ||
...builderArgs, | ||
userAction, | ||
}); | ||
|
||
const createdUserAction = builder.build(); | ||
const result = appMock.render(<EuiCommentList comments={createdUserAction} />); | ||
|
||
expect(result.getByTestId('settings-update-action-settings-update')).toBeTruthy(); | ||
expect(result.getByText(`${label} sync alerts`)).toBeTruthy(); | ||
} | ||
); | ||
}); |
43 changes: 43 additions & 0 deletions
43
x-pack/plugins/cases/public/components/user_actions/settings.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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 { ReactNode } from 'react'; | ||
import { SettingsUserAction } from '../../../common/api'; | ||
import { UserActionBuilder, UserActionResponse } from './types'; | ||
|
||
import { createCommonUpdateUserActionBuilder } from './common'; | ||
import { DISABLED_SETTING, ENABLED_SETTING, SYNC_ALERTS_LC } from './translations'; | ||
|
||
function getSettingsLabel(userAction: UserActionResponse<SettingsUserAction>): ReactNode { | ||
if (userAction.payload.settings.syncAlerts) { | ||
return `${ENABLED_SETTING} ${SYNC_ALERTS_LC}`; | ||
} else { | ||
return `${DISABLED_SETTING} ${SYNC_ALERTS_LC}`; | ||
} | ||
} | ||
|
||
export const createSettingsUserActionBuilder: UserActionBuilder = ({ | ||
userAction, | ||
handleOutlineComment, | ||
}) => ({ | ||
build: () => { | ||
const action = userAction as UserActionResponse<SettingsUserAction>; | ||
if (action?.payload?.settings?.syncAlerts !== undefined) { | ||
const commonBuilder = createCommonUpdateUserActionBuilder({ | ||
userAction, | ||
handleOutlineComment, | ||
label: getSettingsLabel(action), | ||
icon: 'gear', | ||
}); | ||
|
||
return commonBuilder.build(); | ||
} | ||
|
||
// if new settings are introduced. they won't be rendered | ||
return []; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.