Skip to content

Commit

Permalink
Only show locked banner if current user is in organization of the ann…
Browse files Browse the repository at this point in the history
…otation (#8273)

* only show locked banner if current user is in organization of the annotation

* remove debugger statements

* add changelog entry

---------

Co-authored-by: Michael Büßemeyer <[email protected]>
  • Loading branch information
MichaelBuessemeyer and Michael Büßemeyer authored Dec 12, 2024
1 parent 43fe639 commit 8c842c3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released

### Fixed
- Fixed that listing datasets with the `api/datasets` route without compression failed due to missing permissions regarding public datasets. [#8249](https://github.com/scalableminds/webknossos/pull/8249)
- A "Locked by anonymous user" banner is no longer shown when opening public editable annotations of other organizations. [#8273](https://github.com/scalableminds/webknossos/pull/8273)
- Fixed a bug that uploading a zarr dataset with an already existing `datasource-properties.json` file failed. [#8268](https://github.com/scalableminds/webknossos/pull/8268)
- Fixed the organization switching feature for datasets opened via old links. [#8257](https://github.com/scalableminds/webknossos/pull/8257)
- Fixed that the frontend did not ensure a minium length for annotation layer names. Moreover, names starting with a `.` are also disallowed now. [#8244](https://github.com/scalableminds/webknossos/pull/8244)
Expand Down
15 changes: 13 additions & 2 deletions frontend/javascripts/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ import constants from "oxalis/constants";
import { MaintenanceBanner, UpgradeVersionBanner } from "banners";
import { getAntdTheme, getSystemColorTheme } from "theme";
import { formatUserName } from "oxalis/model/accessors/user_accessor";
import { isAnnotationOwner as isAnnotationOwnerAccessor } from "oxalis/model/accessors/annotation_accessor";
import {
isAnnotationFromDifferentOrganization,
isAnnotationOwner as isAnnotationOwnerAccessor,
} from "oxalis/model/accessors/annotation_accessor";

const { Header } = Layout;

Expand All @@ -85,6 +88,7 @@ type StateProps = {
othersMayEdit: boolean;
allowUpdate: boolean;
isLockedByOwner: boolean;
isAnnotationFromDifferentOrganization: boolean;
isAnnotationOwner: boolean;
annotationOwnerName: string;
blockedByUser: APIUserCompact | null | undefined;
Expand Down Expand Up @@ -813,6 +817,7 @@ function Navbar({
allowUpdate,
annotationOwnerName,
isLockedByOwner,
isAnnotationFromDifferentOrganization,
navbarHeight,
isAnnotationOwner,
}: Props) {
Expand Down Expand Up @@ -877,7 +882,12 @@ function Navbar({
menuItems.push(getTimeTrackingMenu(collapseAllNavItems));
}

if (othersMayEdit && !allowUpdate && !isLockedByOwner) {
if (
othersMayEdit &&
!allowUpdate &&
!isLockedByOwner &&
!isAnnotationFromDifferentOrganization
) {
trailingNavItems.push(
<AnnotationLockedByUserTag
key="locked-by-user-tag"
Expand Down Expand Up @@ -1008,6 +1018,7 @@ const mapStateToProps = (state: OxalisState): StateProps => ({
isLockedByOwner: state.tracing.isLockedByOwner,
annotationOwnerName: formatUserName(state.activeUser, state.tracing.owner),
isAnnotationOwner: isAnnotationOwnerAccessor(state),
isAnnotationFromDifferentOrganization: isAnnotationFromDifferentOrganization(state),
navbarHeight: state.uiInformation.navbarHeight,
});

Expand Down
1 change: 1 addition & 0 deletions frontend/javascripts/oxalis/default_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ const defaultState: OxalisState = {
othersMayEdit: false,
blockedByUser: null,
annotationLayers: [],
organization: "",
},
save: {
queue: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ export function isAnnotationOwner(state: OxalisState) {
return !!(activeUser && owner?.id === activeUser.id);
}

export function isAnnotationFromDifferentOrganization(state: OxalisState) {
const activeUser = state.activeUser;

return !!(activeUser && activeUser?.organization !== state.tracing.organization);
}

export type SkeletonTracingStats = {
treeCount: number;
nodeCount: number;
Expand Down
2 changes: 2 additions & 0 deletions frontend/javascripts/oxalis/model/reducers/reducer_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export function convertServerAnnotationToFrontendAnnotation(annotation: APIAnnot
tracingStore,
owner,
contributors,
organization,
othersMayEdit,
isLockedByOwner,
annotationLayers,
Expand All @@ -108,6 +109,7 @@ export function convertServerAnnotationToFrontendAnnotation(annotation: APIAnnot
description,
name,
annotationType,
organization,
isLockedByOwner,
tracingStore,
owner,
Expand Down
1 change: 1 addition & 0 deletions frontend/javascripts/oxalis/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export type Annotation = {
readonly tags: Array<string>;
readonly description: string;
readonly name: string;
readonly organization: string;
readonly tracingStore: APITracingStore;
readonly annotationType: APIAnnotationType;
readonly owner: APIUserBase | null | undefined;
Expand Down

0 comments on commit 8c842c3

Please sign in to comment.