mirror of
https://github.com/abhinavxd/libredesk.git
synced 2025-10-23 05:11:57 +00:00
Allow setting any value for SLA delay duration, replace select with input text
Validations to delay duration
This commit is contained in:
10
cmd/sla.go
10
cmd/sla.go
@@ -129,6 +129,14 @@ func validateSLA(app *App, sla *smodels.SLAPolicy) error {
|
||||
if n.TimeDelay == "" {
|
||||
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "`time_delay`"), nil)
|
||||
}
|
||||
// Validate time delay duration.
|
||||
td, err := time.ParseDuration(n.TimeDelay)
|
||||
if err != nil {
|
||||
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.invalid", "name", "`time_delay`"), nil)
|
||||
}
|
||||
if td.Minutes() < 1 {
|
||||
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.invalid", "name", "`time_delay`"), nil)
|
||||
}
|
||||
}
|
||||
if len(n.Recipients) == 0 {
|
||||
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "`recipients`"), nil)
|
||||
@@ -170,7 +178,7 @@ func validateSLA(app *App, sla *smodels.SLAPolicy) error {
|
||||
if err != nil {
|
||||
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.invalid", "name", "`next_response_time`"), nil)
|
||||
}
|
||||
if nrt.Seconds() < 1 {
|
||||
if nrt.Minutes() < 1 {
|
||||
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.invalid", "name", "`next_response_time`"), nil)
|
||||
}
|
||||
}
|
||||
|
@@ -172,22 +172,14 @@
|
||||
}}
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<Select v-bind="componentField">
|
||||
<SelectTrigger class="w-full">
|
||||
<SelectValue :placeholder="t('admin.sla.selectDuration')" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectItem
|
||||
v-for="duration in delayDurations"
|
||||
:key="duration"
|
||||
:value="duration"
|
||||
>
|
||||
{{ duration }}
|
||||
</SelectItem>
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Input
|
||||
type="text"
|
||||
:placeholder="t('globals.messages.enter', {
|
||||
name: t('globals.terms.duration').toLowerCase()
|
||||
})"
|
||||
v-bind="componentField"
|
||||
@keydown.enter.prevent
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@@ -341,25 +333,6 @@ const submitLabel = computed(() => {
|
||||
(props.initialValues.id ? t('globals.buttons.update') : t('globals.buttons.create'))
|
||||
)
|
||||
})
|
||||
const delayDurations = [
|
||||
'5m',
|
||||
'10m',
|
||||
'15m',
|
||||
'30m',
|
||||
'45m',
|
||||
'1h',
|
||||
'2h',
|
||||
'3h',
|
||||
'4h',
|
||||
'5h',
|
||||
'6h',
|
||||
'7h',
|
||||
'8h',
|
||||
'9h',
|
||||
'10h',
|
||||
'11h',
|
||||
'12h'
|
||||
]
|
||||
|
||||
const { t } = useI18n()
|
||||
const form = useForm({
|
||||
|
@@ -27,7 +27,9 @@ export const createFormSchema = (t) =>
|
||||
.object({
|
||||
type: z.enum(['breach', 'warning']),
|
||||
time_delay_type: z.enum(['immediately', 'after', 'before']),
|
||||
time_delay: z.string().optional(),
|
||||
time_delay: z.string().optional().refine(val => isGoHourMinuteDuration(val), {
|
||||
message: t('globals.messages.goHourMinuteDuration'),
|
||||
}),
|
||||
metric: z.enum(['first_response', 'resolution', 'next_response', 'all']),
|
||||
recipients: z
|
||||
.array(z.string())
|
||||
|
@@ -82,6 +82,7 @@
|
||||
"globals.terms.note": "Note | Notes",
|
||||
"globals.terms.ipAddress": "IP Address | IP Addresses",
|
||||
"globals.terms.alert": "Alert | Alerts",
|
||||
"globals.terms.duration": "Duration | Durations",
|
||||
"globals.messages.badRequest": "Bad request",
|
||||
"globals.messages.adjustFilters": "Try adjusting filters",
|
||||
"globals.messages.errorUpdating": "Error updating {name}",
|
||||
@@ -122,6 +123,7 @@
|
||||
"globals.messages.add": "Add {name}",
|
||||
"globals.messages.denied": "{name} denied",
|
||||
"globals.messages.noResults": "No {name} found",
|
||||
"globals.messages.enter": "Enter {name}",
|
||||
"globals.messages.yes": "Yes",
|
||||
"globals.messages.no": "No",
|
||||
"globals.messages.typeOf": "Type of {name}",
|
||||
@@ -397,7 +399,6 @@
|
||||
"admin.sla.triggerTiming": "Trigger timing",
|
||||
"admin.sla.immediatelyOnBreach": "Immediately on breach",
|
||||
"admin.sla.afterSpecificDuration": "After specific duration",
|
||||
"admin.sla.selectDuration": "Select duration...",
|
||||
"admin.sla.advanceWarning": "Advance warning",
|
||||
"admin.sla.followUpDelay": "Follow up delay",
|
||||
"admin.sla.alertRecipients": "Alert recipients",
|
||||
|
Reference in New Issue
Block a user