Skip to content

Commit

Permalink
move isCronValid in harvester code base
Browse files Browse the repository at this point in the history
  • Loading branch information
a110605 committed Sep 23, 2024
1 parent 98d5db9 commit 49dd503
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pkg/harvester/edit/harvesterhci.io.schedulevmbackup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Tab from '@shell/components/Tabbed/Tab';
import MessageLink from '@shell/components/MessageLink';
import LabeledSelect from '@shell/components/form/LabeledSelect';
import CreateEditView from '@shell/mixins/create-edit-view';
import { isCronValid } from '@shell/utils/validators/cron-schedule';
import { isCronValid } from '@pkg/harvester/utils/cron';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '@pkg/harvester/config/harvester';
import { allHash } from '@shell/utils/promise';
import { HCI } from '../types';
Expand Down
16 changes: 8 additions & 8 deletions pkg/harvester/l10n/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ harvester:
setDefaultVersion: Set default version
addTemplateVersion: Add template version
backup: Take Backup
createSchedule: Create VM Schedule
createSchedule: Create Schedule
restore: Restore
restoreNewVM: Restore New
resumeSchedule: Resume
Expand Down Expand Up @@ -193,7 +193,7 @@ harvester:
scheduleType: Type
maxFailure: Max Failure
sourceVm: Source VM
vmSchedule: VM Schedule
vmSchedule: Virtual Machine Schedule
hostIp: Host IP
vm:
ipAddress: IP Address
Expand Down Expand Up @@ -808,10 +808,10 @@ harvester:
moreNotes: For more details about the release notes, please visit -

schedule:
label: VM Schedules
createTitle: Create VM Schedule
createButtonText: Create VM Schedule
scheduleType: VM Schedule Type
label: Virtual Machine Schedules
createTitle: Create Schedule
createButtonText: Create Schedule
scheduleType: Virtual Machine Schedule Type
cron: Cron Schedule
detail:
namespace: Namespace
Expand Down Expand Up @@ -1495,8 +1495,8 @@ typeLabel:
}
harvesterhci.io.schedulevmbackup: |-
{count, plural,
one { VM Schedule }
other { VM Schedules }
one { Virtual Machine Schedule }
other { Virtual Machine Schedules }
}
harvesterhci.io.virtualmachinebackup: |-
{count, plural,
Expand Down
2 changes: 1 addition & 1 deletion pkg/harvester/list/harvesterhci.io.schedulevmbackup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default {
:schema="schema"
:resource="resource"
:type-display="typeDisplay"
:parentNameOverride="'VM schedule'"
:parentNameOverride="'Virtual Machine schedule'"
:create-button-label="t('harvester.schedule.createButtonText')"
/>
<ResourceTable
Expand Down
11 changes: 11 additions & 0 deletions pkg/harvester/utils/cron.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import cronstrue from 'cronstrue';

export function isCronValid(schedule = '') {
try {
const hint = cronstrue.toString(schedule);

return !!hint;
} catch (e) {
return false;
}
}
10 changes: 0 additions & 10 deletions shell/utils/validators/cron-schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,3 @@ export function cronSchedule(schedule = '', getters, errors) {
errors.push(getters['i18n/t']('validation.invalidCron'));
}
}

export function isCronValid(schedule = '') {
try {
const hint = cronstrue.toString(schedule);

return !!hint;
} catch (e) {
return false;
}
}

0 comments on commit 49dd503

Please sign in to comment.