Skip to content
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

FIX Correctly reset file details after bulk publish #1316

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/dist/js/TinyMCE_sslink-file.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions client/dist/js/TinyMCE_ssmedia.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions client/dist/js/bundle.js

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions client/src/containers/AssetAdmin/AssetAdmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ class AssetAdmin extends Component {
}
// If the file is currently being edited, refresh that view
if (this.props.fileId === file.id) {
this.handleCloseFile();
this.handleOpenFile(file.id);
this.props.resetFileDetails(this.getFolderId(), file.id, this.props.query);
}
}

Expand Down Expand Up @@ -481,8 +480,7 @@ class AssetAdmin extends Component {
this.props.actions.files.readFiles()
.then(() => {
if (fileId && response.find(file => file.id === fileId)) {
this.handleCloseFile();
this.handleOpenFile(fileId);
this.props.resetFileDetails(this.getFolderId(), fileId, this.props.query);
}
});
});
Expand Down Expand Up @@ -739,6 +737,7 @@ AssetAdmin.propTypes = {
sectionConfig: configShape,
fileId: PropTypes.number,
folderId: PropTypes.number,
resetFileDetails: PropTypes.func,
onBrowse: PropTypes.func,
onReplaceUrl: PropTypes.func,
onInsertMany: PropTypes.func,
Expand Down
33 changes: 33 additions & 0 deletions client/src/containers/AssetAdmin/AssetAdminRouter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component } from 'react';
import { Navigate } from 'react-router-dom';
import { connect } from 'react-redux';
import withRouter, { routerPropTypes } from 'lib/withRouter';
import AssetAdmin from 'containers/AssetAdmin/AssetAdmin';
Expand Down Expand Up @@ -53,6 +54,7 @@ class AssetAdminRouter extends Component {

this.handleBrowse = this.handleBrowse.bind(this);
this.handleReplaceUrl = this.handleReplaceUrl.bind(this);
this.handleResetDetails = this.handleResetDetails.bind(this);
this.getUrl = this.getUrl.bind(this);
}

Expand Down Expand Up @@ -128,6 +130,7 @@ class AssetAdminRouter extends Component {
getUrl: this.getUrl,
onBrowse: this.handleBrowse,
onReplaceUrl: this.handleReplaceUrl,
resetFileDetails: this.handleResetDetails,
};
}

Expand Down Expand Up @@ -169,10 +172,40 @@ class AssetAdminRouter extends Component {
this.props.router.navigate(pathname, { replace: true });
}

/**
* Reset the details screen for a file.
* This requires replacing the current navigation to the folder without the details open,
* then replacing it again with it open again.
*
* @param {number} [folderId]
* @param {number} [fileId]
* @param {object} [query]
*/
handleResetDetails(folderId, fileId, query) {
const currentPathname = this.getUrl(folderId, fileId, query);
const clearPathname = this.getUrl(folderId, null, query);
this.props.router.navigate(
clearPathname,
{
replace: true,
state: { reset: true, resetPath: currentPathname }
}
);
}

render() {
// If rendering during a details reset, navigate back to the appropriate location
const locationState = this.props.router.location.state;
if (locationState && locationState && locationState.reset) {
return (
<Navigate to={locationState.resetPath} replace />
);
}
// If there's no section config we have nothing to render
if (!this.props.sectionConfig) {
return null;
}
// Render the asset admin
return (
<AssetAdmin {...this.getSectionProps()} />
);
Expand Down