can now favorite a team from TeamActions
This commit is contained in:
parent
0e98d7329f
commit
39764ae4b0
1 changed files with 29 additions and 1 deletions
|
|
@ -11,7 +11,7 @@ import MoreIcon from "@mui/icons-material/MoreVert";
|
||||||
import GroupSettingsIcon from "@mui/icons-material/Settings";
|
import GroupSettingsIcon from "@mui/icons-material/Settings";
|
||||||
import ShareObjectIcon from "@mui/icons-material/Share";
|
import ShareObjectIcon from "@mui/icons-material/Share";
|
||||||
import ObjectUsersIcon from "@mui/icons-material/AccountCircle";
|
import ObjectUsersIcon from "@mui/icons-material/AccountCircle";
|
||||||
import { Team, teamScope } from "models";
|
import { Team, teamScope, User } from "models";
|
||||||
import { pond } from "protobuf-ts/pond";
|
import { pond } from "protobuf-ts/pond";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import ObjectUsers from "user/ObjectUsers";
|
import ObjectUsers from "user/ObjectUsers";
|
||||||
|
|
@ -22,6 +22,9 @@ import TeamSettings from "./TeamSettings";
|
||||||
import NotificationButton from "common/NotificationButton";
|
import NotificationButton from "common/NotificationButton";
|
||||||
import { blue } from "@mui/material/colors";
|
import { blue } from "@mui/material/colors";
|
||||||
import { makeStyles } from "@mui/styles";
|
import { makeStyles } from "@mui/styles";
|
||||||
|
import { useGlobalState, useUserAPI } from "providers";
|
||||||
|
import { Star, StarBorder } from "@mui/icons-material";
|
||||||
|
import { cloneDeep } from "lodash";
|
||||||
|
|
||||||
const useStyles = makeStyles(() => ({
|
const useStyles = makeStyles(() => ({
|
||||||
shareIcon: {
|
shareIcon: {
|
||||||
|
|
@ -66,6 +69,8 @@ export default function TeamActions(props: Props) {
|
||||||
settings: false,
|
settings: false,
|
||||||
removeSelf: false
|
removeSelf: false
|
||||||
});
|
});
|
||||||
|
const [{ as, user }, dispatch] = useGlobalState()
|
||||||
|
const userAPI = useUserAPI()
|
||||||
|
|
||||||
const groupMenu = () => {
|
const groupMenu = () => {
|
||||||
const canShare = permissions.includes(pond.Permission.PERMISSION_SHARE);
|
const canShare = permissions.includes(pond.Permission.PERMISSION_SHARE);
|
||||||
|
|
@ -168,9 +173,32 @@ export default function TeamActions(props: Props) {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const selectFavorite = () => {
|
||||||
|
let newUser = user.protobuf()
|
||||||
|
if (!newUser.settings) newUser.settings = pond.UserSettings.create()
|
||||||
|
newUser.settings.defaultTeam = user.settings.defaultTeam === team.key() ? "" : team.key();
|
||||||
|
userAPI.updateUser(user.id(), newUser).then(() => {
|
||||||
|
let u = User.create(newUser)
|
||||||
|
dispatch({ key: "user", value: u });
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const canWrite = permissions.includes(pond.Permission.PERMISSION_WRITE);
|
const canWrite = permissions.includes(pond.Permission.PERMISSION_WRITE);
|
||||||
|
const canFavorite = !as.includes("auth")
|
||||||
|
const isFavorite = user.settings.defaultTeam === team.key()
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
|
{ canFavorite &&
|
||||||
|
<Tooltip title={ !isFavorite ? "Make this your default team" : "Remove default team"} >
|
||||||
|
<IconButton onClick={selectFavorite}>
|
||||||
|
{ isFavorite ?
|
||||||
|
<Star />
|
||||||
|
:
|
||||||
|
<StarBorder />
|
||||||
|
}
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
}
|
||||||
<NotificationButton
|
<NotificationButton
|
||||||
notify={preferences.notify}
|
notify={preferences.notify}
|
||||||
onChange={toggleNotificationPreference}
|
onChange={toggleNotificationPreference}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue