Skip to content

Commit

Permalink
Merge pull request #125 from CybercentreCanada/persistent-service-update
Browse files Browse the repository at this point in the history
Persistent service update
  • Loading branch information
cccs-rs authored Sep 17, 2021
2 parents 6a17e25 + 1d2bdee commit 8e69ef5
Showing 1 changed file with 13 additions and 54 deletions.
67 changes: 13 additions & 54 deletions src/components/routes/admin/service_detail/updater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import 'moment/locale/fr';
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { ServiceDetail } from '../service_detail';
import ContainerCard from './container_card';
import SourceDialog from './source_dialog';

type ServiceUpdaterProps = {
Expand All @@ -35,16 +34,6 @@ const ServiceUpdater = ({ service, setService, setModified }: ServiceUpdaterProp
const [editedSourceID, setEditedSourceID] = useState(-1);
const theme = useTheme();

const handleMethodChange = event => {
setModified(true);
setService({ ...service, update_config: { ...service.update_config, method: event.target.value } });
};

const handleUpdateContainerChange = newContainer => {
setModified(true);
setService({ ...service, update_config: { ...service.update_config, run_options: newContainer } });
};

const toggleSignatures = () => {
setModified(true);
setService({
Expand Down Expand Up @@ -112,24 +101,19 @@ const ServiceUpdater = ({ service, setService, setModified }: ServiceUpdaterProp
<Grid item xs={12}>
<Typography variant="h6">{t('updater')}</Typography>
</Grid>
<Grid item xs={12} sm={6}>
<Typography variant="subtitle2">{t('updater.method')}</Typography>
{service ? (
<Select
id="channel"
fullWidth
value={service.update_config.method}
onChange={handleMethodChange}
variant="outlined"
margin="dense"
style={{ marginTop: theme.spacing(1), marginBottom: theme.spacing(0.5) }}
>
<MenuItem value="run">{t('updater.method.run')}</MenuItem>
{/* <MenuItem value="build">{t('updater.method.build')}</MenuItem> */}
</Select>
) : (
<Skeleton style={{ height: '2.5rem' }} />
)}
<Grid item xs={12} sm={3}>
<Typography variant="subtitle2">{t('updater.signatures')}</Typography>
<RadioGroup value={service.update_config.generates_signatures} onChange={toggleSignatures}>
<FormControlLabel value control={<Radio />} label={t('updater.signatures.yes')} />
<FormControlLabel value={false} control={<Radio />} label={t('updater.signatures.no')} />
</RadioGroup>
</Grid>
<Grid item xs={12} sm={3}>
<Typography variant="subtitle2">{t('updater.wait')}</Typography>
<RadioGroup value={service.update_config.wait_for_update} onChange={toggleWaitForUpdate}>
<FormControlLabel value control={<Radio />} label={t('updater.wait.yes')} />
<FormControlLabel value={false} control={<Radio />} label={t('updater.wait.no')} />
</RadioGroup>
</Grid>
<Grid item xs={12} sm={6}>
<Typography variant="subtitle2">{t('updater.interval')}</Typography>
Expand All @@ -147,31 +131,6 @@ const ServiceUpdater = ({ service, setService, setModified }: ServiceUpdaterProp
<Skeleton style={{ height: '2.5rem' }} />
)}
</Grid>
<Grid item xs={12}>
<Typography variant="subtitle2">{t('updater.run.options')}</Typography>
{service ? (
service.update_config.method === 'run' && (
<ContainerCard container={service.update_config.run_options} onChange={handleUpdateContainerChange} />
)
) : (
<Skeleton style={{ height: '8rem' }} />
)}
</Grid>
<Grid item xs={12} sm={6}>
<Typography variant="subtitle2">{t('updater.signatures')}</Typography>
<RadioGroup value={service.update_config.generates_signatures} onChange={toggleSignatures}>
<FormControlLabel value control={<Radio />} label={t('updater.signatures.yes')} />
<FormControlLabel value={false} control={<Radio />} label={t('updater.signatures.no')} />
</RadioGroup>
</Grid>
<Grid item xs={12} sm={6}>
<Typography variant="subtitle2">{t('updater.wait')}</Typography>
<RadioGroup value={service.update_config.wait_for_update} onChange={toggleWaitForUpdate}>
<FormControlLabel value control={<Radio />} label={t('updater.wait.yes')} />
<FormControlLabel value={false} control={<Radio />} label={t('updater.wait.no')} />
</RadioGroup>
</Grid>

<Grid item xs={12}>
<Typography variant="subtitle2">{t('updater.sources')}</Typography>
<SourceDialog
Expand Down

0 comments on commit 8e69ef5

Please sign in to comment.