Skip to content

Commit

Permalink
Allow dataset managers to see all workflow reports of their orga (#7081)
Browse files Browse the repository at this point in the history
* Allow dataset managers to see all workflow reports of their orga

* also show administration menu to dataset managers

* avoid empty admin menu

---------

Co-authored-by: Philipp Otto <[email protected]>
  • Loading branch information
fm3 and philippotto authored May 23, 2023
1 parent 13f6019 commit 4b2e928
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 47 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Loading of precomputed meshes got significantly faster (especially when using a mesh file for an oversegmentation with an applied agglomerate mapping). [#7001](https://github.com/scalableminds/webknossos/pull/7001)
- Improved speed of proofreading by only reloading affected areas after a split or merge. [#7050](https://github.com/scalableminds/webknossos/pull/7050)
- The minimum length of layer names in datasets was set from 3 to 1, enabling single-character names for layers. [#7064](https://github.com/scalableminds/webknossos/pull/7064)
- All dataset managers are now allowed to see all voxelytics workflow reports created in their organization. Previously, only admins could see all workflow reports, with other users seeing only their own. [#7080](https://github.com/scalableminds/webknossos/pull/7080)
- Improved performance for large meshes, especially when loaded from a precomputed oversegmentation mesh file. [#7077](https://github.com/scalableminds/webknossos/pull/7077)

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion app/models/voxelytics/VoxelyticsDAO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class VoxelyticsDAO @Inject()(sqlClient: SqlClient)(implicit ec: ExecutionContex
private def visibleRunsQ(currentUser: User, allowUnlisted: Boolean) = {
val organizationId = currentUser._organization
val readAccessQ =
if (currentUser.isAdmin || allowUnlisted) q"${true}"
if (currentUser.isAdmin || currentUser.isDatasetManager || allowUnlisted) q"${true}"
else q"(__r._user = ${currentUser._id})"
q"""SELECT __r.*
FROM webknossos.voxelytics_runs __r
Expand Down
6 changes: 5 additions & 1 deletion frontend/javascripts/libs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ export function isUserAdmin(user: APIUser): boolean {
}

export function isUserAdminOrTeamManager(user: APIUser): boolean {
return user.isAdmin || isUserTeamManager(user);
return isUserAdmin(user) || isUserTeamManager(user);
}

export function isUserDatasetManager(user: APIUser): boolean {
Expand All @@ -473,6 +473,10 @@ export function isUserAdminOrDatasetManager(user: APIUser | null | undefined): b
return user != null && (isUserAdmin(user) || isUserDatasetManager(user));
}

export function isUserAdminOrManager(user: APIUser): boolean {
return isUserAdmin(user) || isUserTeamManager(user) || isUserDatasetManager(user);
}

export function mayUserEditDataset(user: APIUser | null | undefined, dataset: APIDataset): boolean {
return (
isUserAdminOrDatasetManager(user) &&
Expand Down
94 changes: 49 additions & 45 deletions frontend/javascripts/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,40 +185,42 @@ function getCollapsibleMenuTitle(
);
}

function getAdministrationSubMenu(
collapse: boolean,
isAdmin: boolean,
organization: string,
): SubMenuType {
const adminstrationSubMenuItems = [
{ key: "/users", label: <Link to="/users">Users</Link> },
{ key: "/teams", label: <Link to="/teams">Teams</Link> },
{
key: "/projects",
label: (
<PricingEnforcedSpan requiredPricingPlan={PricingPlanEnum.Team}>
<Link to="/projects">Projects</Link>
</PricingEnforcedSpan>
),
},
{
key: "/tasks",
label: (
<PricingEnforcedSpan requiredPricingPlan={PricingPlanEnum.Team}>
<Link to="/tasks">Tasks</Link>
</PricingEnforcedSpan>
),
},
{
key: "/taskTypes",
label: (
<PricingEnforcedSpan requiredPricingPlan={PricingPlanEnum.Team}>
<Link to="/taskTypes">Task Types</Link>
</PricingEnforcedSpan>
),
},
{ key: "/scripts", label: <Link to="/scripts">Scripts</Link> },
];
function getAdministrationSubMenu(collapse: boolean, activeUser: APIUser) {
const isAdmin = Utils.isUserAdmin(activeUser);
const isAdminOrTeamManager = Utils.isUserAdminOrTeamManager(activeUser);
const organization = activeUser.organization;

const adminstrationSubMenuItems = isAdminOrTeamManager
? [
{ key: "/users", label: <Link to="/users">Users</Link> },
{ key: "/teams", label: <Link to="/teams">Teams</Link> },
{
key: "/projects",
label: (
<PricingEnforcedSpan requiredPricingPlan={PricingPlanEnum.Team}>
<Link to="/projects">Projects</Link>
</PricingEnforcedSpan>
),
},
{
key: "/tasks",
label: (
<PricingEnforcedSpan requiredPricingPlan={PricingPlanEnum.Team}>
<Link to="/tasks">Tasks</Link>
</PricingEnforcedSpan>
),
},
{
key: "/taskTypes",
label: (
<PricingEnforcedSpan requiredPricingPlan={PricingPlanEnum.Team}>
<Link to="/taskTypes">Task Types</Link>
</PricingEnforcedSpan>
),
},
{ key: "/scripts", label: <Link to="/scripts">Scripts</Link> },
]
: [];

if (features().jobsEnabled)
adminstrationSubMenuItems.push({
Expand All @@ -238,6 +240,10 @@ function getAdministrationSubMenu(
label: <Link to="/workflows">Voxelytics</Link>,
});

if (adminstrationSubMenuItems.length === 0) {
return null;
}

return {
key: "adminMenu",
className: collapse ? "hide-on-small-screen" : "",
Expand Down Expand Up @@ -302,7 +308,7 @@ function getHelpSubMenu(
version: string | null,
polledVersion: string | null,
isAuthenticated: boolean,
isAdminOrTeamManager: boolean,
isAdminOrManager: boolean,
collapse: boolean,
openHelpModal: MenuClickEventHandler,
) {
Expand All @@ -320,7 +326,7 @@ function getHelpSubMenu(
</a>
),
},
(!features().discussionBoardRequiresAdmin || isAdminOrTeamManager) &&
(!features().discussionBoardRequiresAdmin || isAdminOrManager) &&
features().discussionBoard !== false
? {
key: "discussion-board",
Expand Down Expand Up @@ -746,9 +752,7 @@ function Navbar({

const _isAuthenticated = isAuthenticated && activeUser != null;

const isAdmin = activeUser != null ? Utils.isUserAdmin(activeUser) : false;
const isAdminOrTeamManager =
activeUser != null ? Utils.isUserAdminOrTeamManager(activeUser) : false;
const isAdminOrManager = activeUser != null ? Utils.isUserAdminOrManager(activeUser) : false;
const collapseAllNavItems = isInAnnotationView;
const hideNavbarLogin = features().hideNavbarLogin || !hasOrganizations;
const menuItems: ItemType[] = [
Expand All @@ -773,11 +777,11 @@ function Navbar({
const loggedInUser: APIUser = activeUser;
menuItems.push(getDashboardSubMenu(collapseAllNavItems));

if (isAdminOrTeamManager && activeUser != null) {
menuItems.push(
getAdministrationSubMenu(collapseAllNavItems, isAdmin, activeUser.organization),
);
menuItems.push(getStatisticsSubMenu(collapseAllNavItems));
if (isAdminOrManager && activeUser != null) {
menuItems.push(getAdministrationSubMenu(collapseAllNavItems, activeUser));
if (Utils.isUserAdminOrTeamManager(activeUser)) {
menuItems.push(getStatisticsSubMenu(collapseAllNavItems));
}
} else {
menuItems.push(getTimeTrackingMenu(collapseAllNavItems));
}
Expand Down Expand Up @@ -810,7 +814,7 @@ function Navbar({
version,
polledVersion,
_isAuthenticated,
isAdminOrTeamManager,
isAdminOrManager,
collapseAllNavItems,
() => setIsHelpModalOpen(true),
),
Expand Down

0 comments on commit 4b2e928

Please sign in to comment.