Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only show locked banner if current user is in organization of the annotation #8273

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apparently the organization prop was already sent by the backend but the frontend discarded this.
-> I fixed this here.

Side note: But there might also be other fields the frontend drops in this function which might be useful to still have 🤔.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But there might also be other fields the frontend drops in this function which might be useful to still have 🤔.

if the frontend doesn't use these properties, there's no need to add them, I think.

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