-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[ML] Transforms/DFA: Refactor list action buttons so modals won't unmount after button click. #70555
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
Merged
Merged
[ML] Transforms/DFA: Refactor list action buttons so modals won't unmount after button click. #70555
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
00d2955
[ML] Refactor list action buttons so modals won't unmount after butto…
walterra 001fafd
[ML] Update tests.
walterra 1b72310
[ML] Rename hook files.
walterra bb91e7d
[ML] Updated file structure.
walterra 996e151
[ML] Refactor analytics list actions.
walterra f4186e7
[ML] Text tweak.
walterra 4382fee
[ML] Simplify props.
walterra 0d299e9
Merge branch 'master' into ml-fix-list-action-buttons
walterra e47755b
[ML] Fix imports and types.
walterra c681bfe
Merge branch 'master' into ml-fix-list-action-buttons
walterra d7cf579
[ML] Update tests to reflect new required component structure.
walterra 13954f7
Merge branch 'master' into ml-fix-list-action-buttons
walterra 1c42f67
[ML] Update tests to reflect new required component structure.
walterra 5de8ec3
[ML] Fix transform edit button setup.
walterra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
12 changes: 12 additions & 0 deletions
12
...lication/data_frame_analytics/pages/analytics_management/components/action_clone/index.ts
This file contains hidden or 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,12 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| export { | ||
| extractCloningConfig, | ||
| isAdvancedConfig, | ||
| CloneButton, | ||
| CloneDataFrameAnalyticsConfig, | ||
| } from './clone_button'; |
This file contains hidden or 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
64 changes: 64 additions & 0 deletions
64
...ata_frame_analytics/pages/analytics_management/components/action_delete/delete_button.tsx
This file contains hidden or 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,64 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import React, { FC } from 'react'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { EuiIcon, EuiLink, EuiToolTip } from '@elastic/eui'; | ||
| import { | ||
| checkPermission, | ||
| createPermissionFailureMessage, | ||
| } from '../../../../../capabilities/check_capabilities'; | ||
| import { isDataFrameAnalyticsRunning, DataFrameAnalyticsListRow } from '../analytics_list/common'; | ||
|
|
||
| interface DeleteButtonProps { | ||
| item: DataFrameAnalyticsListRow; | ||
| onClick: (item: DataFrameAnalyticsListRow) => void; | ||
| } | ||
|
|
||
| export const DeleteButton: FC<DeleteButtonProps> = ({ item, onClick }) => { | ||
| const disabled = isDataFrameAnalyticsRunning(item.stats.state); | ||
| const canDeleteDataFrameAnalytics: boolean = checkPermission('canDeleteDataFrameAnalytics'); | ||
|
|
||
| const buttonDeleteText = i18n.translate('xpack.ml.dataframe.analyticsList.deleteActionName', { | ||
| defaultMessage: 'Delete', | ||
| }); | ||
|
|
||
| const buttonDisabled = disabled || !canDeleteDataFrameAnalytics; | ||
| let deleteButton = ( | ||
| <EuiLink | ||
| data-test-subj="mlAnalyticsJobDeleteButton" | ||
| color={buttonDisabled ? 'subdued' : 'text'} | ||
| disabled={buttonDisabled} | ||
| onClick={buttonDisabled ? undefined : () => onClick(item)} | ||
| aria-label={buttonDeleteText} | ||
| style={{ padding: 0 }} | ||
| > | ||
| <EuiIcon type="trash" /> {buttonDeleteText} | ||
| </EuiLink> | ||
| ); | ||
|
|
||
| if (disabled || !canDeleteDataFrameAnalytics) { | ||
| deleteButton = ( | ||
| <EuiToolTip | ||
| position="top" | ||
| content={ | ||
| disabled | ||
| ? i18n.translate( | ||
| 'xpack.ml.dataframe.analyticsList.deleteActionDisabledToolTipContent', | ||
| { | ||
| defaultMessage: 'Stop the data frame analytics job in order to delete it.', | ||
| } | ||
| ) | ||
| : createPermissionFailureMessage('canStartStopDataFrameAnalytics') | ||
| } | ||
| > | ||
| {deleteButton} | ||
| </EuiToolTip> | ||
| ); | ||
| } | ||
|
|
||
| return deleteButton; | ||
| }; |
108 changes: 108 additions & 0 deletions
108
...ame_analytics/pages/analytics_management/components/action_delete/delete_button_modal.tsx
This file contains hidden or 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,108 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import React, { FC } from 'react'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { | ||
| EuiConfirmModal, | ||
| EuiOverlayMask, | ||
| EuiSwitch, | ||
| EuiFlexGroup, | ||
| EuiFlexItem, | ||
| EUI_MODAL_CONFIRM_BUTTON, | ||
| } from '@elastic/eui'; | ||
| import { FormattedMessage } from '@kbn/i18n/react'; | ||
|
|
||
| import { DeleteAction } from './use_delete_action'; | ||
|
|
||
| export const DeleteButtonModal: FC<DeleteAction> = ({ | ||
| closeModal, | ||
| deleteAndCloseModal, | ||
| deleteTargetIndex, | ||
| deleteIndexPattern, | ||
| indexPatternExists, | ||
| item, | ||
| toggleDeleteIndex, | ||
| toggleDeleteIndexPattern, | ||
| userCanDeleteIndex, | ||
| }) => { | ||
| if (item === undefined) { | ||
| return null; | ||
| } | ||
|
|
||
| const indexName = item.config.dest.index; | ||
|
|
||
| return ( | ||
| <EuiOverlayMask data-test-subj="mlAnalyticsJobDeleteOverlay"> | ||
| <EuiConfirmModal | ||
| data-test-subj="mlAnalyticsJobDeleteModal" | ||
| title={i18n.translate('xpack.ml.dataframe.analyticsList.deleteModalTitle', { | ||
| defaultMessage: 'Delete {analyticsId}', | ||
| values: { analyticsId: item.config.id }, | ||
| })} | ||
| onCancel={closeModal} | ||
| onConfirm={deleteAndCloseModal} | ||
| cancelButtonText={i18n.translate( | ||
| 'xpack.ml.dataframe.analyticsList.deleteModalCancelButton', | ||
| { | ||
| defaultMessage: 'Cancel', | ||
| } | ||
| )} | ||
| confirmButtonText={i18n.translate( | ||
| 'xpack.ml.dataframe.analyticsList.deleteModalDeleteButton', | ||
| { | ||
| defaultMessage: 'Delete', | ||
| } | ||
| )} | ||
| defaultFocusedButton={EUI_MODAL_CONFIRM_BUTTON} | ||
| buttonColor="danger" | ||
| > | ||
| <p> | ||
| <FormattedMessage | ||
| id="xpack.ml.dataframe.analyticsList.deleteModalBody" | ||
| defaultMessage="Are you sure you want to delete this analytics job?" | ||
| /> | ||
| </p> | ||
|
|
||
| <EuiFlexGroup direction="column" gutterSize="none"> | ||
| <EuiFlexItem> | ||
| {userCanDeleteIndex && ( | ||
| <EuiSwitch | ||
| data-test-subj="mlAnalyticsJobDeleteIndexSwitch" | ||
| style={{ paddingBottom: 10 }} | ||
| label={i18n.translate( | ||
| 'xpack.ml.dataframe.analyticsList.deleteDestinationIndexTitle', | ||
| { | ||
| defaultMessage: 'Delete destination index {indexName}', | ||
| values: { indexName }, | ||
| } | ||
| )} | ||
| checked={deleteTargetIndex} | ||
| onChange={toggleDeleteIndex} | ||
| /> | ||
| )} | ||
| </EuiFlexItem> | ||
| <EuiFlexItem> | ||
| {userCanDeleteIndex && indexPatternExists && ( | ||
| <EuiSwitch | ||
| data-test-subj="mlAnalyticsJobDeleteIndexPatternSwitch" | ||
| label={i18n.translate( | ||
| 'xpack.ml.dataframe.analyticsList.deleteTargetIndexPatternTitle', | ||
| { | ||
| defaultMessage: 'Delete index pattern {indexPattern}', | ||
| values: { indexPattern: indexName }, | ||
| } | ||
| )} | ||
| checked={deleteIndexPattern} | ||
| onChange={toggleDeleteIndexPattern} | ||
| /> | ||
| )} | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| </EuiConfirmModal> | ||
| </EuiOverlayMask> | ||
| ); | ||
| }; |
9 changes: 9 additions & 0 deletions
9
...ication/data_frame_analytics/pages/analytics_management/components/action_delete/index.ts
This file contains hidden or 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,9 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| export { DeleteButton } from './delete_button'; | ||
| export { DeleteButtonModal } from './delete_button_modal'; | ||
| export { useDeleteAction } from './use_delete_action'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.