Skip to content

Commit

Permalink
[RHOAIENG-11326] Creating new pipeline from Create Run Page redirects…
Browse files Browse the repository at this point in the history
… to the pipeline detail page
  • Loading branch information
jpuzz0 committed Sep 26, 2024
1 parent 063d974 commit 0c42869
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const PipelineSection: React.FC<PipelineSectionProps> = ({
variant="link"
icon={<PlusCircleIcon />}
onCreate={onPipelineChange}
redirectAfterImport={false}
>
Create new pipeline
</ImportPipelineButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import { PipelineKFv2 } from '~/concepts/pipelines/kfTypes';

type ImportPipelineButtonProps = {
onCreate?: (pipeline: PipelineKFv2) => void;
redirectAfterImport?: boolean;
} & Omit<React.ComponentProps<typeof Button>, 'onClick'>;

const ImportPipelineButton: React.FC<ImportPipelineButtonProps> = ({
onCreate,
children,
redirectAfterImport,
...buttonProps
}) => {
const { apiAvailable, refreshAllAPI, pipelinesServer } = usePipelinesAPI();
Expand All @@ -28,6 +30,7 @@ const ImportPipelineButton: React.FC<ImportPipelineButtonProps> = ({
</Button>
<PipelineImportModal
isOpen={open}
redirectAfterImport={redirectAfterImport}
onClose={(pipeline) => {
setOpen(false);
if (pipeline) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ import { PipelineUploadOption, extractKindFromPipelineYAML } from './utils';
type PipelineImportModalProps = {
isOpen: boolean;
onClose: (pipeline?: PipelineKFv2) => void;
redirectAfterImport?: boolean;
};

const PipelineImportModal: React.FC<PipelineImportModalProps> = ({ isOpen, onClose }) => {
const PipelineImportModal: React.FC<PipelineImportModalProps> = ({
isOpen,
redirectAfterImport = true,
onClose,
}) => {
const navigate = useNavigate();
const { project, api, apiAvailable, namespace } = usePipelinesAPI();
const [importing, setImporting] = React.useState(false);
Expand Down Expand Up @@ -73,11 +78,11 @@ const PipelineImportModal: React.FC<PipelineImportModalProps> = ({ isOpen, onClo
);
const versionId = versions?.[0].pipeline_version_id;

if (versionId) {
if (redirectAfterImport && versionId) {
navigate(pipelineVersionDetailsRoute(namespace, pipeline.pipeline_id, versionId));
}
},
[api, namespace, navigate, onBeforeClose],
[api, namespace, redirectAfterImport, navigate, onBeforeClose],
);

const checkForDuplicateName = useDebounceCallback(
Expand Down

0 comments on commit 0c42869

Please sign in to comment.