Skip to content

Commit

Permalink
add character limit for pipeline run name
Browse files Browse the repository at this point in the history
  • Loading branch information
ppadti committed Jun 11, 2024
1 parent 2b19ddb commit 6cb4663
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions frontend/src/concepts/k8s/NameDescriptionField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type NameDescriptionFieldProps = {
autoFocusName?: boolean;
showK8sName?: boolean;
disableK8sName?: boolean;
maxLength?: number;
};

const NameDescriptionField: React.FC<NameDescriptionFieldProps> = ({
Expand All @@ -32,6 +33,7 @@ const NameDescriptionField: React.FC<NameDescriptionFieldProps> = ({
autoFocusName,
showK8sName,
disableK8sName,
maxLength,
}) => {
const autoSelectNameRef = React.useRef<HTMLInputElement | null>(null);

Expand Down Expand Up @@ -61,7 +63,13 @@ const NameDescriptionField: React.FC<NameDescriptionFieldProps> = ({
name={nameFieldId}
value={data.name}
onChange={(e, name) => setData({ ...data, name })}
maxLength={maxLength}
/>
{maxLength && (
<HelperText>
<HelperTextItem>{`Cannot exceed ${maxLength} characters`}</HelperTextItem>
</HelperText>
)}
</FormGroup>
</StackItem>
{showK8sName && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { PipelineRunType } from '~/pages/pipelines/global/runs';
import ProjectAndExperimentSection from '~/concepts/pipelines/content/createRun/contentSections/ProjectAndExperimentSection';
import PipelineSection from './contentSections/PipelineSection';
import { RunTypeSection } from './contentSections/RunTypeSection';
import { CreateRunPageSections, runPageSectionTitles } from './const';
import { CreateRunPageSections, RUN_NAME_CHARACTER_LIMIT, runPageSectionTitles } from './const';
import { getInputDefinitionParams } from './utils';

type RunFormProps = {
Expand Down Expand Up @@ -72,6 +72,7 @@ const RunForm: React.FC<RunFormProps> = ({ data, runType, onValueChange }) => {
descriptionFieldId="run-description"
data={data.nameDesc}
setData={(nameDesc) => onValueChange('nameDesc', nameDesc)}
maxLength={RUN_NAME_CHARACTER_LIMIT}
/>

{isSchedule && data.runType.type === RunTypeOption.SCHEDULED && (
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/concepts/pipelines/content/createRun/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ export const runPageSectionTitles: Record<CreateRunPageSections, string> = {
[CreateRunPageSections.PIPELINE]: 'Pipeline',
[CreateRunPageSections.PARAMS]: 'Parameters',
};

export const RUN_NAME_CHARACTER_LIMIT = 255;

0 comments on commit 6cb4663

Please sign in to comment.