adding and removing teams works
This commit is contained in:
parent
952b3f6c4e
commit
cf4e3fbe1f
7 changed files with 46 additions and 19 deletions
|
|
@ -7,7 +7,7 @@ export default function Teams() {
|
||||||
const isMobile = useMobile();
|
const isMobile = useMobile();
|
||||||
return (
|
return (
|
||||||
<PageContainer>
|
<PageContainer>
|
||||||
<Box paddingY={isMobile ? 0.5 : 1} paddingX={isMobile ? 1 : 2}>
|
<Box paddingY={isMobile ? 1 : 1.5} paddingX={isMobile ? 1 : 2}>
|
||||||
<TeamList />
|
<TeamList />
|
||||||
</Box>
|
</Box>
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import { createContext, PropsWithChildren, useContext } from "react";
|
||||||
// import GitlabProvider from "./gitlab";
|
// import GitlabProvider from "./gitlab";
|
||||||
import PondProvider from "./pond/pond";
|
import PondProvider from "./pond/pond";
|
||||||
import { useAuth0 } from "@auth0/auth0-react";
|
import { useAuth0 } from "@auth0/auth0-react";
|
||||||
|
import SnackbarProvider from "./Snackbar";
|
||||||
// import SecurityProvider from "./security";
|
// import SecurityProvider from "./security";
|
||||||
// import { useAuth0 } from "@auth0/auth0-react";
|
// import { useAuth0 } from "@auth0/auth0-react";
|
||||||
|
|
||||||
|
|
@ -88,7 +89,9 @@ export default function HTTPProvider(props: Props) {
|
||||||
}}>
|
}}>
|
||||||
{/* <BillingProvider> */}
|
{/* <BillingProvider> */}
|
||||||
<PondProvider>
|
<PondProvider>
|
||||||
|
<SnackbarProvider>
|
||||||
{children}
|
{children}
|
||||||
|
</SnackbarProvider>
|
||||||
{/* <SecurityProvider> */}
|
{/* <SecurityProvider> */}
|
||||||
{/* <GitlabProvider>{children}</GitlabProvider> */}
|
{/* <GitlabProvider>{children}</GitlabProvider> */}
|
||||||
{/* </SecurityProvider> */}
|
{/* </SecurityProvider> */}
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ export const BinAPIContext = createContext<IBinAPIContext>({} as IBinAPIContext)
|
||||||
|
|
||||||
interface Props {}
|
interface Props {}
|
||||||
|
|
||||||
export default function DeviceProvider(props: PropsWithChildren<Props>) {
|
export default function BinProvider(props: PropsWithChildren<Props>) {
|
||||||
const { children } = props;
|
const { children } = props;
|
||||||
const { get, post, put, del } = useHTTP();
|
const { get, post, put, del } = useHTTP();
|
||||||
const permissionAPI = usePermissionAPI();
|
const permissionAPI = usePermissionAPI();
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@ import { PropsWithChildren } from "react";
|
||||||
import UserProvider, { useUserAPI } from "./userAPI";
|
import UserProvider, { useUserAPI } from "./userAPI";
|
||||||
import TeamProvider, { useTeamAPI } from "./teamAPI";
|
import TeamProvider, { useTeamAPI } from "./teamAPI";
|
||||||
import { useImagekitAPI } from "./imagekitAPI";
|
import { useImagekitAPI } from "./imagekitAPI";
|
||||||
import { usePermissionAPI } from "./permissionAPI";
|
import PermissionProvider, { usePermissionAPI } from "./permissionAPI";
|
||||||
import { Scope } from "models";
|
import { Scope } from "models";
|
||||||
import { useBinAPI } from "./binAPI";
|
import BinProvider, { useBinAPI } from "./binAPI";
|
||||||
import { useGateAPI } from "./gateAPI";
|
import GateProvider, { useGateAPI } from "./gateAPI";
|
||||||
|
|
||||||
export const pondURL = (partial: string, demo: boolean = false): string => {
|
export const pondURL = (partial: string, demo: boolean = false): string => {
|
||||||
let url = import.meta.env.VITE_APP_API_URL + (demo ? "/demo" : "") + partial;
|
let url = import.meta.env.VITE_APP_API_URL + (demo ? "/demo" : "") + partial;
|
||||||
|
|
@ -24,7 +24,13 @@ export default function PondProvider(props: PropsWithChildren<any>) {
|
||||||
return (
|
return (
|
||||||
<UserProvider>
|
<UserProvider>
|
||||||
<TeamProvider>
|
<TeamProvider>
|
||||||
{children}
|
<PermissionProvider>
|
||||||
|
<BinProvider>
|
||||||
|
<GateProvider>
|
||||||
|
{children}
|
||||||
|
</GateProvider>
|
||||||
|
</BinProvider>
|
||||||
|
</PermissionProvider>
|
||||||
</TeamProvider>
|
</TeamProvider>
|
||||||
</UserProvider>
|
</UserProvider>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ interface Props {
|
||||||
refreshCallback: () => void;
|
refreshCallback: () => void;
|
||||||
preferences: pond.TeamPreferences;
|
preferences: pond.TeamPreferences;
|
||||||
toggleNotificationPreference: () => void;
|
toggleNotificationPreference: () => void;
|
||||||
|
removeSelfCallback?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface OpenState {
|
interface OpenState {
|
||||||
|
|
@ -157,7 +158,11 @@ export default function TeamActions(props: Props) {
|
||||||
scope={teamScope(key)}
|
scope={teamScope(key)}
|
||||||
label={label}
|
label={label}
|
||||||
isDialogOpen={openState.removeSelf}
|
isDialogOpen={openState.removeSelf}
|
||||||
closeDialogCallback={() => setOpenState({ ...openState, removeSelf: false })}
|
closeDialogCallback={(removeSelf: boolean) => {
|
||||||
|
console.log(removeSelf)
|
||||||
|
if (removeSelf) refreshCallback()
|
||||||
|
setOpenState({ ...openState, removeSelf: false })
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import PrevIcon from "@mui/icons-material/NavigateBefore";
|
||||||
import LastIcon from "@mui/icons-material/SkipNext";
|
import LastIcon from "@mui/icons-material/SkipNext";
|
||||||
import FirstIcon from "@mui/icons-material/SkipPrevious";
|
import FirstIcon from "@mui/icons-material/SkipPrevious";
|
||||||
import TeamSettings from "./TeamSettings";
|
import TeamSettings from "./TeamSettings";
|
||||||
import { Add } from "@mui/icons-material";
|
import { Add, AddBox, AddOutlined } from "@mui/icons-material";
|
||||||
import { cloneDeep } from "lodash";
|
import { cloneDeep } from "lodash";
|
||||||
import { getContextKeys, getContextTypes } from "pbHelpers/Context";
|
import { getContextKeys, getContextTypes } from "pbHelpers/Context";
|
||||||
import { makeStyles, styled } from "@mui/styles";
|
import { makeStyles, styled } from "@mui/styles";
|
||||||
|
|
@ -48,6 +48,12 @@ const useStyles = makeStyles((theme: Theme) => ({
|
||||||
marginLeft: "auto",
|
marginLeft: "auto",
|
||||||
marginRight: theme.spacing(2),
|
marginRight: theme.spacing(2),
|
||||||
marginTop: theme.spacing(1)
|
marginTop: theme.spacing(1)
|
||||||
|
},
|
||||||
|
button: {
|
||||||
|
width: theme.spacing(6),
|
||||||
|
height: theme.spacing(6),
|
||||||
|
marginTop: "auto",
|
||||||
|
marginBottom: "auto"
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
@ -207,6 +213,7 @@ export default function TeamList(props: Props) {
|
||||||
team={Team.create(team)}
|
team={Team.create(team)}
|
||||||
permissions={permissions}
|
permissions={permissions}
|
||||||
refreshCallback={loadTeams}
|
refreshCallback={loadTeams}
|
||||||
|
removeSelfCallback={loadTeams}
|
||||||
preferences={preferences}
|
preferences={preferences}
|
||||||
toggleNotificationPreference={() => {
|
toggleNotificationPreference={() => {
|
||||||
if (preferences) {
|
if (preferences) {
|
||||||
|
|
@ -333,7 +340,9 @@ export default function TeamList(props: Props) {
|
||||||
}}>
|
}}>
|
||||||
{isUser ? user.name() + "'s " : "Someone's "} Teams
|
{isUser ? user.name() + "'s " : "Someone's "} Teams
|
||||||
</Typography>
|
</Typography>
|
||||||
<Add onClick={() => setTeamDialogOpen(true)} />
|
<IconButton onClick={() => setTeamDialogOpen(true)} color="primary" className={classes.button}>
|
||||||
|
<AddBox/>
|
||||||
|
</IconButton>
|
||||||
<TextField
|
<TextField
|
||||||
className={classes.input}
|
className={classes.input}
|
||||||
value={search}
|
value={search}
|
||||||
|
|
|
||||||
|
|
@ -45,17 +45,17 @@ export default function RemoveSelfFromObject(props: Props) {
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
])
|
])
|
||||||
.then((response: any) => {
|
.then(() => {
|
||||||
success("Successfully left " + label);
|
success("Successfully left " + label);
|
||||||
close(true);
|
close(true);
|
||||||
navigate("/" + (path !== undefined ? path : scope.kind) + "s");
|
navigate("/" + (path !== undefined ? path : scope.kind) + "s");
|
||||||
})
|
})
|
||||||
.catch((err: any) => {
|
// .catch((err: any) => {
|
||||||
err.response.data.error
|
// err.response.data.error
|
||||||
? warning(err.response.data.error)
|
// ? warning(err.response.data.error)
|
||||||
: error("Error occured when trying to remove yourself from " + label);
|
// : error("Error occured when trying to remove yourself from " + label);
|
||||||
close(false);
|
// close(false);
|
||||||
});
|
// });
|
||||||
};
|
};
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ UI BEGINS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ UI BEGINS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
@ -70,11 +70,15 @@ export default function RemoveSelfFromObject(props: Props) {
|
||||||
</Typography>
|
</Typography>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button onClick={() => close(false)} color="primary">
|
<Button onClick={() => close(false)}>
|
||||||
Cancel
|
<Typography color="textPrimary" variant="body2">
|
||||||
|
Cancel
|
||||||
|
</Typography>
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={submit} color="primary" autoFocus>
|
<Button onClick={submit} color="primary" autoFocus>
|
||||||
Leave
|
<Typography color="warning" variant="body2">
|
||||||
|
Leave
|
||||||
|
</Typography>
|
||||||
</Button>
|
</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue