Skip to content

Commit

Permalink
fix(pci.databases): fixing namespaces edition and creation form
Browse files Browse the repository at this point in the history
ref:DATATR-1556
Signed-off-by: Arthur Bullet <[email protected]>
  • Loading branch information
abullet33 committed Oct 18, 2024
1 parent 3aea5b6 commit 70828b8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router';
import { useEffect, useState } from 'react';

import { ChevronDown, ChevronRight, HelpCircle } from 'lucide-react';
import { useParams } from 'react-router-dom';
import { Button } from '@/components/ui/button';
import {
Dialog,
Expand Down Expand Up @@ -156,7 +156,9 @@ const AddEditNamespace = ({
retention: retentionFormValues,
snapshotEnabled: formValues.snapshotEnabled,
writesToCommitLogEnabled: formValues.writesToCommitLogEnabled,
resolution: convertDurationStringToISODuration(formValues.resolution),
resolution: formValues.resolution
? convertDurationStringToISODuration(formValues.resolution)
: null,
},
});
} else {
Expand All @@ -170,7 +172,9 @@ const AddEditNamespace = ({
namespace: {
name: formValues.name,
retention: retentionFormValues,
resolution: convertDurationStringToISODuration(formValues.resolution),
resolution: formValues.resolution
? convertDurationStringToISODuration(formValues.resolution)
: null,
type: formValues.type,
snapshotEnabled: formValues.snapshotEnabled,
writesToCommitLogEnabled: formValues.writesToCommitLogEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,33 @@ export const useNamespaceForm = ({

const typeRules = z.nativeEnum(database.m3db.namespace.TypeEnum);

const schema = z.object({
name: nameRules,
resolution: mandatoryShortTimeRules,
blockDataExpirationDuration: optionalShortTimeRules,
blockSizeDuration: optionalShortTimeRules,
bufferFutureDuration: optionalShortTimeRules,
bufferPastDuration: optionalShortTimeRules,
periodDuration: mandatoryShortTimeRules,
snapshotEnabled: z.boolean().optional(),
type: typeRules,
writesToCommitLogEnabled: z.boolean().optional(),
});
const schema = z
.object({
name: nameRules,
periodDuration: mandatoryShortTimeRules,
resolution: optionalShortTimeRules,
blockDataExpirationDuration: optionalShortTimeRules,
blockSizeDuration: optionalShortTimeRules,
bufferFutureDuration: optionalShortTimeRules,
bufferPastDuration: optionalShortTimeRules,
snapshotEnabled: z.boolean().optional(),
type: typeRules,
writesToCommitLogEnabled: z.boolean().optional(),
})
.superRefine((values, context) => {
if (
values.type === database.m3db.namespace.TypeEnum.aggregated &&
!values.resolution
) {
context.addIssue({
code: z.ZodIssueCode.custom,
message: t('formNamespaceErrorMinLength', {
min: NAMESPACES_CONFIG.name.min,
}),
path: ['resolution'],
});
}
});

type ValidationSchema = z.infer<typeof schema>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface NamespaceCreation {
/** Name of the namespace */
name: string;
/** Resolution for an aggregated namespace */
resolution: string;
resolution?: string;
/** Retention configuration */
retention: Retention;
/** Defines whether M3db will create snapshot files for this namespace */
Expand Down

0 comments on commit 70828b8

Please sign in to comment.