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

Conditionally render pipeline modals #3300

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 1 addition & 3 deletions frontend/src/concepts/pipelines/content/ArchiveModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ interface ArchiveModalProps {
onCancel: () => void;
onSubmit: () => Promise<void[]>;
children: React.ReactNode;
isOpen: boolean;
testId: string;
}

Expand All @@ -21,7 +20,6 @@ export const ArchiveModal: React.FC<ArchiveModalProps> = ({
title,
alertTitle,
children,
isOpen,
testId,
}) => {
const { refreshAllAPI } = usePipelinesAPI();
Expand Down Expand Up @@ -53,7 +51,7 @@ export const ArchiveModal: React.FC<ArchiveModalProps> = ({

return (
<Modal
isOpen={isOpen}
isOpen
title={title}
titleIconVariant="warning"
variant="small"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const PipelineServerActions: React.FC<PipelineServerActionsProps> = ({ variant,
}}
/>
) : null}
<ViewServerModal isOpen={viewOpen} onClose={() => setViewOpen(false)} />
{viewOpen ? <ViewServerModal onClose={() => setViewOpen(false)} /> : null}
{deletePipelinesOpen ? (
<DeletePipelinesModal
toDeletePipelines={pipelines}
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/concepts/pipelines/content/RestoreModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ interface RestoreModalProps {
title: string;
alertTitle: string;
children: React.ReactNode;
isOpen: boolean;
testId: string;
}

Expand All @@ -18,7 +17,6 @@ export const RestoreModal: React.FC<RestoreModalProps> = ({
onSubmit,
title,
children,
isOpen,
testId,
alertTitle,
}) => {
Expand All @@ -43,7 +41,7 @@ export const RestoreModal: React.FC<RestoreModalProps> = ({

return (
<Modal
isOpen={isOpen}
isOpen
title={title}
variant="small"
onClose={onCancel}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ import { ExternalDatabaseSecret } from '~/concepts/pipelines/content/configurePi
import { DSPipelineKind } from '~/k8sTypes';

type ViewPipelineServerModalProps = {
isOpen: boolean;
onClose: () => void;
pipelineNamespaceCR: DSPipelineKind | null;
};

const ViewPipelineServerModal: React.FC<ViewPipelineServerModalProps> = ({
isOpen,
onClose,
pipelineNamespaceCR,
}) => {
Expand All @@ -35,7 +33,7 @@ const ViewPipelineServerModal: React.FC<ViewPipelineServerModalProps> = ({
const databaseSecret = dataEntryToRecord(result?.values?.data ?? []);

return (
<Modal title="View pipeline server" isOpen={isOpen} onClose={onClose} variant="small">
<Modal title="View pipeline server" isOpen onClose={onClose} variant="small">
{pipelineNamespaceCR && (
<DescriptionList termWidth="20ch" isHorizontal>
{!!pipelineNamespaceCR.spec.objectStorage.externalStorage?.s3CredentialsSecret
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { configureDSPipelineResourceSpec, objectStorageIsValid } from './utils';
import { PipelineServerConfigType } from './types';

type ConfigurePipelinesServerModalProps = {
open: boolean;
onClose: () => void;
};

Expand All @@ -27,20 +26,13 @@ const FORM_DEFAULTS: PipelineServerConfigType = {

export const ConfigurePipelinesServerModal: React.FC<ConfigurePipelinesServerModalProps> = ({
onClose,
open,
}) => {
const { project, namespace } = usePipelinesAPI();
const [dataConnections, loaded, , refresh] = useDataConnections(namespace);
const [dataConnections, loaded] = useDataConnections(namespace);
const [fetching, setFetching] = React.useState(false);
const [error, setError] = React.useState<Error>();
const [config, setConfig] = React.useState<PipelineServerConfigType>(FORM_DEFAULTS);

React.useEffect(() => {
if (open) {
refresh();
}
}, [open, refresh]);

const databaseIsValid = config.database.useDefault
? true
: config.database.value.every(({ key, value }) =>
Expand Down Expand Up @@ -101,7 +93,7 @@ export const ConfigurePipelinesServerModal: React.FC<ConfigurePipelinesServerMod
title="Configure pipeline server"
variant="medium"
description="Configuring a pipeline server enables you to create and manage pipelines."
isOpen={open}
isOpen
onClose={onBeforeClose}
footer={
<DashboardModalFooter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,19 @@
>
{children || 'Create experiment'}
</Button>
<CreateExperimentModal
isOpen={open}
onClose={(experiment) => {
setOpen(false);
if (experiment) {
if (onCreate) {
onCreate(experiment);
{open ? (
<CreateExperimentModal
onClose={(experiment) => {
setOpen(false);
if (experiment) {
if (onCreate) {
onCreate(experiment);

Check warning on line 34 in frontend/src/concepts/pipelines/content/experiment/CreateExperimentButton.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/pipelines/content/experiment/CreateExperimentButton.tsx#L29-L34

Added lines #L29 - L34 were not covered by tests
}
refreshAllAPI();

Check warning on line 36 in frontend/src/concepts/pipelines/content/experiment/CreateExperimentButton.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/pipelines/content/experiment/CreateExperimentButton.tsx#L36

Added line #L36 was not covered by tests
}
refreshAllAPI();
}
}}
/>
}}
/>
) : null}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ import {
import { CharLimitHelperText } from '~/components/CharLimitHelperText';

type CreateExperimentModalProps = {
isOpen: boolean;
onClose: (experiment?: ExperimentKFv2) => void;
};

const CreateExperimentModal: React.FC<CreateExperimentModalProps> = ({ isOpen, onClose }) => {
const CreateExperimentModal: React.FC<CreateExperimentModalProps> = ({ onClose }) => {
const { project, api, apiAvailable } = usePipelinesAPI();
const [submitting, setSubmitting] = React.useState(false);
const [error, setError] = React.useState<Error | undefined>();
Expand All @@ -41,7 +40,7 @@ const CreateExperimentModal: React.FC<CreateExperimentModalProps> = ({ isOpen, o

return (
<Modal
isOpen={isOpen}
isOpen
title="Create experiment"
onClose={() => onBeforeClose()}
actions={[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,20 @@
>
{children || 'Import pipeline'}
</Button>
<PipelineImportModal
isOpen={open}
redirectAfterImport={redirectAfterImport}
onClose={(pipeline) => {
setOpen(false);
if (pipeline) {
if (onCreate) {
onCreate(pipeline);
{open ? (
<PipelineImportModal

Check warning on line 32 in frontend/src/concepts/pipelines/content/import/ImportPipelineButton.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/pipelines/content/import/ImportPipelineButton.tsx#L32

Added line #L32 was not covered by tests
redirectAfterImport={redirectAfterImport}
onClose={(pipeline) => {
setOpen(false);
if (pipeline) {
if (onCreate) {
onCreate(pipeline);

Check warning on line 38 in frontend/src/concepts/pipelines/content/import/ImportPipelineButton.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/pipelines/content/import/ImportPipelineButton.tsx#L34-L38

Added lines #L34 - L38 were not covered by tests
}
refreshAllAPI();

Check warning on line 40 in frontend/src/concepts/pipelines/content/import/ImportPipelineButton.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/pipelines/content/import/ImportPipelineButton.tsx#L40

Added line #L40 was not covered by tests
}
refreshAllAPI();
}
}}
/>
}}
/>
) : null}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,19 @@
</DropdownItem>
</DropdownList>
</Dropdown>
<PipelineImportModal
isOpen={isPipelineModalOpen}
onClose={(pipeline) => {
setPipelineModalOpen(false);
if (pipeline) {
if (onImportPipeline) {
onImportPipeline(pipeline);
{isPipelineModalOpen ? (
<PipelineImportModal
onClose={(pipeline) => {
setPipelineModalOpen(false);
if (pipeline) {
if (onImportPipeline) {
onImportPipeline(pipeline);

Check warning on line 91 in frontend/src/concepts/pipelines/content/import/ImportPipelineSplitButton.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/pipelines/content/import/ImportPipelineSplitButton.tsx#L91

Added line #L91 was not covered by tests
}
refreshAllAPI();
}
refreshAllAPI();
}
}}
/>
}}
/>
) : null}
{isPipelineVersionModalOpen && (
<PipelineVersionImportModal
onClose={(pipelineVersion) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ import PipelineUploadRadio from './PipelineUploadRadio';
import { PipelineUploadOption, extractKindFromPipelineYAML } from './utils';

type PipelineImportModalProps = {
isOpen: boolean;
onClose: (pipeline?: PipelineKFv2) => void;
redirectAfterImport?: boolean;
};

const PipelineImportModal: React.FC<PipelineImportModalProps> = ({
isOpen,
redirectAfterImport = true,
onClose,
}) => {
Expand Down Expand Up @@ -152,7 +150,7 @@ const PipelineImportModal: React.FC<PipelineImportModalProps> = ({
return (
<Modal
title="Import pipeline"
isOpen={isOpen}
isOpen
onClose={() => onBeforeClose()}
actions={[
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,9 @@ const PipelineRunDetails: React.FC<
}
}}
/>
<ArchiveRunModal
isOpen={archiving}
runs={run ? [run] : []}
onCancel={() => setArchiving(false)}
/>
{archiving ? (
<ArchiveRunModal runs={run ? [run] : []} onCancel={() => setArchiving(false)} />
) : null}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ const ActiveExperimentTable: React.FC<ActiveExperimentTableProps> = ({ ...baseTa
/>
)}
/>
<ArchiveExperimentModal
isOpen={isArchiveModalOpen}
experiments={archiveExperiments}
onCancel={() => setIsArchiveModalOpen(false)}
/>
{isArchiveModalOpen ? (
<ArchiveExperimentModal
experiments={archiveExperiments}
onCancel={() => setIsArchiveModalOpen(false)}
/>
) : null}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ const ArchivedExperimentTable: React.FC<ArchivedExperimentTableProps> = ({ ...ba
/>
)}
/>
<RestoreExperimentModal
isOpen={isRestoreModalOpen}
experiments={restoreExperiments}
onCancel={() => setIsRestoreModalOpen(false)}
/>
{isRestoreModalOpen ? (
<RestoreExperimentModal
experiments={restoreExperiments}
onCancel={() => setIsRestoreModalOpen(false)}
/>
) : null}
{deleteExperiment ? (
<DeleteExperimentModal
onCancel={() => setDeleteExperiment(undefined)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,22 +295,24 @@ const PipelineRunTableInternal: React.FC<PipelineRunTableInternalProps> = ({
data-testid={`${runType}-runs-table`}
id={`${runType}-runs-table`}
/>
<ArchiveRunModal
isOpen={isArchiveModalOpen}
runs={selectedRuns}
onCancel={() => {
setIsArchiveModalOpen(false);
setSelectedIds([]);
}}
/>
<RestoreRunModal
isOpen={isRestoreModalOpen}
runs={selectedRuns}
onCancel={() => {
setIsRestoreModalOpen(false);
setSelectedIds([]);
}}
/>
{isArchiveModalOpen ? (
<ArchiveRunModal
runs={selectedRuns}
onCancel={() => {
setIsArchiveModalOpen(false);
setSelectedIds([]);
}}
/>
) : null}
{isRestoreModalOpen ? (
<RestoreRunModal
runs={selectedRuns}
onCancel={() => {
setIsRestoreModalOpen(false);
setSelectedIds([]);
}}
/>
) : null}
{isDeleteModalOpen && (
<DeletePipelineRunsModal
toDeleteResources={selectedRuns}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,12 @@ const PipelineRunTableRow: React.FC<PipelineRunTableRowProps> = ({
items={actions}
popperProps={{ appendTo: getDashboardMainContainer, position: 'right' }}
/>
<RestoreRunModal
isOpen={isRestoreModalOpen}
runs={[run]}
onCancel={() => setIsRestoreModalOpen(false)}
/>
<ArchiveRunModal
isOpen={isArchiveModalOpen}
runs={[run]}
onCancel={() => setIsArchiveModalOpen(false)}
/>
{isRestoreModalOpen ? (
<RestoreRunModal runs={[run]} onCancel={() => setIsRestoreModalOpen(false)} />
) : null}
{isArchiveModalOpen ? (
<ArchiveRunModal runs={[run]} onCancel={() => setIsArchiveModalOpen(false)} />
) : null}
</Td>
)}
</Tr>
Expand Down
Loading
Loading