-
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.
Add start, stop, and delete actions to rollup jobs table and detail p…
…anel (#22235)
- Loading branch information
Showing
26 changed files
with
910 additions
and
80 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
7 changes: 7 additions & 0 deletions
7
x-pack/plugins/rollup/public/crud_app/sections/components/index.js
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,7 @@ | ||
/* | ||
* 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 { JobActionMenu } from './job_action_menu'; |
114 changes: 114 additions & 0 deletions
114
...crud_app/sections/components/job_action_menu/confirm_delete_modal/confirm_delete_modal.js
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,114 @@ | ||
/* | ||
* 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, { Component, Fragment } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; | ||
|
||
import { | ||
EuiConfirmModal, | ||
EuiOverlayMask, | ||
} from '@elastic/eui'; | ||
|
||
class ConfirmDeleteModalUi extends Component { | ||
static propTypes = { | ||
isSingleSelection: PropTypes.bool.isRequired, | ||
entity: PropTypes.string.isRequired, | ||
jobs: PropTypes.array.isRequired, | ||
onCancel: PropTypes.func.isRequired, | ||
onConfirm: PropTypes.func.isRequired, | ||
} | ||
|
||
renderJobs() { | ||
const { jobs } = this.props; | ||
const jobItems = jobs.map(({ id, status }) => { | ||
const statusText = status === 'started' ? ' (started)' : null; | ||
return <li key={id}>{id}{statusText}</li>; | ||
}); | ||
|
||
return <ul>{jobItems}</ul>; | ||
} | ||
|
||
render() { | ||
const { | ||
isSingleSelection, | ||
entity, | ||
jobs, | ||
onCancel, | ||
onConfirm, | ||
intl, | ||
} = this.props; | ||
|
||
let title; | ||
let content; | ||
|
||
if (isSingleSelection) { | ||
const { id, status } = jobs[0]; | ||
title = intl.formatMessage({ | ||
id: 'xpack.rollupJobs.jobActionMenu.deleteJob.confirmModal.modalTitleSingle', | ||
defaultMessage: 'Delete rollup job \'{id}\'?', | ||
}, { id }); | ||
|
||
if (status === 'started') { | ||
content = ( | ||
<p> | ||
<FormattedMessage | ||
id="xpack.rollupJobs.jobActionMenu.deleteJob.deleteDescriptionSingleRunning" | ||
defaultMessage="This job has been started." | ||
/> | ||
</p> | ||
); | ||
} | ||
} else { | ||
title = intl.formatMessage({ | ||
id: 'xpack.rollupJobs.jobActionMenu.deleteJob.confirmModal.modalTitleMultiple', | ||
defaultMessage: 'Delete {count} rollup jobs?', | ||
}, { count: jobs.length }); | ||
|
||
content = ( | ||
<Fragment> | ||
<p> | ||
<FormattedMessage | ||
id="xpack.rollupJobs.jobActionMenu.deleteJob.deleteDescriptionMultiple" | ||
defaultMessage="You are about to delete {mergedKeyword}" | ||
values={{ mergedKeyword: isSingleSelection ? 'this' : 'these' }} | ||
/> | ||
{' '} | ||
{entity}: | ||
</p> | ||
{this.renderJobs()} | ||
</Fragment> | ||
); | ||
} | ||
|
||
return ( | ||
<EuiOverlayMask> | ||
<EuiConfirmModal | ||
title={title} | ||
onCancel={onCancel} | ||
onConfirm={onConfirm} | ||
cancelButtonText={ | ||
intl.formatMessage({ | ||
id: 'xpack.rollupJobs.jobActionMenu.deleteJob.confirmModal.cancelButtonText', | ||
defaultMessage: 'Cancel', | ||
}) | ||
} | ||
buttonColor="danger" | ||
confirmButtonText={ | ||
intl.formatMessage({ | ||
id: 'xpack.rollupJobs.jobActionMenu.deleteJob.confirmModal.confirmButtonText', | ||
defaultMessage: 'Delete', | ||
}) | ||
} | ||
> | ||
{content} | ||
</EuiConfirmModal> | ||
</EuiOverlayMask> | ||
); | ||
} | ||
} | ||
|
||
export const ConfirmDeleteModal = injectI18n(ConfirmDeleteModalUi); |
7 changes: 7 additions & 0 deletions
7
.../rollup/public/crud_app/sections/components/job_action_menu/confirm_delete_modal/index.js
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,7 @@ | ||
/* | ||
* 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 { ConfirmDeleteModal } from './confirm_delete_modal'; |
7 changes: 7 additions & 0 deletions
7
x-pack/plugins/rollup/public/crud_app/sections/components/job_action_menu/index.js
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,7 @@ | ||
/* | ||
* 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 { JobActionMenu } from './job_action_menu.container'; |
30 changes: 30 additions & 0 deletions
30
...s/rollup/public/crud_app/sections/components/job_action_menu/job_action_menu.container.js
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,30 @@ | ||
/* | ||
* 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 { connect } from 'react-redux'; | ||
import { JobActionMenu as JobActionMenuComponent } from './job_action_menu'; | ||
import { | ||
startJobs, | ||
stopJobs, | ||
deleteJobs, | ||
} from '../../../store/actions'; | ||
|
||
const mapDispatchToProps = (dispatch, { jobs }) => { | ||
const jobIds = jobs.map(job => job.id); | ||
return { | ||
startJobs: () => { | ||
dispatch(startJobs(jobIds)); | ||
}, | ||
stopJobs: () => { | ||
dispatch(stopJobs(jobIds)); | ||
}, | ||
deleteJobs: () => { | ||
dispatch(deleteJobs(jobIds)); | ||
}, | ||
}; | ||
}; | ||
|
||
export const JobActionMenu = connect(undefined, mapDispatchToProps)(JobActionMenuComponent); |
Oops, something went wrong.