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 15 commits into
base: task/digital-rocks
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 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,20 +16,19 @@ 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}`;
const path = updatedPath ? `${projectUrl}/${updatedPath}` : projectUrl;
history.replace(path);
};

const { form, selectedFile, formName, additionalData, useReloadCallback } =
useSelector((state) => state.files.modalProps.dynamicform);
const isOpen = useSelector((state) => state.files.modals.dynamicform);
Expand Down
7 changes: 4 additions & 3 deletions client/src/redux/sagas/_custom/drp.sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ function* executeOperation(
isEdit && file.path === params.path
? `${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(`/${file.name}`, `/${values.name}`)
: newPath;

yield call(reloadCallback, reloadPath);
}

Expand Down
Loading