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
Endpoint to allow users to delete pending on-demand tasks #1653
Changes from 5 commits
f1cfcc1
8d9fdf3
a635fd2
72beec8
6489d99
232e74a
c96ec74
99532b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React, { Component, PropTypes } from 'react'; | ||
|
||
import { Glyphicon } from 'react-bootstrap'; | ||
import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger'; | ||
import ToolTip from 'react-bootstrap/lib/Tooltip'; | ||
|
||
import { getClickComponent } from '../modal/ModalWrapper'; | ||
|
||
import DeletePendingTaskModal from './DeletePendingTaskModal'; | ||
|
||
const deletePendingTaskTooltip = ( | ||
<ToolTip id="delete"> | ||
Delete this pending task | ||
</ToolTip> | ||
); | ||
|
||
export default class DeletePendingTaskButton extends Component { | ||
|
||
static propTypes = { | ||
taskId: PropTypes.string.isRequired, | ||
requestType: PropTypes.string.isRequired, | ||
then: PropTypes.func | ||
}; | ||
|
||
static defaultProps = { | ||
children: ( | ||
<OverlayTrigger placement="top" id="view-delete-pending-task-overlay" overlay={deletePendingTaskTooltip}> | ||
<a> | ||
<Glyphicon glyph="trash" /> | ||
</a> | ||
</OverlayTrigger> | ||
) | ||
}; | ||
|
||
render() { | ||
if (this.props.requestType == "ON_DEMAND") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than making this check here, I would only render the button in the first place if the type is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could wrap it in a conditional, like
|
||
return ( | ||
<span> | ||
{getClickComponent(this)} | ||
<DeletePendingTaskModal | ||
ref="modal" | ||
taskId={this.props.taskId} | ||
requestType={this.props.requestType} | ||
then={this.props.then} | ||
/> | ||
</span> | ||
); | ||
} | ||
return (null); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React, { Component, PropTypes } from 'react'; | ||
import { connect } from 'react-redux'; | ||
|
||
import { DeletePendingOnDemandTask } from '../../../actions/api/tasks'; | ||
|
||
import FormModal from '../../common/modal/FormModal'; | ||
|
||
class DeletePendingTaskModal extends Component { | ||
static propTypes = { | ||
taskId: PropTypes.string.isRequired, | ||
requestType: PropTypes.string.isRequired, | ||
deletePendingTask: PropTypes.func.isRequired, | ||
then: PropTypes.func | ||
}; | ||
|
||
show() { | ||
this.refs.deletePendingTaskModal.show(); | ||
} | ||
|
||
render() { | ||
return ( | ||
<FormModal | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we not already have a confirm modal? Feels bad doing it as a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes, we do have one! I'll swap it out. |
||
name="Delete Pending Task" | ||
ref="deletePendingTaskModal" | ||
action="Delete Pending Task" | ||
onConfirm={() => this.props.deletePendingTask()} | ||
buttonStyle="primary" | ||
formElements={[]}> | ||
<p>Are you sure you want to delete this task?</p> | ||
<pre>{this.props.taskId}</pre> | ||
</FormModal> | ||
); | ||
} | ||
} | ||
|
||
const mapDispatchToProps = (dispatch, ownProps) => ({ | ||
deletePendingTask: () => dispatch(DeletePendingOnDemandTask.trigger(ownProps.taskId)).then(response => (ownProps.then && ownProps.then(response))) | ||
}); | ||
|
||
export default connect( | ||
null, | ||
mapDispatchToProps, | ||
null, | ||
{ withRef: true } | ||
)(DeletePendingTaskModal); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import classNames from 'classnames'; | |
|
||
import Utils from '../../utils'; | ||
|
||
import DeletePendingTaskButton from '../common/modalButtons/DeletePendingTaskButton'; | ||
import JSONButton from '../common/JSONButton'; | ||
import KillTaskButton from '../common/modalButtons/KillTaskButton'; | ||
import RunNowButton from '../common/modalButtons/RunNowButton'; | ||
|
@@ -307,6 +308,9 @@ export const ScheduledActions = ( | |
cellRender={(cellData) => ( | ||
<div className="hidden-xs"> | ||
<RunNowButton requestId={cellData.pendingTask.pendingTaskId.requestId} /> | ||
<DeletePendingTaskButton taskId={cellData.pendingTask.pendingTaskId.id} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style: |
||
requestType={cellData.request.requestType} | ||
/> | ||
<JSONButton className="inline" object={cellData} showOverlay={true}> | ||
{'{ }'} | ||
</JSONButton> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,8 @@ master: | |
net: host | ||
environment: | ||
MESOS_ZK: zk://localhost:2181/mesos | ||
MESOS_HOSTNAME: localhost | ||
MESOS_IP: 127.0.0.1 | ||
MESOS_HOSTNAME: 192.168.99.100 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have a fix for this in #1655 , I'll merge through to master so you can pull it in |
||
MESOS_IP: 192.168.99.100 | ||
MESOS_QUORUM: 1 | ||
MESOS_CLUSTER: docker-compose | ||
MESOS_WORK_DIR: /var/lib/mesos | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defining the children here seems weird, especially since the component is only being used in one place. Do we need the ability to override the button's contents? Either way, I would move the logic into the
render
function rather thandefaultProps
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No override necessary that I can think of. Curious, why is it done this way in the
PauseButton
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, this UI has a lot of demons ha. I don't blame you for copying it though. In this case I think it's fine if you just hardcode it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, figured out why it's defined here - the
getClickComponent
hooks up theonClick
logic based onprops.children
. I'll leave for now unless you have better alternative?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine if it'll be a bigger refactor. Better to have it be consistent for now.