Skip to content

Commit 40d8565

Browse files
committed
Pass sharingToken to dataset name disambiguation logic (#8625)
* Pass sharingToken to dataset name disambiguation logic * changelog * empty commit
1 parent 0233348 commit 40d8565

File tree

8 files changed

+75
-28
lines changed

8 files changed

+75
-28
lines changed

CHANGELOG.released.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
77
and this project adheres to [Calendar Versioning](http://calver.org/) `0Y.0M.MICRO`.
88
For upgrade instructions, please check the [migration guide](MIGRATIONS.released.md).
99

10+
## [25.05.1](https://github.com/scalableminds/webknossos/releases/tag/25.05.1) - 2025-05-19
11+
[Commits](https://github.com/scalableminds/webknossos/compare/25.05.0...25.05.1)
12+
13+
### Fixed
14+
15+
- Fixed viewing datasets with legacy-style links (without ids) by sharing token. [#8625](https://github.com/scalableminds/webknossos/pull/8625)
16+
17+
### Removed
18+
19+
### Breaking Changes
20+
21+
1022
## [25.05.0](https://github.com/scalableminds/webknossos/releases/tag/25.05.0) - 2025-04-29
1123
[Commits](https://github.com/scalableminds/webknossos/compare/25.04.0...25.05.0)
1224

@@ -2854,4 +2866,4 @@ Also the data viewing and tracing workflow is smoothed further:
28542866

28552867
## [18.07.0](https://github.com/scalableminds/webknossos/releases/tag/18.07.0) - 2018-07-05
28562868

2857-
First release
2869+
First release

CHANGELOG.unreleased.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ and this project adheres to [Calendar Versioning](http://calver.org/) `0Y.0M.MIC
88
For upgrade instructions, please check the [migration guide](MIGRATIONS.released.md).
99

1010
## Unreleased
11-
[Commits](https://github.com/scalableminds/webknossos/compare/25.05.0...HEAD)
11+
[Commits](https://github.com/scalableminds/webknossos/compare/25.05.1...HEAD)
1212

1313
### Added
1414

MIGRATIONS.released.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ See `MIGRATIONS.unreleased.md` for the changes which are not yet part of an offi
66
This project adheres to [Calendar Versioning](http://calver.org/) `0Y.0M.MICRO`.
77
User-facing changes are documented in the [changelog](CHANGELOG.released.md).
88

9+
## [25.05.1](https://github.com/scalableminds/webknossos/releases/tag/25.05.1) - 2025-05-19
10+
[Commits](https://github.com/scalableminds/webknossos/compare/25.05.0...25.05.1)
11+
12+
### Postgres Evolutions:
13+
14+
915
## [25.05.0](https://github.com/scalableminds/webknossos/releases/tag/25.05.0) - 2025-04-29
1016
[Commits](https://github.com/scalableminds/webknossos/compare/25.04.0...25.05.0)
1117

@@ -841,4 +847,4 @@ First release
841847
- [009-remove-team-assignment-from-task.sql](conf/evolutions/009-remove-team-assignment-from-task.sql)
842848
- [010-add-organization-data.sql](conf/evolutions/010-add-organization-data.sql)
843849
- [011-add-isOrganizationTeam.sql](conf/evolutions/011-add-isOrganizationTeam.sql)
844-
- [012-add-foreign-keys.sql](conf/evolutions/012-add-foreign-keys.sql)
850+
- [012-add-foreign-keys.sql](conf/evolutions/012-add-foreign-keys.sql)

MIGRATIONS.unreleased.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ This project adheres to [Calendar Versioning](http://calver.org/) `0Y.0M.MICRO`.
66
User-facing changes are documented in the [changelog](CHANGELOG.released.md).
77

88
## Unreleased
9-
[Commits](https://github.com/scalableminds/webknossos/compare/25.05.0...HEAD)
9+
[Commits](https://github.com/scalableminds/webknossos/compare/25.05.1...HEAD)
1010

1111
### Postgres Evolutions:

app/controllers/DatasetController.scala

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,17 +385,21 @@ class DatasetController @Inject()(userService: UserService,
385385
}
386386
}
387387

388-
def getOrganizationForDataset(datasetName: String): Action[AnyContent] = sil.UserAwareAction.async {
389-
implicit request =>
388+
def getOrganizationForDataset(datasetName: String, sharingToken: Option[String]): Action[AnyContent] =
389+
sil.UserAwareAction.async { implicit request =>
390+
val ctx = URLSharing.fallbackTokenAccessContext(sharingToken)
390391
for {
391-
organizationId <- datasetDAO.getOrganizationIdForDataset(datasetName)
392+
organizationId <- datasetDAO.getOrganizationIdForDataset(datasetName)(ctx)
392393
} yield Ok(Json.obj("organization" -> organizationId))
393-
}
394+
}
394395

395-
def getDatasetIdFromNameAndOrganization(datasetName: String, organizationId: String): Action[AnyContent] =
396+
def getDatasetIdFromNameAndOrganization(datasetName: String,
397+
organizationId: String,
398+
sharingToken: Option[String]): Action[AnyContent] =
396399
sil.UserAwareAction.async { implicit request =>
400+
val ctx = URLSharing.fallbackTokenAccessContext(sharingToken)
397401
for {
398-
datasetBox <- datasetDAO.findOneByNameAndOrganization(datasetName, organizationId).futureBox
402+
datasetBox <- datasetDAO.findOneByNameAndOrganization(datasetName, organizationId)(ctx).futureBox
399403
result <- (datasetBox match {
400404
case Full(dataset) =>
401405
Fox.successful(

conf/webknossos.latest.routes

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ GET /datasets
8181
POST /datasets controllers.DatasetController.create(typ: String)
8282
POST /datasets/exploreRemote controllers.DatasetController.exploreRemoteDataset()
8383
POST /datasets/exploreAndAddRemote controllers.DatasetController.exploreAndAddRemoteDataset()
84-
GET /datasets/disambiguate/:datasetName/toNew controllers.DatasetController.getOrganizationForDataset(datasetName: String)
85-
GET /datasets/disambiguate/:organizationId/:datasetName/toId controllers.DatasetController.getDatasetIdFromNameAndOrganization(datasetName: String, organizationId: String)
84+
GET /datasets/disambiguate/:datasetName/toNew controllers.DatasetController.getOrganizationForDataset(datasetName: String, sharingToken: Option[String])
85+
GET /datasets/disambiguate/:organizationId/:datasetName/toId controllers.DatasetController.getDatasetIdFromNameAndOrganization(datasetName: String, organizationId: String, sharingToken: Option[String])
8686
GET /datasets/:datasetId/health controllers.DatasetController.health(datasetId: ObjectId, sharingToken: Option[String])
8787
PATCH /datasets/:datasetId controllers.DatasetController.update(datasetId: ObjectId)
8888
PATCH /datasets/:datasetId/updatePartial controllers.DatasetController.updatePartial(datasetId: ObjectId)

frontend/javascripts/admin/api/disambiguate_legacy_routes.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import Request, { type RequestOptions } from "libs/request";
22

3-
export async function getOrganizationForDataset(datasetName: string): Promise<string> {
3+
export async function getOrganizationForDataset(
4+
datasetName: string,
5+
sharingToken?: string | null | undefined,
6+
): Promise<string> {
7+
const sharingTokenSuffix = sharingToken != null ? `?sharingToken=${sharingToken}` : "";
48
const { organization: organizationId } = await Request.receiveJSON(
5-
`/api/datasets/disambiguate/${datasetName}/toNew`,
9+
`/api/datasets/disambiguate/${datasetName}/toNew${sharingTokenSuffix}`,
610
);
711
return organizationId;
812
}

frontend/javascripts/router.tsx

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,17 @@ class ReactRouter extends React.Component<Props> {
156156
if (tracingType == null) {
157157
return <h3>Invalid annotation URL.</h3>;
158158
}
159+
const getParams = Utils.getUrlParamsObjectFromString(location.search);
159160
return (
160161
<AsyncRedirect
161162
redirectTo={async () => {
162163
const datasetName = match.params.datasetName || "";
163164
const organizationId = match.params.organizationId || "";
164-
const datasetId = await getDatasetIdFromNameAndOrganization(datasetName, organizationId);
165+
const datasetId = await getDatasetIdFromNameAndOrganization(
166+
datasetName,
167+
organizationId,
168+
getParams.token,
169+
);
165170
return `/datasets/${datasetName}-${datasetId}/sandbox/:${tracingType}${location.search}${location.hash}`;
166171
}}
167172
/>
@@ -173,6 +178,7 @@ class ReactRouter extends React.Component<Props> {
173178
const { datasetId, datasetName } = getDatasetIdOrNameFromReadableURLPart(
174179
match.params.datasetNameAndId,
175180
);
181+
const getParams = Utils.getUrlParamsObjectFromString(location.search);
176182

177183
if (tracingType == null) {
178184
return <h3>Invalid annotation URL.</h3>;
@@ -183,10 +189,11 @@ class ReactRouter extends React.Component<Props> {
183189
return (
184190
<AsyncRedirect
185191
redirectTo={async () => {
186-
const organizationId = await getOrganizationForDataset(datasetName);
192+
const organizationId = await getOrganizationForDataset(datasetName, getParams.token);
187193
const datasetId = await getDatasetIdFromNameAndOrganization(
188194
datasetName,
189195
organizationId,
196+
getParams.token,
190197
);
191198
return `/datasets/${datasetName}-${datasetId}/sandbox/${tracingType}${location.search}${location.hash}`;
192199
}}
@@ -205,31 +212,40 @@ class ReactRouter extends React.Component<Props> {
205212
);
206213
};
207214

208-
tracingViewModeLegacy = ({ match, location }: ContextRouter) => (
209-
<AsyncRedirect
210-
redirectTo={async () => {
211-
const datasetName = match.params.datasetName || "";
212-
const organizationId = match.params.organizationId || "";
213-
const datasetId = await getDatasetIdFromNameAndOrganization(datasetName, organizationId);
214-
return `/datasets/${datasetName}-${datasetId}/view${location.search}${location.hash}`;
215-
}}
216-
/>
217-
);
215+
tracingViewModeLegacy = ({ match, location }: ContextRouter) => {
216+
const getParams = Utils.getUrlParamsObjectFromString(location.search);
217+
return (
218+
<AsyncRedirect
219+
redirectTo={async () => {
220+
const datasetName = match.params.datasetName || "";
221+
const organizationId = match.params.organizationId || "";
222+
const datasetId = await getDatasetIdFromNameAndOrganization(
223+
datasetName,
224+
organizationId,
225+
getParams.token,
226+
);
227+
return `/datasets/${datasetName}-${datasetId}/view${location.search}${location.hash}`;
228+
}}
229+
/>
230+
);
231+
};
218232

219233
tracingViewMode = ({ match }: ContextRouter) => {
220234
const { datasetId, datasetName } = getDatasetIdOrNameFromReadableURLPart(
221235
match.params.datasetNameAndId,
222236
);
237+
const getParams = Utils.getUrlParamsObjectFromString(location.search);
223238
if (datasetName) {
224239
// Handle very old legacy URLs which neither have a datasetId nor an organizationId.
225240
// The schema is something like <authority>/datasets/:datasetName/view
226241
return (
227242
<AsyncRedirect
228243
redirectTo={async () => {
229-
const organizationId = await getOrganizationForDataset(datasetName);
244+
const organizationId = await getOrganizationForDataset(datasetName, getParams.token);
230245
const datasetId = await getDatasetIdFromNameAndOrganization(
231246
datasetName,
232247
organizationId,
248+
getParams.token,
233249
);
234250
return `/datasets/${datasetName}-${datasetId}/view${location.search}${location.hash}`;
235251
}}
@@ -508,16 +524,21 @@ class ReactRouter extends React.Component<Props> {
508524
const { datasetId, datasetName } = getDatasetIdOrNameFromReadableURLPart(
509525
match.params.datasetNameAndId,
510526
);
527+
const getParams = Utils.getUrlParamsObjectFromString(location.search);
511528
if (datasetName) {
512529
// Handle very old legacy URLs which neither have a datasetId nor an organizationId.
513530
// The schema is something like <authority>/datasets/:datasetName/edit
514531
return (
515532
<AsyncRedirect
516533
redirectTo={async () => {
517-
const organizationId = await getOrganizationForDataset(datasetName);
534+
const organizationId = await getOrganizationForDataset(
535+
datasetName,
536+
getParams.token,
537+
);
518538
const datasetId = await getDatasetIdFromNameAndOrganization(
519539
datasetName,
520540
organizationId,
541+
getParams.token,
521542
);
522543
return `/datasets/${datasetName}-${datasetId}/edit`;
523544
}}

0 commit comments

Comments
 (0)