Loading frontend/src/dashboard/ExerciseSelector/ImportDialog.tsx +6 −17 Original line number Diff line number Diff line Loading @@ -4,15 +4,12 @@ import { DialogBody, DialogFooter, FileInput, OverlayToaster, } from '@blueprintjs/core' import { exportImportUrl } from '@inject/shared/config' import { useNotifyContext } from '@inject/shared/notification/contexts/NotifyContext' import { useURLContext } from '@inject/shared/url' import { ChangeEvent, FC, useState } from 'react' // TODO: use the frontend NotifyEngine when merged const toaster = OverlayToaster.create() interface ImportDialogProps { isOpen: boolean onClose: () => void Loading @@ -21,6 +18,7 @@ interface ImportDialogProps { const ImportDialog: FC<ImportDialogProps> = ({ isOpen, onClose, onImport }) => { const { host, protocol } = useURLContext() const { notify } = useNotifyContext() const [loading, setLoading] = useState(false) Loading @@ -43,10 +41,7 @@ const ImportDialog: FC<ImportDialogProps> = ({ isOpen, onClose, onImport }) => { setLoading(true) onClose() toaster.show({ message: 'Uploading...', icon: 'cloud-upload', }) notify('Uploading...', { intent: 'none', icon: 'cloud-upload' }) fetch(exportImportUrl(protocol, host), { method: 'POST', Loading @@ -55,8 +50,7 @@ const ImportDialog: FC<ImportDialogProps> = ({ isOpen, onClose, onImport }) => { .then(res => res.json()) .then((res: { status: string; detail: string }) => { if (res.status !== 'ok') { toaster.show({ message: `${res.status}: ${res.detail}`, notify(`${res.status}: ${res.detail}`, { intent: 'danger', icon: 'error', }) Loading @@ -64,15 +58,10 @@ const ImportDialog: FC<ImportDialogProps> = ({ isOpen, onClose, onImport }) => { } onImport() toaster.show({ message: res.detail, intent: 'success', icon: 'tick', }) notify(res.detail, { intent: 'success', icon: 'tick' }) }) .catch((err: { status: string; detail: string }) => { toaster.show({ message: `${err.status}: ${err.detail}`, notify(`${err.status}: ${err.detail}`, { intent: 'danger', icon: 'error', }) Loading frontend/src/dashboard/ExerciseSelector/index.tsx +11 −3 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ import { ButtonGroup, ButtonProps, NonIdealState, Overlay, Overlay2, Section, SectionCard, Spinner, Loading @@ -17,6 +17,11 @@ import ImportDialog from './ImportDialog' import useExercisesSubscription from '@inject/graphql/utils/useExercisesSubscription' import { useURLContext } from '@inject/shared/url' import { exportImportUrl } from '@inject/shared/config' import { css } from '@emotion/css' const portal = css` z-index: 10; ` interface ExerciseSelectorProps { buttonProps?: ButtonProps | undefined Loading Loading @@ -86,7 +91,10 @@ const ExerciseSelector: FC<ExerciseSelectorProps> = ({ buttonProps }) => { onClick={() => setIsOpen(true)} {...buttonProps} /> <Overlay isOpen={isOpen} onClose={() => setIsOpen(false)}> <Overlay2 portalClassName={portal} isOpen={isOpen} onClose={() => setIsOpen(false)}> <Section title='Exercise Selector' rightElement={ Loading Loading @@ -114,7 +122,7 @@ const ExerciseSelector: FC<ExerciseSelectorProps> = ({ buttonProps }) => { </div> </SectionCard> </Section> </Overlay> </Overlay2> <ImportDialog isOpen={isImportOpen} onClose={() => setIsImportOpen(false)} Loading Loading
frontend/src/dashboard/ExerciseSelector/ImportDialog.tsx +6 −17 Original line number Diff line number Diff line Loading @@ -4,15 +4,12 @@ import { DialogBody, DialogFooter, FileInput, OverlayToaster, } from '@blueprintjs/core' import { exportImportUrl } from '@inject/shared/config' import { useNotifyContext } from '@inject/shared/notification/contexts/NotifyContext' import { useURLContext } from '@inject/shared/url' import { ChangeEvent, FC, useState } from 'react' // TODO: use the frontend NotifyEngine when merged const toaster = OverlayToaster.create() interface ImportDialogProps { isOpen: boolean onClose: () => void Loading @@ -21,6 +18,7 @@ interface ImportDialogProps { const ImportDialog: FC<ImportDialogProps> = ({ isOpen, onClose, onImport }) => { const { host, protocol } = useURLContext() const { notify } = useNotifyContext() const [loading, setLoading] = useState(false) Loading @@ -43,10 +41,7 @@ const ImportDialog: FC<ImportDialogProps> = ({ isOpen, onClose, onImport }) => { setLoading(true) onClose() toaster.show({ message: 'Uploading...', icon: 'cloud-upload', }) notify('Uploading...', { intent: 'none', icon: 'cloud-upload' }) fetch(exportImportUrl(protocol, host), { method: 'POST', Loading @@ -55,8 +50,7 @@ const ImportDialog: FC<ImportDialogProps> = ({ isOpen, onClose, onImport }) => { .then(res => res.json()) .then((res: { status: string; detail: string }) => { if (res.status !== 'ok') { toaster.show({ message: `${res.status}: ${res.detail}`, notify(`${res.status}: ${res.detail}`, { intent: 'danger', icon: 'error', }) Loading @@ -64,15 +58,10 @@ const ImportDialog: FC<ImportDialogProps> = ({ isOpen, onClose, onImport }) => { } onImport() toaster.show({ message: res.detail, intent: 'success', icon: 'tick', }) notify(res.detail, { intent: 'success', icon: 'tick' }) }) .catch((err: { status: string; detail: string }) => { toaster.show({ message: `${err.status}: ${err.detail}`, notify(`${err.status}: ${err.detail}`, { intent: 'danger', icon: 'error', }) Loading
frontend/src/dashboard/ExerciseSelector/index.tsx +11 −3 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ import { ButtonGroup, ButtonProps, NonIdealState, Overlay, Overlay2, Section, SectionCard, Spinner, Loading @@ -17,6 +17,11 @@ import ImportDialog from './ImportDialog' import useExercisesSubscription from '@inject/graphql/utils/useExercisesSubscription' import { useURLContext } from '@inject/shared/url' import { exportImportUrl } from '@inject/shared/config' import { css } from '@emotion/css' const portal = css` z-index: 10; ` interface ExerciseSelectorProps { buttonProps?: ButtonProps | undefined Loading Loading @@ -86,7 +91,10 @@ const ExerciseSelector: FC<ExerciseSelectorProps> = ({ buttonProps }) => { onClick={() => setIsOpen(true)} {...buttonProps} /> <Overlay isOpen={isOpen} onClose={() => setIsOpen(false)}> <Overlay2 portalClassName={portal} isOpen={isOpen} onClose={() => setIsOpen(false)}> <Section title='Exercise Selector' rightElement={ Loading Loading @@ -114,7 +122,7 @@ const ExerciseSelector: FC<ExerciseSelectorProps> = ({ buttonProps }) => { </div> </SectionCard> </Section> </Overlay> </Overlay2> <ImportDialog isOpen={isImportOpen} onClose={() => setIsImportOpen(false)} Loading