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

Wc 129 dataset form redirect fix #1006

Open
wants to merge 14 commits into
base: task/digital-rocks
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@ const DataFilesFormModal = () => {
const location = useLocation();

const reloadPage = (updatedPath = '') => {
// Updated regex to capture the URL up until the last project segment
let projectUrl = location.pathname.replace(
/(\/projects\/[^/]+\/[^/]+)\/?.*/,
/(\/projects\/[^/]+\/[^/]+\/?.*)/,
'$1'
);

if (projectUrl.endsWith('/')) {
projectUrl = projectUrl.slice(0, -1);
}

const path = updatedPath ? `${projectUrl}/${updatedPath}` : `${projectUrl}`;
// Avoid appending updatedPath if it's already part of projectUrl
const path =
updatedPath && !projectUrl.endsWith(updatedPath)
? `${projectUrl}/${updatedPath}`
: projectUrl;

history.replace(path);
};

Expand Down
3 changes: 2 additions & 1 deletion client/src/redux/sagas/_custom/drp.sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ function* executeOperation(
? `${path}/${file.path.split('/').pop()}`
: path;

// Check if the file name has changed. If not, keep the same path
const reloadPath =
isEdit && file.name !== values.name
? newPath.replace(file.name, values.name)
? newPath.replace(new RegExp(`/${file.name}$`), `/${values.name}`)
: newPath;

yield call(reloadCallback, reloadPath);
Expand Down
Loading