Skip to content

Commit

Permalink
Merge branch 'v1.7' of https://github.com/microsoft/DLWorkspace into …
Browse files Browse the repository at this point in the history
…xiaxiao/updateWording
  • Loading branch information
Xia Xiao committed Aug 31, 2020
2 parents 660b82d + 3d21b02 commit 4acd74e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/dashboard/src/hooks/useActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ ${givenName} ${familyName}
const onUpdateExemption = useCallback((event: any, job: any, isExempted: boolean) => {
const title = `${job.jobName}(${job.jobId})`;
const actionName = isExempted ? "Enable" : "Disable";
return confirm(`${actionName} idle GPU timeout policy exemption for job ${title} ?`).then((answer) => {
const confirmMessage = createElement("div", null, [`${actionName} idle GPU timeout policy exemption for job `, createElement("b", null, job.jobName), `(${job.jobId}) ?`]);

return confirm(confirmMessage).then((answer) => {
if (answer === false) return;
enqueueSnackbar(`${title}'s exemption is being updated.`);
return updateException(job.jobId, isExempted).then((response) => {
Expand Down
7 changes: 4 additions & 3 deletions src/dashboard/src/hooks/useConfirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import {
FunctionComponent,
createContext,
ReactNode,
useCallback,
useContext,
useState
Expand All @@ -16,7 +17,7 @@ import {
} from '@material-ui/core';

interface ConfirmContext {
setMessage: (message: string) => void;
setMessage: (message: string | ReactNode) => void;
setOpen: (open: boolean) => void;
setResolve: (resolve: (value: boolean) => void) => void;
}
Expand All @@ -28,7 +29,7 @@ const ConfirmContext = createContext<ConfirmContext>({
});

const ConfirmProvider: FunctionComponent = ({ children }) => {
const [message, setMessage] = useState<string>();
const [message, setMessage] = useState<string | ReactNode>();
const [open, setOpen] = useState(false);
const [resolve, setResolve] = useState<(value: boolean) => void>();

Expand Down Expand Up @@ -63,7 +64,7 @@ const ConfirmProvider: FunctionComponent = ({ children }) => {

const useConfirm = () => {
const { setMessage, setOpen, setResolve } = useContext(ConfirmContext);
const confirm = useCallback((message: string) => {
const confirm = useCallback((message: string | ReactNode) => {
setMessage(message);
setOpen(true);
return new Promise<boolean>((resolve) => {
Expand Down

0 comments on commit 4acd74e

Please sign in to comment.