mirror of
https://github.com/XFox111/TabsAsideExtension.git
synced 2026-04-22 07:58:01 +03:00
!feat: major 3.0 release candidate
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import resolveConflict from "@/features/collectionStorage/utils/resolveConflict";
|
||||
import { Button, MessageBar, MessageBarActions, MessageBarBody, MessageBarProps, MessageBarTitle } from "@fluentui/react-components";
|
||||
import { ArrowUpload20Regular, CloudArrowDown20Regular, Wrench20Regular } from "@fluentui/react-icons";
|
||||
import { useCollections } from "../../../contexts/CollectionsProvider";
|
||||
|
||||
export default function CloudIssueMessages(props: MessageBarProps): React.ReactElement
|
||||
{
|
||||
const { cloudIssue, refreshCollections } = useCollections();
|
||||
|
||||
const overrideStorageWith = async (source: "local" | "sync") =>
|
||||
{
|
||||
await resolveConflict(source);
|
||||
await refreshCollections();
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{ cloudIssue === "parse_error" &&
|
||||
<MessageBar intent="error" layout="multiline" { ...props }>
|
||||
<MessageBarBody>
|
||||
<MessageBarTitle>{ i18n.t("parse_error_message.title") }</MessageBarTitle>
|
||||
{ i18n.t("parse_error_message.message") }
|
||||
</MessageBarBody>
|
||||
<MessageBarActions>
|
||||
<Button icon={ <Wrench20Regular /> } onClick={ () => overrideStorageWith("local") }>
|
||||
{ i18n.t("parse_error_message.action") }
|
||||
</Button>
|
||||
</MessageBarActions>
|
||||
</MessageBar>
|
||||
}
|
||||
|
||||
{ cloudIssue === "merge_conflict" &&
|
||||
<MessageBar intent="warning" layout="multiline" { ...props }>
|
||||
<MessageBarBody>
|
||||
<MessageBarTitle>{ i18n.t("merge_conflict_message.title") }</MessageBarTitle>
|
||||
{ i18n.t("merge_conflict_message.message") }
|
||||
</MessageBarBody>
|
||||
<MessageBarActions>
|
||||
<Button icon={ <ArrowUpload20Regular /> } onClick={ () => overrideStorageWith("local") }>
|
||||
{ i18n.t("merge_conflict_message.accept_local") }
|
||||
</Button>
|
||||
<Button icon={ <CloudArrowDown20Regular /> } onClick={ () => overrideStorageWith("sync") }>
|
||||
{ i18n.t("merge_conflict_message.accept_cloud") }
|
||||
</Button>
|
||||
</MessageBarActions>
|
||||
</MessageBar>
|
||||
}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import { BuyMeACoffee20Regular } from "@/assets/BuyMeACoffee20";
|
||||
import { buyMeACoffeeLink, storeLink } from "@/data/links";
|
||||
import { useBmcStyles } from "@/hooks/useBmcStyles";
|
||||
import extLink from "@/utils/extLink";
|
||||
import { Button, Link, MessageBar, MessageBarActions, MessageBarBody, MessageBarProps, MessageBarTitle } from "@fluentui/react-components";
|
||||
import { DismissRegular, HeartFilled } from "@fluentui/react-icons";
|
||||
import { ReactElement } from "react";
|
||||
|
||||
export default function CtaMessage(props: MessageBarProps): ReactElement
|
||||
{
|
||||
const [counter, setCounter] = useState<number>(0);
|
||||
const bmcCls = useBmcStyles();
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
ctaCounter.getValue().then(c =>
|
||||
{
|
||||
if (c >= 0)
|
||||
{
|
||||
setCounter(c);
|
||||
ctaCounter.setValue(c + 1);
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
const resetCounter = async (counter: number) =>
|
||||
{
|
||||
await ctaCounter.setValue(counter);
|
||||
setCounter(counter);
|
||||
};
|
||||
|
||||
if (counter < 50)
|
||||
return <></>;
|
||||
|
||||
return (
|
||||
<MessageBar layout="multiline" icon={ <HeartFilled color="red" /> } { ...props }>
|
||||
<MessageBarBody>
|
||||
<MessageBarTitle>{ i18n.t("cta_message.title") }</MessageBarTitle>
|
||||
{ i18n.t("cta_message.message") } <Link { ...extLink(storeLink) }>{ i18n.t("cta_message.feedback") }</Link>
|
||||
</MessageBarBody>
|
||||
<MessageBarActions
|
||||
containerAction={
|
||||
<Button icon={ <DismissRegular /> } appearance="transparent" onClick={ () => resetCounter(0) } />
|
||||
}
|
||||
>
|
||||
<Button
|
||||
as="a" { ...extLink(buyMeACoffeeLink) }
|
||||
onClick={ () => resetCounter(-1) }
|
||||
appearance="primary"
|
||||
className={ bmcCls.button }
|
||||
icon={ <BuyMeACoffee20Regular /> }
|
||||
>
|
||||
{ i18n.t("common.cta.sponsor") }
|
||||
</Button>
|
||||
</MessageBarActions>
|
||||
</MessageBar>
|
||||
);
|
||||
}
|
||||
|
||||
const ctaCounter = storage.defineItem<number>("local:ctaCounter", { fallback: 0 });
|
||||
@@ -0,0 +1,21 @@
|
||||
import useStorageInfo from "@/hooks/useStorageInfo";
|
||||
import { MessageBar, MessageBarBody, MessageBarProps, MessageBarTitle } from "@fluentui/react-components";
|
||||
|
||||
export default function StorageCapacityIssueMessage(props: MessageBarProps): JSX.Element
|
||||
{
|
||||
const { usedStorageRatio } = useStorageInfo();
|
||||
|
||||
if (usedStorageRatio < 0.8)
|
||||
return <></>;
|
||||
|
||||
return (
|
||||
<MessageBar intent="warning" layout="multiline" { ...props }>
|
||||
<MessageBarBody>
|
||||
<MessageBarTitle>
|
||||
{ i18n.t("storage_full_message.title", [(usedStorageRatio * 100).toFixed(1)]) }
|
||||
</MessageBarTitle>
|
||||
{ i18n.t("storage_full_message.message") }
|
||||
</MessageBarBody>
|
||||
</MessageBar>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user