Skip to content

Commit

Permalink
add badge to UserMenu when update is available
Browse files Browse the repository at this point in the history
notsidney committed Jul 12, 2021

Verified

This commit was signed with the committer’s verified signature.
Byron Sebastian Thiel
1 parent ea336a6 commit f6d5dfe
Showing 4 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion www/package.json
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
"@antlerengineering/form-builder": "^2.6.0",
"@antlerengineering/multiselect": "^0.9.2",
"@date-io/date-fns": "1.x",
"@material-ui/core": "^4.11.3",
"@material-ui/core": "^4.12.1",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.56",
"@material-ui/pickers": "^3.2.10",
2 changes: 1 addition & 1 deletion www/src/components/Navigation/UpdateChecker.tsx
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ import WIKI_LINKS from "constants/wikiLinks";
const useLastCheckedUpdateState = createPersistedState(
"_FT_LAST_CHECKED_UPDATE"
);
const useLatestUpdateState = createPersistedState("_FT_LATEST_UPDATE");
export const useLatestUpdateState = createPersistedState("_FT_LATEST_UPDATE");

const useStyles = makeStyles((theme) =>
createStyles({
13 changes: 11 additions & 2 deletions www/src/components/Navigation/UserMenu.tsx
Original file line number Diff line number Diff line change
@@ -14,15 +14,17 @@ import {
ListItemSecondaryAction,
ListItemIcon,
Divider,
Badge,
} from "@material-ui/core";
import AccountCircleIcon from "@material-ui/icons/AccountCircle";
import ArrowRightIcon from "@material-ui/icons/ArrowRight";
import CheckIcon from "@material-ui/icons/Check";

import UpdateChecker from "./UpdateChecker";
import UpdateChecker, { useLatestUpdateState } from "./UpdateChecker";
import { useAppContext } from "contexts/AppContext";
import routes from "constants/routes";
import { projectId } from "../../firebase";
import meta from "../../../package.json";

const useStyles = makeStyles((theme) =>
createStyles({
@@ -64,6 +66,7 @@ export default function UserMenu(props: IconButtonProps) {
const anchorEl = useRef<HTMLButtonElement>(null);
const [open, setOpen] = useState(false);
const [themeSubMenu, setThemeSubMenu] = useState<EventTarget | null>(null);
const [latestUpdate] = useLatestUpdateState<null | Record<string, any>>();

const {
currentUser,
@@ -118,7 +121,13 @@ export default function UserMenu(props: IconButtonProps) {
onClick={() => setOpen(true)}
className={classes.iconButton}
>
{avatar}
{latestUpdate?.tag_name > "v" + meta.version ? (
<Badge color="primary" overlap="circular" variant="dot">
{avatar}
</Badge>
) : (
avatar
)}
</IconButton>

<Menu
34 changes: 17 additions & 17 deletions www/yarn.lock
Original file line number Diff line number Diff line change
@@ -2237,15 +2237,15 @@
resolved "https://registry.yarnpkg.com/@jsdevtools/ono/-/ono-7.1.3.tgz#9df03bbd7c696a5c58885c34aa06da41c8543796"
integrity sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==

"@material-ui/core@^4.11.3":
version "4.11.3"
resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-4.11.3.tgz#f22e41775b0bd075e36a7a093d43951bf7f63850"
integrity sha512-Adt40rGW6Uds+cAyk3pVgcErpzU/qxc7KBR94jFHBYretU4AtWZltYcNsbeMn9tXL86jjVL1kuGcIHsgLgFGRw==
"@material-ui/core@^4.12.1":
version "4.12.1"
resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-4.12.1.tgz#ac8f081498047aa02bb6ee70b77c5dad6a2a6e73"
integrity sha512-C6hYsjkWCTfBx9FaqxhCZCITBagh7fyCKFtHyvO3tTOcBw6NJaktdhNZ2n82jQdQdgfFvg6OOxi7OOzsAdAcBQ==
dependencies:
"@babel/runtime" "^7.4.4"
"@material-ui/styles" "^4.11.3"
"@material-ui/system" "^4.11.3"
"@material-ui/types" "^5.1.0"
"@material-ui/styles" "^4.11.4"
"@material-ui/system" "^4.12.1"
"@material-ui/types" "5.1.0"
"@material-ui/utils" "^4.11.2"
"@types/react-transition-group" "^4.2.0"
clsx "^1.0.4"
@@ -2285,14 +2285,14 @@
react-transition-group "^4.0.0"
rifm "^0.7.0"

"@material-ui/styles@^4.11.3":
version "4.11.3"
resolved "https://registry.yarnpkg.com/@material-ui/styles/-/styles-4.11.3.tgz#1b8d97775a4a643b53478c895e3f2a464e8916f2"
integrity sha512-HzVzCG+PpgUGMUYEJ2rTEmQYeonGh41BYfILNFb/1ueqma+p1meSdu4RX6NjxYBMhf7k+jgfHFTTz+L1SXL/Zg==
"@material-ui/styles@^4.11.4":
version "4.11.4"
resolved "https://registry.yarnpkg.com/@material-ui/styles/-/styles-4.11.4.tgz#eb9dfccfcc2d208243d986457dff025497afa00d"
integrity sha512-KNTIZcnj/zprG5LW0Sao7zw+yG3O35pviHzejMdcSGCdWbiO8qzRgOYL8JAxAsWBKOKYwVZxXtHWaB5T2Kvxew==
dependencies:
"@babel/runtime" "^7.4.4"
"@emotion/hash" "^0.8.0"
"@material-ui/types" "^5.1.0"
"@material-ui/types" "5.1.0"
"@material-ui/utils" "^4.11.2"
clsx "^1.0.4"
csstype "^2.5.2"
@@ -2307,17 +2307,17 @@
jss-plugin-vendor-prefixer "^10.5.1"
prop-types "^15.7.2"

"@material-ui/system@^4.11.3":
version "4.11.3"
resolved "https://registry.yarnpkg.com/@material-ui/system/-/system-4.11.3.tgz#466bc14c9986798fd325665927c963eb47cc4143"
integrity sha512-SY7otguNGol41Mu2Sg6KbBP1ZRFIbFLHGK81y4KYbsV2yIcaEPOmsCK6zwWlp+2yTV3J/VwT6oSBARtGIVdXPw==
"@material-ui/system@^4.12.1":
version "4.12.1"
resolved "https://registry.yarnpkg.com/@material-ui/system/-/system-4.12.1.tgz#2dd96c243f8c0a331b2bb6d46efd7771a399707c"
integrity sha512-lUdzs4q9kEXZGhbN7BptyiS1rLNHe6kG9o8Y307HCvF4sQxbCgpL2qi+gUk+yI8a2DNk48gISEQxoxpgph0xIw==
dependencies:
"@babel/runtime" "^7.4.4"
"@material-ui/utils" "^4.11.2"
csstype "^2.5.2"
prop-types "^15.7.2"

"@material-ui/types@^5.1.0":
"@material-ui/[email protected]":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@material-ui/types/-/types-5.1.0.tgz#efa1c7a0b0eaa4c7c87ac0390445f0f88b0d88f2"
integrity sha512-7cqRjrY50b8QzRSYyhSpx4WRw2YuO0KKIGQEVk5J8uoz2BanawykgZGoWEqKm7pVIbzFDN0SpPcVV4IhOFkl8A==

0 comments on commit f6d5dfe

Please sign in to comment.