Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
leafty committed Jan 3, 2025
1 parent c27a52d commit 5a70917
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 37 deletions.
2 changes: 0 additions & 2 deletions client/src/dataset/Dataset.container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
*/

import { useEffect, useState } from "react";
// import { useHistory, useParams } from "react-router";
import { useLocation, useParams } from "react-router-dom-v5-compat";

import { useCoreSupport } from "../features/project/useProjectCoreSupport";
import useLegacySelector from "../utils/customHooks/useLegacySelector.hook";
import DatasetView from "./Dataset.present";

export default function ShowDataset(props) {
// const history = useHistory();
const location = useLocation();

const { identifier: identifier_ } = useParams();
Expand Down
4 changes: 0 additions & 4 deletions client/src/dataset/Dataset.present.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { groupBy, isEmpty } from "lodash-es";
import { useState } from "react";
import { Helmet } from "react-helmet";
// import { Link } from "react-router-dom";
import { Link, useNavigate } from "react-router-dom-v5-compat";
import {
Button,
Expand Down Expand Up @@ -298,12 +297,10 @@ function ErrorAfterCreation(props) {
}

function AddToProjectButton({ insideKg, locked, logged, identifier }) {
// const history = useHistory();
const navigate = useNavigate();

const addDatasetUrl = `/datasets/${identifier}/add`;
const goToAddToProject = () => {
// if (history) history.push(addDatasetUrl);
navigate(addDatasetUrl);
};

Expand Down Expand Up @@ -595,7 +592,6 @@ export default function DatasetView(props) {
client={props.client}
dataset={dataset}
externalUrl={props.externalUrl}
// history={props.history}
metadataVersion={props.metadataVersion}
modalOpen={deleteDatasetModalOpen}
projectPathWithNamespace={props.projectPathWithNamespace}
Expand Down
49 changes: 18 additions & 31 deletions client/src/project/datasets/delete/DeleteDataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/

import { useEffect, useState } from "react";
// import { useHistory } from "react-router";
import { useNavigate } from "react-router-dom-v5-compat";
import {
Button,
Expand Down Expand Up @@ -109,7 +108,6 @@ type DatasetDeleteModalProps = {
closeModal: () => void;
dataset: DeleteDatasetProps["dataset"];
deleteDataset: () => void;
// history: DeleteDatasetProps["history"];
modalOpen: DeleteDatasetProps["modalOpen"];
serverErrors: CoreErrorContent | string | undefined;
submitLoader: { isSubmitting: boolean; text: string | undefined };
Expand Down Expand Up @@ -142,7 +140,6 @@ export type DeleteDatasetSuccessResponse = {

export interface DeleteDatasetProps extends CoreVersionUrl {
dataset: DatasetCore;
// history: ReturnType<typeof useHistory>;
externalUrl: string;
onCancel: () => void;
modalOpen: boolean;
Expand All @@ -169,33 +166,24 @@ function DeleteDataset(props: DeleteDatasetProps) {
});

// handle deleting dataset
useEffect(
() => {
if (deleteDatasetStatus.error && "data" in deleteDatasetStatus.error) {
const errorResponse = deleteDatasetStatus.error
.data as CoreErrorResponse;
setSubmitting(false);
setServerErrors(errorResponse.error);
} else if (deleteDatasetStatus.error) {
// ? This cases is unlikely to happen with the current implementation of renku-core
setSubmitting(false);
const errorMessage =
"There was an unexpected problem deleting the dataset: " +
deleteDatasetStatus.error.toString();
setServerErrors(errorMessage);
} else if (deleteDatasetStatus.isSuccess) {
setSubmitting(false);
setSubmitLoaderText("Dataset deleted, you will be redirected soon...");
// props.history.push({
// pathname: projectDatasetsUrl,
// state: { reload: true },
// });
navigate({ pathname: projectDatasetsUrl }, { state: { reload: true } });
}
},
[deleteDatasetStatus, navigate, projectDatasetsUrl]
// [deleteDatasetStatus, props.history, projectDatasetsUrl]
);
useEffect(() => {
if (deleteDatasetStatus.error && "data" in deleteDatasetStatus.error) {
const errorResponse = deleteDatasetStatus.error.data as CoreErrorResponse;
setSubmitting(false);
setServerErrors(errorResponse.error);
} else if (deleteDatasetStatus.error) {
// ? This cases is unlikely to happen with the current implementation of renku-core
setSubmitting(false);
const errorMessage =
"There was an unexpected problem deleting the dataset: " +
deleteDatasetStatus.error.toString();
setServerErrors(errorMessage);
} else if (deleteDatasetStatus.isSuccess) {
setSubmitting(false);
setSubmitLoaderText("Dataset deleted, you will be redirected soon...");
navigate({ pathname: projectDatasetsUrl }, { state: { reload: true } });
}
}, [deleteDatasetStatus, navigate, projectDatasetsUrl]);

const localDeleteDataset = () => {
setSubmitting(true);
Expand Down Expand Up @@ -225,7 +213,6 @@ function DeleteDataset(props: DeleteDatasetProps) {
deleteDataset={localDeleteDataset}
serverErrors={serverErrors}
submitLoader={{ isSubmitting, text: submitLoaderText }}
// history={props.history}
/>
);
}
Expand Down

0 comments on commit 5a70917

Please sign in to comment.