Skip to content

Commit

Permalink
Merge pull request #968 from avivtur/delete-modal-wrong-url
Browse files Browse the repository at this point in the history
Bug 2142647: Delete modal lead to wrong URL
  • Loading branch information
openshift-merge-robot authored Nov 15, 2022
2 parents df5bb1c + 87e6dd5 commit f5ce596
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/utils/components/DeleteModal/DeleteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { useHistory } from 'react-router-dom';

import TabModal from '@kubevirt-utils/components/TabModal/TabModal';
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation';
import { K8sResourceCommon } from '@openshift-console/dynamic-plugin-sdk';
import { getResourceUrl } from '@kubevirt-utils/resources/shared';
import {
getGroupVersionKindForResource,
K8sResourceCommon,
} from '@openshift-console/dynamic-plugin-sdk';
import { useK8sModel } from '@openshift-console/dynamic-plugin-sdk/lib/utils/k8s/hooks/useK8sModel';
import { useLastNamespace } from '@openshift-console/dynamic-plugin-sdk-internal';
import { ButtonVariant } from '@patternfly/react-core';

import ConfirmActionMessage from '../ConfirmActionMessage/ConfirmActionMessage';
Expand All @@ -21,15 +27,16 @@ const DeleteModal: React.FC<DeleteModalProps> = React.memo(
const { t } = useKubevirtTranslation();
const history = useHistory();

const [model] = useK8sModel(getGroupVersionKindForResource(obj));
const [lastNamespace] = useLastNamespace();
const url = getResourceUrl({ model, activeNamespace: lastNamespace });
return (
<TabModal<K8sResourceCommon>
obj={obj}
headerText={headerText || t('Delete Resource?')}
onSubmit={() => {
return onDeleteSubmit().then(() => {
const pathname = history?.location?.pathname;
const url = pathname.slice(0, pathname.indexOf(obj?.metadata?.name));
pathname?.includes(obj?.metadata?.name) && history.push(url);
history.push(url);
});
}}
isOpen={isOpen}
Expand Down

0 comments on commit f5ce596

Please sign in to comment.