Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forgetting browser warning #928

Merged
merged 7 commits into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import clsx from "clsx"
import { Trans } from "@lingui/macro"
import dayjs from "dayjs"
import { BrowserShare, useThresholdKey } from "../../../../Contexts/ThresholdKeyContext"
import CustomModal from "../../../Elements/CustomModal"

const useStyles = makeStyles(({ palette, constants, animation, breakpoints }: CSFTheme) =>
createStyles({
Expand Down Expand Up @@ -62,8 +63,32 @@ const useStyles = makeStyles(({ palette, constants, animation, breakpoints }: CS
actionBox: {
marginTop: constants.generalUnit * 2
},
spanMarginRight: {
oneSpace: {
marginRight: "0.5rem"
},
modalContainer: {
padding: `${constants.generalUnit * 3}px ${constants.generalUnit * 4}px`,
[breakpoints.down("md")]: {
padding: `${constants.generalUnit * 2}px ${constants.generalUnit * 2}px`
}
},
modalFooter: {
marginTop: constants.generalUnit * 4,
display: "flex",
alignItems: "center",
justifyContent: "flex-end"
},
cancelButton: {
marginRight: constants.generalUnit
},
modalInner: {
backgroundColor: constants.actionModal.backgroundColor,
color: constants.actionModal.color,
[breakpoints.down("md")]: {
borderTopLeftRadius: `${constants.generalUnit * 1.5}px`,
borderTopRightRadius: `${constants.generalUnit * 1.5}px`,
maxWidth: `${breakpoints.width("md")}px !important`
}
}
})
)
Expand All @@ -84,13 +109,15 @@ const BrowserPanel = ({ dateAdded, shareIndex, browser, os }: BrowserShare) => {
const [showPanel, setShowPanel] = useState(false)
const [loadingDeleteShare, setLoadingDeleteShare] = useState(false)
const [loadingDownloadKey, setLoadingDownloadKey] = useState(false)
const [isModalConfirmationOpen, setIsModalConfirmationOpen] = useState(false)

const onDeleteShare = useCallback(() => {
setLoadingDeleteShare(true)
deleteShare(shareIndex)
.then(() => {
setLoadingDeleteShare(false)
setShowPanel(false)
setIsModalConfirmationOpen(false)
}).catch((e) => {
console.error(e)
setLoadingDeleteShare(false)
Expand Down Expand Up @@ -129,24 +156,24 @@ const BrowserPanel = ({ dateAdded, shareIndex, browser, os }: BrowserShare) => {
component="p"
className={classes.subtitle}
>
<span className={classes.spanMarginRight}><Trans>Operating system:</Trans></span>{os.name}
<span className={classes.oneSpace}><Trans>Operating system:</Trans></span>{os.name}
</Typography>
<Typography
variant="body1"
component="p"
className={classes.subtitle}
>
<span className={classes.spanMarginRight}>
<span className={classes.oneSpace}>
<Trans>Browser:</Trans>
</span>
<span className={classes.spanMarginRight}>{browser.name}</span>{browser.version}
<span className={classes.oneSpace}>{browser.name}</span>{browser.version}
</Typography>
<Typography
variant="body1"
component="p"
className={classes.subtitleLast}
>
<span className={classes.spanMarginRight}><Trans>Saved on:</Trans></span>{dayjs(dateAdded).format("DD MMM YYYY - HH:mm")}
<span className={classes.oneSpace}><Trans>Saved on:</Trans></span>{dayjs(dateAdded).format("DD MMM YYYY - HH:mm")}
</Typography>
<div className={classes.actionBox}>
<Typography
Expand All @@ -167,22 +194,41 @@ const BrowserPanel = ({ dateAdded, shareIndex, browser, os }: BrowserShare) => {
</div>
{keyDetails && browserShares.length > 1 && keyDetails.totalShares > 3 &&
<div className={classes.actionBox}>
<Typography
variant="body1"
component="p"
className={classes.lightSubtitle}
>
<Trans>Forgetting this browser deletes this from your list of sign-in methods.
You will not be able to forget a browser if you only have two methods set up.</Trans>
</Typography>
<Button
size="small"
loading={loadingDeleteShare}
onClick={onDeleteShare}
disabled={loadingDeleteShare}
onClick={() => setIsModalConfirmationOpen(true)}
>
<Trans>Forget this browser</Trans>
</Button>
<CustomModal
active={isModalConfirmationOpen}
injectedClass={{
inner: classes.modalInner
}}
>
<div className={classes.modalContainer}>
<Typography>
<Trans>By forgetting this browser, you will not be able to use its associated recovery key to sign-in.</Trans>
</Typography>
<div className={classes.modalFooter}>
<Button
variant="outline"
onClick={() => setIsModalConfirmationOpen(false)}
className={classes.cancelButton}
tanmoyAtb marked this conversation as resolved.
Show resolved Hide resolved
disabled={loadingDeleteShare}
>
<Trans>Cancel</Trans>
</Button>
<Button
onClick={onDeleteShare}
loading={loadingDeleteShare}
disabled={loadingDeleteShare}
>
<Trans>Forget this browser</Trans>
</Button>
</div>
</div>
</CustomModal>
</div>
}
</div>
Expand Down
4 changes: 4 additions & 0 deletions packages/files-ui/src/Themes/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ export interface CsfColors extends IConstants {
backgroundColor: string
color: string
}
actionModal: {
backgroundColor: string
color: string
}
previewModal: {
controlsBackground: string
controlsColor: string
Expand Down
4 changes: 4 additions & 0 deletions packages/files-ui/src/Themes/DarkTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ export const darkTheme = createTheme<CsfColors>({
backgroundColor: "var(--gray2)",
color: "var(--gray9)"
},
actionModal: {
backgroundColor: "var(--gray2)",
color: "var(--gray9)"
},
previewModal: {
controlsBackground: "var(--gray1)",
controlsColor: "var(--gray10)",
Expand Down
4 changes: 4 additions & 0 deletions packages/files-ui/src/Themes/LightTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ export const lightTheme = createTheme<CsfColors>({
backgroundColor: "var(--gray1)",
color: "var(--gray10)"
},
actionModal: {
backgroundColor: "var(--gray1)",
color: "var(--gray10)"
},
previewModal: {
controlsBackground: "var(--gray9)",
controlsColor: "var(--gray8)",
Expand Down