Files
ServerKit/frontend/src/components/backups/AddScheduleModal.jsx
T
Juan Denis 16837621f6 Use one term per concept across the UI
Applies the copy glossary to about 370 strings and 64 call sites:
service (not app/application/site), sign in/out (not log in/out),
server and panel server (not box/machine/host), Delete destroys /
Remove detaches / Uninstall is for software, New opens a form and
Create submits it, settings, backup vs snapshot vs restore point,
extensions and Features, environment variables, compose project,
two-factor authentication. Confirm dialogs that destroy something now
use the same verb on the title and the button instead of "Confirm".

Backend messages that reach toasts verbatim ("Application not
found" x95 and others) are listed in plan 88 for the typed-error
work rather than edited here.
2026-10-04 04:48:33 -04:00

70 lines
4.5 KiB
React

import { useTranslation } from 'react-i18next';
import Modal from '@/components/Modal';
import { FormField } from '@/components/FormField';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Select, SelectTrigger, SelectContent, SelectItem, SelectValue } from '@/components/ui/select';
import useForm from '@/hooks/useForm';
export default function AddScheduleModal({ open, onClose, onCreate, onCreated, remoteEnabled, timezone }) {
const { t } = useTranslation();
const form = useForm({
initialValues: { name: '', backupType: 'application', target: '', scheduleTime: '02:00', days: ['daily'], uploadRemote: false },
onSubmit: async (values) => {
await onCreate(values);
form.reset();
onCreated();
},
});
const targetLabel = form.values.backupType === 'files'
? t('app.backups.schedulePaths', 'Paths (comma-separated)')
: form.values.backupType === 'database'
? t('app.backups.scheduleDatabase', 'Database (format: mysql:dbname or postgresql:dbname)')
: t('app.backups.applicationName', 'Service name');
return (
<Modal open={open} onClose={() => { if (!form.isSubmitting) onClose(); }} title={t('app.backups.addBackupSchedule', 'New backup schedule')}>
<form onSubmit={form.handleSubmit} data-walkthrough="backup-schedule-form">
{form.submitError && <p className="error-message" role="alert">{form.submitError}</p>}
<FormField htmlFor="backup-schedule-name" label={t('app.backups.scheduleName', 'Schedule name')} error={form.getFieldError('name')} required>
<Input id="backup-schedule-name" type="text" {...form.getFieldProps('name')} placeholder={t('app.backups.dailyAppBackup', 'Daily service backup')} required />
</FormField>
<FormField htmlFor="backup-schedule-type" label={t('app.backups.backupType', 'Backup type')} error={form.getFieldError('backupType')}>
<Select
name="backupType"
value={form.values.backupType}
onValueChange={(value) => form.setValue('backupType', value, { touch: true })}
>
<SelectTrigger id="backup-schedule-type" aria-invalid={Boolean(form.getFieldError('backupType'))}>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="application">{t('app.backups.application', 'Service')}</SelectItem>
<SelectItem value="database">{t('app.backups.database', 'Database')}</SelectItem>
<SelectItem value="files">{t('app.backups.filesDirectories', 'Files / directories')}</SelectItem>
</SelectContent>
</Select>
</FormField>
<FormField htmlFor="backup-schedule-target" label={targetLabel} error={form.getFieldError('target')} required>
<Input id="backup-schedule-target" type="text" {...form.getFieldProps('target')} placeholder={form.values.backupType === 'files' ? '/etc/nginx,/var/www/config' : form.values.backupType === 'database' ? 'mysql:mydb' : 'my-app'} required />
</FormField>
<FormField htmlFor="backup-schedule-time" label={t('common.labels.time', 'Time')} error={form.getFieldError('scheduleTime')} hint={timezone} required>
<Input id="backup-schedule-time" type="time" {...form.getFieldProps('scheduleTime')} required />
</FormField>
{remoteEnabled && (
<FormField>
<label className="checkbox-label">
<input type="checkbox" name="uploadRemote" checked={form.values.uploadRemote} onChange={form.handleChange} />
<span>{t('app.backups.uploadToRemoteStorageAfterBackup', 'Upload to remote storage after backup')}</span>
</label>
</FormField>
)}
<div className="modal-actions">
<Button type="button" variant="outline" onClick={onClose} disabled={form.isSubmitting}>{t('common.actions.cancel', 'Cancel')}</Button>
<Button type="submit" disabled={form.isSubmitting} data-walkthrough="backup-schedule-submit">{t('app.backups.addSchedule', 'Create schedule')}</Button>
</div>
</form>
</Modal>
);
}