MCPcopy
hub / github.com/chartbrew/chartbrew / Sidebar

Function Sidebar

client/src/components/Sidebar.jsx:22–624  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20
21
22function Sidebar() {
23 const { isDark, theme, setTheme } = useTheme()
24 const collapsed = useSelector(selectSidebarCollapsed);
25
26 const [createTeamModal, setCreateTeamModal] = useState(false);
27 const [creatingTeam, setCreatingTeam] = useState(false);
28 const [teamName, setTeamName] = useState("");
29
30 const user = useSelector((state) => state.user);
31 const team = useSelector(selectTeam);
32 const teams = useSelector(selectTeams);
33 const teamInitials = team?.name?.split(" ").map((part) => part[0]).join("").slice(0, 2).toUpperCase() || "T";
34 const userInitials = user?.data?.name?.split(" ").map((part) => part[0]).join("").slice(0, 2).toUpperCase() || "U";
35
36 const navigate = useNavigate();
37 const dispatch = useDispatch();
38
39 const _canAccess = (role, teamRoles) => {
40 return canAccess(role, user.data.id, teamRoles);
41 };
42
43 const _getActiveMenu = () => {
44 return window.location.pathname.split("/")[1];
45 };
46
47 const pathMenu = _getActiveMenu();
48 const isDashboardActive = pathMenu === "" || window.location.pathname.indexOf("dashboard") > -1;
49 const isConnectionsActive = pathMenu === "connections";
50 const isDatasetsActive = pathMenu === "datasets";
51 const isIntegrationsActive = pathMenu === "integrations";
52 const isSettingsActive = pathMenu === "settings";
53
54 const _getTeamRole = (teamRoles) => {
55 if (!teamRoles) return "";
56 let role = teamRoles.filter((o) => o.user_id === user.data.id)[0];
57 if (role.role === "teamOwner") {
58 return {
59 role: "Team Owner",
60 color: "accent",
61 };
62 } else if (role.role === "teamAdmin") {
63 return {
64 role: "Team Admin",
65 color: "success",
66 };
67 } else if (role.role === "projectAdmin") {
68 return {
69 role: "Project Admin",
70 color: "warning",
71 };
72 } else if (role.role === "projectEditor") {
73 return {
74 role: "Project Editor",
75 color: "default",
76 };
77 } else if (role.role === "projectViewer") {
78 return {
79 role: "Project Viewer",

Callers

nothing calls this directly

Calls 10

useThemeFunction · 0.90
cnFunction · 0.90
logoutFunction · 0.90
_getActiveMenuFunction · 0.85
_onChangeTeamFunction · 0.85
_getTeamRoleFunction · 0.85
_onCycleThemeFunction · 0.85
_getThemeFunction · 0.85
_canAccessFunction · 0.70
dispatchFunction · 0.50

Tested by

no test coverage detected