Skip to content
Open
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
15 changes: 6 additions & 9 deletions src/components/dialogs/limits/limits-pane-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,8 @@ const temporaryLimitsValidationSchema = () => {
return yup.object().shape({
[TEMPORARY_LIMIT_DURATION]: yup.number().nullable().min(0),
[TEMPORARY_LIMIT_VALUE]: yup.number().nullable().positive(),
[TEMPORARY_LIMIT_NAME]: yup
.string()
.nullable()
.when([TEMPORARY_LIMIT_VALUE, TEMPORARY_LIMIT_DURATION], {
is: (limitValue: number | null, limitDuration: number | null) => limitValue || limitDuration,
then: () => yup.string().nullable().required(),
}),
[TEMPORARY_LIMIT_NAME]: yup.string().nullable().required(),
[DELETION_MARK]: yup.boolean(),
});
};

Expand All @@ -75,9 +70,11 @@ const currentLimitsValidationSchema = (isModification = false) => ({
.array()
.of(temporaryLimitsValidationSchema())
.test('distinctNames', 'TemporaryLimitNameUnicityError', (array) => {
const namesArray = !array
const namesArray: (string | null)[] = !array
? []
: array.filter((l) => !!l[TEMPORARY_LIMIT_NAME]).map((l) => sanitizeString(l[TEMPORARY_LIMIT_NAME]));
: array
.filter((l: TemporaryLimitFormInfos) => !!l[TEMPORARY_LIMIT_NAME] && !l[DELETION_MARK])
.map((l) => sanitizeString(l[TEMPORARY_LIMIT_NAME]));
return areArrayElementsUnique(namesArray);
})
.test('distinctDurations', 'TemporaryLimitDurationUnicityError', (array) => {
Expand Down
6 changes: 5 additions & 1 deletion src/components/dialogs/limits/temporary-limits-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ function TemporaryLimitsTable({
);

const renderTableRow = (rowId: string, index: number) => (
<TableRow onMouseEnter={() => setHoveredRowIndex(index)} onMouseLeave={() => setHoveredRowIndex(-1)}>
<TableRow
key={'row' + rowId}
onMouseEnter={() => setHoveredRowIndex(index)}
onMouseLeave={() => setHoveredRowIndex(-1)}
>
{columnsDefinition.map((column) => renderTableCell(rowId, index, column))}
<TableCell key={rowId + 'delete'}>
<IconButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export interface CurrentLimitsFormInfos {

export interface TemporaryLimitFormInfos {
[TEMPORARY_LIMIT_NAME]: string;
[TEMPORARY_LIMIT_DURATION]: number | null;
[TEMPORARY_LIMIT_VALUE]: number | null;
[DELETION_MARK]: boolean;
[TEMPORARY_LIMIT_DURATION]?: number | null;
[TEMPORARY_LIMIT_VALUE]?: number | null;
[DELETION_MARK]?: boolean;
}
4 changes: 2 additions & 2 deletions src/services/network-modification-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ export interface OperationalLimitsGroup {

export interface Limit {
name: string;
acceptableDuration: number | null;
value: number | null;
acceptableDuration?: number | null;
value?: number | null;
}

export interface TemporaryLimit extends Limit {
Expand Down
Loading