Skip to content

Commit

Permalink
Merge pull request #2571 from Gkrumbach07/experiment-section-hide
Browse files Browse the repository at this point in the history
Add useIsAreaAvailable hook to check if experiments are available and hide jump to section
  • Loading branch information
openshift-merge-bot[bot] authored Mar 7, 2024
2 parents 3b57e11 + 04ae1b1 commit 2859b99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions frontend/src/concepts/pipelines/content/createRun/RunPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { useGetSearchParamValues } from '~/utilities/useGetSearchParamValues';
import { PipelineRunSearchParam } from '~/concepts/pipelines/content/types';
import { PipelineRunType } from '~/pages/pipelines/global/runs';
import useExperimentById from '~/concepts/pipelines/apiHooks/useExperimentById';
import { useIsAreaAvailable, SupportedArea } from '~/concepts/areas';

type RunPageProps = {
cloneRun?: PipelineRunKFv2 | PipelineRunJobKFv2 | null;
Expand All @@ -48,6 +49,14 @@ const RunPage: React.FC<RunPageProps> = ({ cloneRun, contextPath, testId }) => {
const [cloneRunPipeline] = usePipelineById(cloneRunPipelineId);
const [cloneRunExperiment] = useExperimentById(cloneRunExperimentId);

const isExperimentsAvailable = useIsAreaAvailable(SupportedArea.PIPELINE_EXPERIMENTS).status;

const sections = isExperimentsAvailable
? Object.values(CreateRunPageSections)
: Object.values(CreateRunPageSections).filter(
(section) => section !== CreateRunPageSections.EXPERIMENT,
);

const [formData, setFormDataValue] = useRunFormData(cloneRun, {
runType: {
...(runType === PipelineRunType.Scheduled
Expand All @@ -73,11 +82,7 @@ const RunPage: React.FC<RunPageProps> = ({ cloneRun, contextPath, testId }) => {
return (
<div data-testid={testId}>
<PageSection isFilled variant="light">
<GenericSidebar
sections={Object.values(CreateRunPageSections)}
titles={runPageSectionTitles}
maxWidth={175}
>
<GenericSidebar sections={sections} titles={runPageSectionTitles} maxWidth={175}>
<RunForm
data={formData}
runType={runType as PipelineRunType}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/concepts/pipelines/content/createRun/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ export const RUN_OPTION_LABEL_SIZE = 100;

export enum CreateRunPageSections {
NAME_DESC = 'run-section-name-desc',
EXPERIMENT = 'run-section-experiment',
PIPELINE = 'run-section-pipeline',
PIPELINE_VERSION = 'run-section-pipeline-version',
EXPERIMENT = 'run-section-experiment',
PARAMS = 'run-section-params',
}

export const runPageSectionTitles: Record<CreateRunPageSections, string> = {
[CreateRunPageSections.NAME_DESC]: 'Name and description',
[CreateRunPageSections.EXPERIMENT]: 'Experiment',
[CreateRunPageSections.PIPELINE]: 'Pipeline',
[CreateRunPageSections.PIPELINE_VERSION]: 'Pipeline version',
[CreateRunPageSections.EXPERIMENT]: 'Experiment',
[CreateRunPageSections.PARAMS]: 'Pipeline input parameters',
};

0 comments on commit 2859b99

Please sign in to comment.