-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into fb-LEAP-192
- Loading branch information
Showing
19 changed files
with
513 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"message": "fix: OPTIC-109: Blank draft should not be created when an annotation is submitted", | ||
"commit": "c9758b2fb911f789d6ba3c4b1dd8a44528eea5d0", | ||
"message": "feat: LEAP-206: Ensure users can navigate freely and drafts are saved when leaving the labelling screen", | ||
"commit": "32a18f43f46d65f61db5841ac58258f36f194bdc", | ||
"branch": "master", | ||
"date": "2023/09/22 11:06:45" | ||
"date": "2023/09/26 10:39:21" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
label_studio/frontend/src/components/DraftGuard/DraftGuard.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { useContext, useEffect } from 'react'; | ||
import { useHistory } from 'react-router-dom'; | ||
import { ToastContext } from '../Toast/Toast'; | ||
import { FF_OPTIC_2, isFF } from '../../utils/feature-flags'; | ||
|
||
export const DRAFT_GUARD_KEY = "DRAFT_GUARD"; | ||
|
||
export const draftGuardCallback = { | ||
current: null, | ||
}; | ||
|
||
export const DraftGuard = () => { | ||
const toast = useContext(ToastContext); | ||
const history = useHistory(); | ||
|
||
useEffect(() => { | ||
if (isFF(FF_OPTIC_2)) { | ||
const unblock = history.block(() => { | ||
const selected = window.Htx?.annotationStore?.selected; | ||
const submissionInProgress = !!selected?.submissionStarted; | ||
const hasChanges = !!selected?.history.undoIdx && !submissionInProgress; | ||
|
||
if (hasChanges) { | ||
selected.saveDraftImmediatelyWithResults()?.then((res) => { | ||
const status = res?.$meta?.status; | ||
|
||
if (status === 200 || status === 201) { | ||
toast.show({ message: "Draft saved successfully", type: "info" }); | ||
draftGuardCallback.current?.(true); | ||
draftGuardCallback.current = null; | ||
} else if (status !== undefined) { | ||
toast.show({ message: "There was an error saving your draft", type: "error" }); | ||
} | ||
}); | ||
|
||
return DRAFT_GUARD_KEY; | ||
} | ||
}); | ||
|
||
return () => { | ||
draftGuardCallback.current = null; | ||
unblock(); | ||
}; | ||
} | ||
}, []); | ||
|
||
return <></>; | ||
}; |
27 changes: 27 additions & 0 deletions
27
label_studio/frontend/src/components/Toast/MessageToast.styl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
messageToastInfoBackgroundColor = #262626 | ||
messageToastErrorBackgroundColor = #cf1322fc | ||
|
||
.MessageToast | ||
&_info | ||
--background-color messageToastInfoBackgroundColor | ||
--hover-background-color lighten(messageToastInfoBackgroundColor, 10%) | ||
&_error | ||
--background-color messageToastErrorBackgroundColor | ||
--hover-background-color lighten(messageToastErrorBackgroundColor, 10%) | ||
background-color var(--background-color) | ||
|
||
.toast | ||
--border-color rgba(240, 238, 242, 0.16) | ||
--padding 8px 16px | ||
background-color inherit | ||
|
||
&__action, | ||
&__content | ||
color #FAFAFA | ||
display flex | ||
align-items center | ||
|
||
&__action | ||
background-color inherit | ||
&:hover | ||
background-color var(--hover-background-color) |
28 changes: 28 additions & 0 deletions
28
label_studio/frontend/src/components/Toast/MessageToast.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Toast, ToastAction, ToastProps } from '../../components/Toast/Toast'; | ||
import { LsCross } from '../../assets/icons'; | ||
import { FC } from 'react'; | ||
import { Block } from '../../utils/bem'; | ||
import "./MessageToast.styl"; | ||
|
||
export interface MessageToastProps extends ToastProps { | ||
children?: any, | ||
toastType?: "info" | "error" | null | ||
closeCallback?: () => void | ||
} | ||
|
||
export const MessageToast: FC<MessageToastProps> = ({ toastType = "info", closeCallback, children, ...props }) => { | ||
return ( | ||
<Block name="MessageToast" | ||
tag={Toast} | ||
open={!!children} | ||
mod={{ | ||
info: toastType === "info", | ||
error: toastType === "error", | ||
}} | ||
action={<ToastAction closeCallback={closeCallback} altText="x"><LsCross /></ToastAction>} | ||
{...props} | ||
> | ||
{children} | ||
</Block> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
@keyframes toast-enter-up | ||
from | ||
opacity 0 | ||
transform translateY(100%) | ||
to | ||
opacity 1 | ||
transform translateY(0) | ||
|
||
@keyframes toast-leave-fade | ||
from | ||
opacity 1 | ||
to | ||
opacity 0 | ||
|
||
@keyframes toast-leave-down | ||
from | ||
opacity 1 | ||
transform translateY(var(--radix-toast-swipe-end-y)) | ||
to | ||
opacity 0 | ||
transform translateY(100%) | ||
|
||
.toast-viewport | ||
--toast-spacing 8px | ||
position fixed | ||
display flex | ||
justify-content center | ||
width 100% | ||
z-index 9999 | ||
bottom 24px | ||
pointer-events none | ||
|
||
& ol | ||
list-style none | ||
|
||
& li + li | ||
margin-top var(--toast-spacing) | ||
|
||
& ol:empty | ||
display: none; | ||
|
||
& li | ||
@media (prefers-reduced-motion: no-preference) | ||
will-change opacity, transform | ||
|
||
&[data-state="open"] | ||
animation toast-enter-up 100ms ease-out forwards | ||
|
||
&[data-state="closed"] | ||
animation toast-leave-fade 100ms ease-out forwards | ||
|
||
&[data-swipe="move"] | ||
transform translateY(var(--radix-toast-swipe-move-y)) | ||
|
||
&[data-swipe="cancel"] | ||
transform translateY(0) | ||
|
||
&[data-swipe="end"] | ||
animation toast-leave-down 100ms ease-out forwards | ||
|
||
.toast | ||
--background-color #FAFAFA | ||
--border-color rgba(137, 128, 152, 0.16) | ||
--padding 8px 16px | ||
display flex | ||
align-items center | ||
gap 16px | ||
border-radius 4px | ||
overflow hidden | ||
border 1px solid var(--border-color) | ||
background-color var(--background-color) | ||
|
||
& > div, | ||
&__content | ||
font-size 16px | ||
letter-spacing 0.5px | ||
line-height 24px | ||
flex 1 | ||
|
||
&__action, | ||
&__content | ||
padding var(--padding) | ||
|
||
&__action | ||
font-weight 500 | ||
font-size 16px | ||
letter-spacing 0.15px | ||
line-height 24px | ||
border none | ||
border-radius 0 | ||
border-left 1px solid var(--border-color) |
Oops, something went wrong.