Fix singular file skip screen and add back link modification

This commit is contained in:
Daniel Lautzenheiser
2022-09-21 19:04:12 -04:00
parent 279e7e154d
commit 6823744acf
3 changed files with 42 additions and 3 deletions

View File

@ -74,13 +74,16 @@ function getDefaultPath(collections) {
/**
* Returns default collection name if only one collection
*
*
* @param {Collection} collection
* @returns {string}
*/
function getDefaultCollectionPath(collection) {
if (collection.has('files') && collection.get('files').size === 1) {
return `/collections/${collection.get('name')}/entries/${collection.get('files').first().get('name')}`;
return `/collections/${collection.get('name')}/entries/${collection
.get('files')
.first()
.get('name')}`;
}
return null;
@ -97,7 +100,7 @@ function RouteInCollectionDefault({ collections, render, ...props }) {
return <Redirect to={defaultPath} />;
}
const defaultCollectionPath = getDefaultCollectionPath(collections);
const defaultCollectionPath = getDefaultCollectionPath(collectionExists);
if (defaultCollectionPath !== null) {
return <Redirect to={defaultCollectionPath} />;
}

View File

@ -447,6 +447,10 @@ function mapStateToProps(state, ownProps) {
editorBackLink = `/workflow`;
}
if (collection.has('files') && collection.get('files').size === 1) {
editorBackLink = '/';
}
if (collection.has('nested') && slug) {
const pathParts = slug.split('/');
if (pathParts.length > 2) {