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

Merged
merged 17 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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 @@ -15,19 +15,16 @@ const DataFilesFormModal = () => {
const history = useHistory();
const location = useLocation();

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

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

const path = updatedPath ? `${projectUrl}/${updatedPath}` : `${projectUrl}`;
history.replace(path);
const projectUrl = match[0];

const cleanProjectUrl = projectUrl.replace(/\/$/, '');
const cleanUpdatedPath = updatedPath.replace(/^\/+/, '');

history.replace(`${cleanProjectUrl}/${cleanUpdatedPath}`);
};

const { form, selectedFile, formName, additionalData, useReloadCallback } =
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(`/${file.name}`, `/${values.name}`)
: newPath;

yield call(reloadCallback, reloadPath);
Expand Down
Loading