fix(striker-ui): make optimize for OS required

main
Tsu-ba-me 3 years ago
parent befe5ec4b5
commit 75606eb9a0
  1. 31
      striker-ui/components/ProvisionServerDialog.tsx
  2. 2
      striker-ui/lib/test_input/testNotBlank.ts
  3. 2
      striker-ui/lib/test_input/testRange.ts
  4. 2
      striker-ui/types/TestInputFunction.ts

@ -1031,6 +1031,9 @@ const ProvisionServerDialog = ({
const [inputOptimizeForOSValue, setInputOptimizeForOSValue] = const [inputOptimizeForOSValue, setInputOptimizeForOSValue] =
useState<OSAutoCompleteOption | null>(null); useState<OSAutoCompleteOption | null>(null);
const [inputOptimizeForOSMessage, setInputOptimizeForOSMessage] = useState<
InputMessage | undefined
>();
const [includeAnvilUUIDs, setIncludeAnvilUUIDs] = useState<string[]>([]); const [includeAnvilUUIDs, setIncludeAnvilUUIDs] = useState<string[]>([]);
const [includeFileUUIDs, setIncludeFileUUIDs] = useState<string[]>([]); const [includeFileUUIDs, setIncludeFileUUIDs] = useState<string[]>([]);
@ -1139,11 +1142,7 @@ const ProvisionServerDialog = ({
}, },
value: inputInstallISOFileUUID, value: inputInstallISOFileUUID,
}, },
tests: [ tests: [{ test: testNotBlank }],
{
test: testNotBlank,
},
],
}, },
anvil: { anvil: {
defaults: { defaults: {
@ -1154,11 +1153,18 @@ const ProvisionServerDialog = ({
}, },
value: inputAnvilValue, value: inputAnvilValue,
}, },
tests: [ tests: [{ test: testNotBlank }],
{ },
test: testNotBlank, optimizeForOS: {
defaults: {
max: 0,
min: 0,
onSuccess: () => {
setInputOptimizeForOSMessage(undefined);
}, },
], value: inputOptimizeForOSValue?.key,
},
tests: [{ test: testNotBlank }],
}, },
}; };
virtualDisks.inputSizeMessages.forEach((message, vdIndex) => { virtualDisks.inputSizeMessages.forEach((message, vdIndex) => {
@ -1208,11 +1214,7 @@ const ProvisionServerDialog = ({
onFinishBatch: () => { onFinishBatch: () => {
setVirtualDisks({ ...virtualDisks }); setVirtualDisks({ ...virtualDisks });
}, },
tests: [ tests: [{ test: testNotBlank }],
{
test: testNotBlank,
},
],
}; };
}); });
@ -1577,6 +1579,7 @@ const ProvisionServerDialog = ({
inputLabelProps.isNotifyRequired = inputOptimizeForOSValue === null; inputLabelProps.isNotifyRequired = inputOptimizeForOSValue === null;
}} }}
label="Optimize for OS" label="Optimize for OS"
messageBoxProps={inputOptimizeForOSMessage}
noOptionsText="No matching OS" noOptionsText="No matching OS"
onChange={(event, value) => { onChange={(event, value) => {
setInputOptimizeForOSValue(value); setInputOptimizeForOSValue(value);

@ -1,6 +1,6 @@
import { InputTestArgs } from '../../types/TestInputFunction'; import { InputTestArgs } from '../../types/TestInputFunction';
const testNotBlank: (args: InputTestArgs) => boolean = ({ value }) => const testNotBlank: (args: InputTestArgs) => boolean = ({ value }) =>
value !== ''; value ? String(value).length > 0 : false;
export default testNotBlank; export default testNotBlank;

@ -1,6 +1,6 @@
import { InputTestArgs } from '../../types/TestInputFunction'; import { InputTestArgs } from '../../types/TestInputFunction';
const testRange: (args: InputTestArgs) => boolean = ({ max, min, value }) => const testRange: (args: InputTestArgs) => boolean = ({ max, min, value }) =>
value >= min && value <= max; value ? value >= min && value <= max : false;
export default testRange; export default testRange;

@ -1,7 +1,7 @@
export type InputTestArgs = { export type InputTestArgs = {
max: bigint | number; max: bigint | number;
min: bigint | number; min: bigint | number;
value: bigint | number | string; value?: bigint | number | null | string;
}; };
export type InputTest = { export type InputTest = {

Loading…
Cancel
Save