Skip to content

Commit

Permalink
feat: Remove responsibility from frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Oct 9, 2023
1 parent 459e21c commit 10c44f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 0 additions & 1 deletion editor.planx.uk/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@ const EditorToolbar: React.FC<{
? `All teams`
: user.teams
.map((team) => team.team.name)
.concat(["Templates"])
.join(", ")}
</ListItemText>
</MenuItem>
Expand Down
9 changes: 4 additions & 5 deletions editor.planx.uk/src/pages/FlowEditor/lib/store/user.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { User } from "@opensystemslab/planx-core/types";
import { User, UserTeams } from "@opensystemslab/planx-core/types";
import { _client } from "client";
import jwtDecode from "jwt-decode";
import { Team } from "types";
Expand All @@ -24,13 +24,12 @@ export const userStore: StateCreator<UserStore, [], [], UserStore> = (
canUserEditTeam(teamSlug) {
const user = this.getUser();
if (!user) return false;

const hasTeamEditorRole = (team: UserTeams) => team.role === "teamEditor" && team.team.slug === teamSlug;

return (
user.isPlatformAdmin ||
teamSlug === "templates" ||
user.teams.filter(
(team) => team.role === "teamEditor" && team.team.slug === teamSlug,
).length > 0
user.teams.some(hasTeamEditorRole)
);
},

Expand Down

0 comments on commit 10c44f8

Please sign in to comment.