Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ const ApplicationFormManualV0: FC<ApplicationFormProps> = ({

const classes = useStyles();
const ps = useAppSelector((state) => selectAllPipeds(state));
const pipeds = ps
.filter((piped) => !piped.disabled)
const pipedOptions = ps
.filter((piped) => !piped.disabled || piped.id === detailApp?.pipedId)
.sort((a, b) => sortFunc(a.name, b.name));

const selectedPiped = useAppSelector(selectPipedById(values.pipedId));
Expand Down Expand Up @@ -278,12 +278,13 @@ const ApplicationFormManualV0: FC<ApplicationFormProps> = ({
pipedId: value,
});
}}
options={pipeds.map((piped) => ({
options={pipedOptions.map((piped) => ({
label: `${piped.name} (${piped.id})`,
value: piped.id,
disabled: piped.disabled,
}))}
required
disabled={isSubmitting || pipeds.length === 0}
disabled={isSubmitting || pipedOptions.length === 0}
/>
<FormSelectInput
id="platformProvider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ const ApplicationFormManualV1: FC<ApplicationFormProps> = ({

const classes = useStyles();
const ps = useAppSelector((state) => selectAllPipeds(state));
const pipeds = ps
.filter((piped) => !piped.disabled)
const pipedOptions = ps
.filter((piped) => !piped.disabled || piped.id === detailApp?.pipedId)
.sort((a, b) => sortFunc(a.name, b.name));

const selectedPiped = useAppSelector(selectPipedById(values.pipedId));
Expand Down Expand Up @@ -259,12 +259,13 @@ const ApplicationFormManualV1: FC<ApplicationFormProps> = ({
pipedId: value,
});
}}
options={pipeds.map((piped) => ({
options={pipedOptions.map((piped) => ({
label: `${piped.name} (${piped.id})`,
value: piped.id,
disabled: piped.disabled,
}))}
required
disabled={isSubmitting || pipeds.length === 0}
disabled={isSubmitting || pipedOptions.length === 0}
/>

<FormControl variant="outlined">
Expand All @@ -275,7 +276,7 @@ const ApplicationFormManualV1: FC<ApplicationFormProps> = ({
value={values.deployTargets.map(
(item) => `${item.deployTarget} - ${item.pluginName}`
)}
disabled={isSubmitting || pipeds.length === 0}
disabled={isSubmitting || pipedOptions.length === 0}
onChange={(_e, value) => {
const selected = deployTargetOptions.filter((item) =>
value.includes(item.value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ const ApplicationFormSuggestionV1: FC<Props> = ({
[apps, selectedPipedId]
);

const pipeds = useMemo(() => {
return ps.sort((a, b) => sortFunc(a.name, b.name));
const pipedOptions = useMemo(() => {
return ps
.filter((piped) => !piped.disabled)
.sort((a, b) => sortFunc(a.name, b.name));
}, [ps]);

/**
Expand All @@ -171,10 +173,10 @@ const ApplicationFormSuggestionV1: FC<Props> = ({
* Init selectedPipedId if there is only one piped
*/
useEffect(() => {
if (pipeds.length === 1 && !selectedApp) {
setSelectedPipedId(pipeds[0].id);
if (pipedOptions.length === 1 && !selectedApp) {
setSelectedPipedId(pipedOptions[0].id);
}
}, [pipeds, selectedApp]);
}, [pipedOptions, selectedApp]);

/**
* Init selectedApp if there is only one app
Expand Down Expand Up @@ -249,7 +251,7 @@ const ApplicationFormSuggestionV1: FC<Props> = ({
onSelectPiped(e.target.value as string);
}}
>
{pipeds.map((e) => (
{pipedOptions.map((e) => (
<MenuItem value={e.id} key={`piped-${e.id}`}>
{e.name} ({e.id})
</MenuItem>
Expand Down
6 changes: 5 additions & 1 deletion web/src/components/form-select-input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ const FormSelectInput = <T extends BaseOption>({
disabled={disabled}
>
{options.map((op) => (
<MenuItem value={String(op.value)} key={String(op.value)}>
<MenuItem
value={String(op.value)}
key={String(op.value)}
disabled={!!op?.disabled}
>
{getOptionLabel(op)}
</MenuItem>
))}
Expand Down