notification button is now present and clickable in team list

This commit is contained in:
Carter 2024-11-19 18:02:05 -06:00
parent aa56f05c25
commit de9da91c2e
3 changed files with 32 additions and 46 deletions

View file

@ -1,13 +1,9 @@
import { createStyles, IconButton, Tooltip } from "@mui/material"; import { IconButton, Tooltip } from "@mui/material";
// import { Theme } from "@material-ui/core/styles/createMuiTheme"; // import { Theme } from "@material-ui/core/styles/createMuiTheme";
// import withStyles, { WithStyles } from "@material-ui/core/styles/withStyles"; // import withStyles, { WithStyles } from "@material-ui/core/styles/withStyles";
import NotificationsEnabledIcon from "@mui/icons-material/NotificationsActive"; import NotificationsEnabledIcon from "@mui/icons-material/NotificationsActive";
import NotificationsDisabledIcon from "@mui/icons-material/NotificationsOff"; import NotificationsDisabledIcon from "@mui/icons-material/NotificationsOff";
import { WithStyles } from "@mui/styles"; interface Props {
const styles = () => createStyles({});
interface Props extends WithStyles<typeof styles> {
notify: boolean; notify: boolean;
hidden?: boolean; hidden?: boolean;
onChange: Function; onChange: Function;
@ -15,7 +11,6 @@ interface Props extends WithStyles<typeof styles> {
tooltip: string; tooltip: string;
} }
// interface State {}
export default function NotificationButton (props: Props) { export default function NotificationButton (props: Props) {

View file

@ -171,7 +171,7 @@ export default function TeamActions(props: Props) {
const canWrite = permissions.includes(pond.Permission.PERMISSION_WRITE); const canWrite = permissions.includes(pond.Permission.PERMISSION_WRITE);
return ( return (
<React.Fragment> <React.Fragment>
{/* <NotificationButton <NotificationButton
notify={preferences.notify} notify={preferences.notify}
onChange={toggleNotificationPreference} onChange={toggleNotificationPreference}
tooltip={ tooltip={
@ -181,7 +181,7 @@ export default function TeamActions(props: Props) {
(preferences.notify ? "enabled" : "disabled") (preferences.notify ? "enabled" : "disabled")
} }
// hidden={isLoading} // hidden={isLoading}
/> */} />
{canWrite && ( {canWrite && (
<Tooltip title="Team Settings"> <Tooltip title="Team Settings">
<IconButton onClick={() => setOpenState({ ...openState, settings: true })}> <IconButton onClick={() => setOpenState({ ...openState, settings: true })}>

View file

@ -134,16 +134,6 @@ export default function TeamList() {
userAPI userAPI
.getUser(u, teamScope(team.settings?.key)) .getUser(u, teamScope(team.settings?.key))
.then(resp => { .then(resp => {
// let permissions: pond.Permission[] = resp.permissions.map(perm => pond.Permission[perm as unknown as keyof typeof pond.Permission]);
// console.log(resp.permissions)
// console.log(typeof(resp.permissions))
resp.permissions.forEach(p => {
// console.log('Value:', p, 'Type:', typeof p);
});
// permissions.forEach(p => {
// console.log('Value:', p, 'Type:', typeof p);
// });
// console.log('Expected Value:', pond.Permission.PERMISSION_WRITE, 'Type:', typeof pond.Permission.PERMISSION_WRITE);
newTeamPerms[index] = resp.permissions; newTeamPerms[index] = resp.permissions;
newTeamPrefs[index] = resp.preferences; newTeamPrefs[index] = resp.preferences;
}) })
@ -178,7 +168,34 @@ export default function TeamList() {
} }
return ( return (
<React.Fragment key={index}> <React.Fragment key={index}>
<ListItem alignItems="flex-start"> <ListItem
alignItems="flex-start"
secondaryAction={
<TeamActions
team={Team.create(team)}
permissions={permissions}
refreshCallback={loadTeams}
removeSelfCallback={loadTeams}
preferences={preferences}
toggleNotificationPreference={() => {
if (preferences) {
let newTeamPrefs = cloneDeep(teamPrefs);
newTeamPrefs[index].notify = !newTeamPrefs[index].notify;
teamAPI
.updatePreferences(
Team.create(team).key(),
newTeamPrefs[index],
getContextKeys(),
getContextTypes()
)
.then(() => {
setTeamPrefs(newTeamPrefs);
});
}
}}
/>
}
>
<ListItemAvatar> <ListItemAvatar>
<Avatar <Avatar
onClick={() => { onClick={() => {
@ -207,32 +224,6 @@ export default function TeamList() {
</React.Fragment> </React.Fragment>
} }
/> />
<ListItemSecondaryAction>
<TeamActions
team={Team.create(team)}
permissions={permissions}
refreshCallback={loadTeams}
removeSelfCallback={loadTeams}
preferences={preferences}
toggleNotificationPreference={() => {
if (preferences) {
let newTeamPrefs = cloneDeep(teamPrefs);
newTeamPrefs[index].notify = !newTeamPrefs[index].notify;
teamAPI
.updatePreferences(
Team.create(team).key(),
newTeamPrefs[index],
getContextKeys(),
getContextTypes()
)
.then(() => {
setTeamPrefs(newTeamPrefs);
});
// setTeamPrefs(newTeamPrefs)
}
}}
/>
</ListItemSecondaryAction>
</ListItem> </ListItem>
<Divider variant="inset" component="li" /> <Divider variant="inset" component="li" />
</React.Fragment> </React.Fragment>