Skip to content

Commit

Permalink
Remove the wizard reachedFrom param now that it's no longer necessary…
Browse files Browse the repository at this point in the history
… for the modal or the cancel button
  • Loading branch information
mturley committed Jul 20, 2022
1 parent 719e7ac commit 8966443
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 31 deletions.
2 changes: 1 addition & 1 deletion console-extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"groupId": "import-application-group",
"label": "Import from cluster",
"description": "Import a manually deployed application on another cluster to an automated GitOps workflow.",
"href": "/app-imports/new/ns/:namespace?from=add",
"href": "/app-imports/new/ns/:namespace",
"icon": { "$codeRef": "icons.importIconElement" }
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/AppImportsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const AppImportsPage: React.FunctionComponent<AppImportsPageProps> = ({
}, [activePipelineGroupName, activePipelineGroup, deletePipelineMutation, history, namespace]);

const isEmptyState = loaded && pipelineGroups.length === 0;
const goToImportWizard = () => history.push(appImportWizardUrl(namespace, 'imports'));
const goToImportWizard = () => history.push(appImportWizardUrl(namespace));

return (
<Page>
Expand Down
7 changes: 2 additions & 5 deletions src/components/ImportPage.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import * as React from 'react';
import Helmet from 'react-helmet';
import { useLocation, useRouteMatch } from 'react-router-dom';
import { useRouteMatch } from 'react-router-dom';
import { PageSection, Title } from '@patternfly/react-core';
import { QueryClient, QueryClientProvider } from 'react-query';
import { ImportWizard } from './ImportWizard/ImportWizard';
import { NamespaceContext } from 'src/context/NamespaceContext';
import { WizardReachedFromParam } from 'src/utils/paths';

const queryClient = new QueryClient();

const ImportPage: React.FunctionComponent = () => {
const {
params: { namespace },
} = useRouteMatch<{ namespace: string }>();
const location = useLocation();
const urlParams = React.useMemo(() => new URLSearchParams(location.search), [location.search]);
return (
<>
<Helmet>
Expand All @@ -27,7 +24,7 @@ const ImportPage: React.FunctionComponent = () => {
<Title headingLevel="h1">Import application</Title>
</PageSection>
<PageSection variant="light" type="wizard">
<ImportWizard reachedFrom={urlParams.get('from') as WizardReachedFromParam} />
<ImportWizard />
</PageSection>
</>
</NamespaceContext.Provider>
Expand Down
10 changes: 3 additions & 7 deletions src/components/ImportWizard/ImportWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { getYamlFieldKeys } from './helpers';
import { ConfirmModal } from 'src/common/components/ConfirmModal';
import { RouteGuard } from 'src/common/components/RouteGuard';
import { useSourcePVCsQuery } from 'src/api/queries/sourceResources';
import { WizardReachedFromParam, appImportsPageUrl } from 'src/utils/paths';
import { appImportsPageUrl } from 'src/utils/paths';
import { ImportWizardWelcomeModal } from './ImportWizardWelcomeModal';

enum StepId {
Expand All @@ -45,11 +45,7 @@ enum StepId {
Review,
}

interface ImportWizardProps {
reachedFrom: WizardReachedFromParam;
}

export const ImportWizard: React.FunctionComponent<ImportWizardProps> = ({ reachedFrom }) => {
export const ImportWizard: React.FunctionComponent = () => {
const history = useHistory();

const forms = useImportWizardFormState();
Expand Down Expand Up @@ -337,7 +333,7 @@ export const ImportWizard: React.FunctionComponent<ImportWizardProps> = ({ reach
</WizardFooter>
}
/>
<ImportWizardWelcomeModal reachedFrom={reachedFrom} />
<ImportWizardWelcomeModal />
</ImportWizardFormContext.Provider>
);
};
15 changes: 3 additions & 12 deletions src/components/ImportWizard/ImportWizardWelcomeModal.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
import * as React from 'react';
import { Link } from 'react-router-dom';
import { Button, Modal, TextContent, Text, Checkbox } from '@patternfly/react-core';
import { appImportsPageUrl, pipelinesListUrl, WizardReachedFromParam } from 'src/utils/paths';
import { appImportsPageUrl, pipelinesListUrl } from 'src/utils/paths';
import { useNamespaceContext } from 'src/context/NamespaceContext';
import spacing from '@patternfly/react-styles/css/utilities/Spacing/spacing';
import { useLocalStorage } from 'src/common/hooks/useLocalStorage';

type ImportWizardWelcomeModalProps = {
reachedFrom: WizardReachedFromParam;
};

export const ImportWizardWelcomeModal: React.FunctionComponent<ImportWizardWelcomeModalProps> = ({
reachedFrom,
}) => {
export const ImportWizardWelcomeModal: React.FunctionComponent = () => {
const namespace = useNamespaceContext();
const [isDisabled, setIsDisabled] = useLocalStorage('isCraneWizardWelcomeModalDisabled');
const [isOpen, setIsOpen] = React.useState(false);
React.useEffect(() => {
if (reachedFrom !== 'add' && isDisabled !== 'true') setIsOpen(true);
}, [isDisabled, reachedFrom]);
const [isOpen, setIsOpen] = React.useState(isDisabled !== 'true');
const onClose = () => setIsOpen(false);
return (
<Modal
Expand Down
2 changes: 1 addition & 1 deletion src/utils/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const useTopologyGraphActionProvider: TopologyActionProvider = ({ element
label: 'Import application from cluster',
icon: importIconElement,
cta: {
href: appImportWizardUrl(namespace, 'topology'),
href: appImportWizardUrl(namespace),
},
path: 'add-to-project',
},
Expand Down
5 changes: 1 addition & 4 deletions src/utils/paths.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { pipelineRunGVK } from 'src/api/queries/pipelines';
import { PipelineRunKind } from 'src/reused/pipelines-plugin/src/types';

export type WizardReachedFromParam = 'add' | 'topology' | 'imports' | null;

export const appImportWizardUrl = (namespace: string, from?: WizardReachedFromParam) =>
`/app-imports/new/ns/${namespace}${from ? `?from=${from}` : ''}`;
export const appImportWizardUrl = (namespace: string) => `/app-imports/new/ns/${namespace}`;

export const appImportsPageUrl = (namespace: string, pipelineGroupName?: string) =>
`/app-imports/ns/${namespace}${pipelineGroupName ? `/${pipelineGroupName}` : ''}`;
Expand Down

0 comments on commit 8966443

Please sign in to comment.