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 {
static propTypes = {
task: PropTypes.object.isRequired,
apiURL: PropTypes.string.isRequired,
}
folderUrl: 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() {
const {
folderUrl,
} = this.state;
} = this.props;
return (
<Fragment>
{folderUrl ?

Wyświetl plik

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