Skip to content

Commit

Permalink
fix(datasets): the list of datasets is reloaded after dataset create
Browse files Browse the repository at this point in the history
  • Loading branch information
vfried committed Mar 11, 2020
1 parent 3ca895f commit cad115f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/dataset/Dataset.present.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export default function DatasetView(props) {
if (dataset === null) {
return (
<Alert color="danger">
Error 404: The dataset that was selected does not exist or could not
The dataset that was selected does not exist or could not
be accessed.<br /> <br /> If you just created the dataset
try <Button color="danger" size="sm" onClick={
() => window.location.reload()
Expand Down
20 changes: 12 additions & 8 deletions src/project/Project.present.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,18 +546,12 @@ class ProjectViewOverview extends Component {

class ProjectDatasetsNav extends Component {

componentDidMount() {
this.props.fetchDatasets();
}

render() {
const loading = isRequestPending(this.props, "datasets");
const allDatasets = this.props.core.datasets || [];
if (loading && (allDatasets.length < 1 || this.props.core.datasets === undefined))
return <Loader />;

if (allDatasets.length === 0)
return null;

return <DatasetsListView
datasets={this.props.core.datasets}
datasetsUrl={this.props.datasetsUrl}
Expand All @@ -582,8 +576,18 @@ class ProjectViewDatasets extends Component {

class ProjectViewDatasetsList extends Component {

componentDidMount() {
if (this.props.core.datasets === undefined
|| (this.props.location.state && this.props.location.state.datasets))
this.props.fetchDatasets();
}

render() {
const loading = isRequestPending(this.props, "datasets");
const loading = this.props.core.datasets === SpecialPropVal.UPDATING;
const incomingDatasets = this.props.location.state && this.props.location.state.datasets
? this.props.location.state.datasets : [];
if (loading || this.props.core.datasets === undefined || incomingDatasets.length > this.props.core.datasets.length)
return <Loader />;
const progress = this.props.webhook.progress;
const kgLoading = progress == null
|| progress === GraphIndexingStatus.NO_WEBHOOK
Expand Down
45 changes: 22 additions & 23 deletions src/project/datasets/new/DatasetNew.present.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,30 @@ function DatasetNew(props) {

props.client.postDataset(props.httpProjectUrl, dataset)
.then(dataset => {
if (dataset.data.error !== undefined) {
if (dataset.data.error !== undefined) {
setSubmitLoader(false);
setServerErrors(dataset.data.error.reason);
}
else {
let waitForDatasetInKG = setInterval(
() => {
props.client.getProjectDatasetsFromKG(props.projectPathWithNamespace)
.then(datasets => {
// eslint-disable-next-line
let new_dataset = datasets.find( ds => ds.name === dataset.data.result.dataset_name);
if (new_dataset !== undefined) {
setSubmitLoader(false);
props.datasetFormSchema.name.value = props.datasetFormSchema.name.initial;
props.datasetFormSchema.description.value = props.datasetFormSchema.description.initial;
props.datasetFormSchema.files.value = props.datasetFormSchema.files.initial;
clearInterval(waitForDatasetInKG);
props.history.push(
{ pathname: `/projects/${props.projectPathWithNamespace}/datasets/${new_dataset.identifier}/`
});
}
});
}
, 6000);
}
}
else {
let waitForDatasetInKG = setInterval(() => {
props.client.getProjectDatasetsFromKG(props.projectPathWithNamespace)
.then(datasets => {
// eslint-disable-next-line
let new_dataset = datasets.find( ds => ds.name === dataset.data.result.dataset_name);
if (new_dataset !== undefined) {
setSubmitLoader(false);
props.datasetFormSchema.name.value = props.datasetFormSchema.name.initial;
props.datasetFormSchema.description.value = props.datasetFormSchema.description.initial;
props.datasetFormSchema.files.value = props.datasetFormSchema.files.initial;
clearInterval(waitForDatasetInKG);
props.history.push({
pathname: `/projects/${props.projectPathWithNamespace}/datasets/${new_dataset.identifier}/`,
state: { datasets: datasets }
});
}
});
}, 6000);
}
});
};

Expand Down

0 comments on commit cad115f

Please sign in to comment.