Load task button only if folderUrl is set

pull/721/head
nchamo 2019-09-07 12:31:27 -03:00
rodzic 0000cb988c
commit 8b4c81a3b8
2 zmienionych plików z 15 dodań i 19 usunięć

Wyświetl plik

@ -5,25 +5,13 @@ import GoToFolderButton from "./components/GoToFolderButton";
export default class TaskView extends Component { export default class TaskView extends Component {
static propTypes = { static propTypes = {
task: PropTypes.object.isRequired, folderUrl: PropTypes.string.isRequired,
apiURL: PropTypes.string.isRequired, }
}
state = {
folderUrl: null,
};
componentDidMount() {
$.getJSON(`${this.props.apiURL}/projects/${this.props.task.project}/tasks/${this.props.task.id}/checkforurl`)
.done(data => {
this.setState({folderUrl: data.folder_url});
})
}
render() { render() {
const { const {
folderUrl, folderUrl,
} = this.state; } = this.props;
return ( return (
<Fragment> <Fragment>
{folderUrl ? {folderUrl ?

Wyświetl plik

@ -12,9 +12,17 @@ PluginsAPI.Dashboard.addNewTaskButton(
PluginsAPI.Dashboard.addTaskActionButton( PluginsAPI.Dashboard.addTaskActionButton(
["cloudimport/build/TaskView.js"], ["cloudimport/build/TaskView.js"],
function(args, ImportView) { function(args, ImportView) {
return React.createElement(ImportView, { $.ajax({
task: args.task, url: `{{ api_url }}/projects/${args.task.project}/tasks/${args.task.id}/checkforurl`,
apiURL: "{{ api_url }}", dataType: 'json',
}); async: false,
success: function(data) {
if (data.folder_url) {
return React.createElement(ImportView, {
folderUrl: data.folder_url,
});
}
}
});
} }
); );