Skip to content

Commit

Permalink
Fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
allan-silva committed Jul 30, 2022
1 parent 7da3aa1 commit 094e073
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 31 deletions.
4 changes: 1 addition & 3 deletions ui/src/components/DialogAction/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ function DialogAction(props) {
{body && <DialogContentText component="div">{body}</DialogContentText>}
</DialogContent>
<DialogActions>
<Button
disabled={actionExecuting}
onClick={onClose}>
<Button disabled={actionExecuting} onClick={onClose}>
Cancel
</Button>
<div className={classes.executingActionWrapper}>
Expand Down
16 changes: 12 additions & 4 deletions ui/src/components/EmergencyShutoffCard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const useStyles = makeStyles(theme => ({
},
actionButton: {
minWidth: 'max-content',
}
},
}));

function EmergencyShutoffCard({
Expand Down Expand Up @@ -86,7 +86,7 @@ function EmergencyShutoffCard({
{emergencyShutoff.comment && (
<Typography component="p" className={classes.reason}>
Reason: {emergencyShutoff.comment}
</Typography>
</Typography>
)}

{emergencyShutoff.scheduledChange ? (
Expand All @@ -108,11 +108,19 @@ function EmergencyShutoffCard({
)}
{requiresSignoff &&
(user && user.email in emergencyShutoff.scheduledChange.signoffs ? (
<Button color="secondary" disabled={!user} onClick={onRevoke} className={classes.actionButton}>
<Button
color="secondary"
disabled={!user}
onClick={onRevoke}
className={classes.actionButton}>
Revoke Signoff
</Button>
) : (
<Button color="secondary" disabled={!user} onClick={onSignoff} className={classes.actionButton}>
<Button
color="secondary"
disabled={!user}
onClick={onSignoff}
className={classes.actionButton}>
Signoff
</Button>
))}
Expand Down
57 changes: 33 additions & 24 deletions ui/src/views/Rules/ListRules/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ function ListRules(props) {
const [scrollToRow, setScrollToRow] = useState(null);
const [roles, setRoles] = useState([]);
const [emergencyShutoffs, setEmergencyShutoffs] = useState([]);
const [emergencyShutoffReasonComment, setEmergencyShutoffReasonComment] = useState('');
const [
emergencyShutoffReasonComment,
setEmergencyShutoffReasonComment,
] = useState('');
const [signoffRole, setSignoffRole] = useState('');
const [drawerState, setDrawerState] = useState({ open: false, item: {} });
const [drawerReleaseName, setDrawerReleaseName] = useState(null);
Expand Down Expand Up @@ -738,23 +741,13 @@ function ListRules(props) {
/>
</FormControl>
);

const handleDisableUpdates = async () => {
const [product, channel] = productChannelQueries;
setDialogState({
...dialogState,
open: true,
title: `Disable updates for ${product} : ${channel} ?`,
confirmText: 'Yes',
destructive: false,
mode: 'disableUpdates',
handleSubmit: handleDisableUpdatesSubmit,
});
};

const handleDisableUpdatesSubmit = async () => {
const [product, channel] = productChannelQueries;
const { error, data } = await disableUpdates(product, channel, emergencyShutoffReasonComment);
const { error, data } = await disableUpdates(
product,
channel,
emergencyShutoffReasonComment
);

if (!error) {
const result = clone(emergencyShutoffs);
Expand All @@ -764,12 +757,26 @@ function ListRules(props) {
handleSnackbarOpen({
message: `Updates for the ${product} ${channel} channel have been disabled`,
});
setEmergencyShutoffReasonComment('')
setEmergencyShutoffReasonComment('');
}

handleDialogClose();
};

const handleDisableUpdates = async () => {
const [product, channel] = productChannelQueries;

setDialogState({
...dialogState,
open: true,
title: `Disable updates for ${product} : ${channel} ?`,
confirmText: 'Yes',
destructive: false,
mode: 'disableUpdates',
handleSubmit: handleDisableUpdatesSubmit,
});
};

const handleEnableUpdates = async () => {
const [product, channel] = productChannelQueries;
const esDetails = emergencyShutoffs.find(
Expand Down Expand Up @@ -1033,20 +1040,22 @@ function ListRules(props) {

const getDialogSubmit = () => {
const dialogSubmits = {
'delete': handleDeleteDialogSubmit,
'signoff': handleSignoffDialogSubmit,
'disableUpdates': handleDisableUpdatesSubmit,
'signoffEnableUpdates': handleSignoffEnableUpdatesDialogSubmit,
delete: handleDeleteDialogSubmit,
signoff: handleSignoffDialogSubmit,
disableUpdates: handleDisableUpdatesSubmit,
signoffEnableUpdates: handleSignoffEnableUpdatesDialogSubmit,
};

return dialogSubmits[dialogState.mode];
};

const getDialogBody = () => {
const dialogStates = {
'delete': deleteDialogBody,
'signoff': signoffDialogBody,
'disableUpdates': disableUpdatesBody,
delete: deleteDialogBody,
signoff: signoffDialogBody,
disableUpdates: disableUpdatesBody,
};

return dialogStates[dialogState.mode];
};

Expand Down

0 comments on commit 094e073

Please sign in to comment.