[arvados-workbench2] updated: 2.4.0-161-gcd015a3c
git repository hosting
git at public.arvados.org
Thu Jul 28 20:03:26 UTC 2022
Summary of changes:
cypress/integration/search.spec.js | 2 +-
src/routes/routes.ts | 9 +++++++--
src/store/open-in-new-tab/open-in-new-tab.actions.ts | 20 ++++++++++++--------
.../actions/copy-to-clipboard-action.tsx | 4 ++--
.../context-menu/actions/helpers.test.ts | 4 ++--
src/views-components/context-menu/actions/helpers.ts | 5 ++++-
6 files changed, 28 insertions(+), 16 deletions(-)
via cd015a3c1aa2511da7c0063125a24065d37799bb (commit)
from 6aa9f73fef64bbca1e3b71eb526946d69d014246 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit cd015a3c1aa2511da7c0063125a24065d37799bb
Author: Stephen Smith <stephen at curii.com>
Date: Thu Jul 28 16:02:44 2022 -0400
19079: Don't use collection specific url processing for search result clipboard actions
Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen at curii.com>
diff --git a/cypress/integration/search.spec.js b/cypress/integration/search.spec.js
index 6f880e7f..86d86877 100644
--- a/cypress/integration/search.spec.js
+++ b/cypress/integration/search.spec.js
@@ -127,7 +127,7 @@ describe('Search tests', function() {
});
});
- it.only('shows search context menu', function() {
+ it('shows search context menu', function() {
const colName = `Collection ${Math.floor(Math.random() * Math.floor(999999))}`;
cy.createCollection(adminUser.token, {
diff --git a/src/routes/routes.ts b/src/routes/routes.ts
index 50689ec3..22c8f4c8 100644
--- a/src/routes/routes.ts
+++ b/src/routes/routes.ts
@@ -66,7 +66,10 @@ export const getResourceUrl = (uuid: string) => {
}
};
-export const getNavUrl = (uuid: string, config: FederationConfig) => {
+/**
+ * @returns A relative or federated url for the given uuid, with a token for federated WB1 urls
+ */
+export const getNavUrl = (uuid: string, config: FederationConfig, includeToken: boolean = true): string => {
const path = getResourceUrl(uuid) || "";
const cls = uuid.substring(0, 5);
if (cls === config.localCluster || extractUuidKind(uuid) === ResourceKind.USER || COLLECTION_PDH_REGEX.exec(uuid)) {
@@ -83,7 +86,9 @@ export const getNavUrl = (uuid: string, config: FederationConfig) => {
u = new URL(config.remoteHostsConfig[cls].workbench2Url);
} else {
u = new URL(config.remoteHostsConfig[cls].workbenchUrl);
- u.search = "api_token=" + config.sessions.filter((s) => s.clusterId === cls)[0].token;
+ if (includeToken) {
+ u.search = "api_token=" + config.sessions.filter((s) => s.clusterId === cls)[0].token;
+ }
}
u.pathname = path;
return u.toString();
diff --git a/src/store/open-in-new-tab/open-in-new-tab.actions.ts b/src/store/open-in-new-tab/open-in-new-tab.actions.ts
index a363bc03..c465aae8 100644
--- a/src/store/open-in-new-tab/open-in-new-tab.actions.ts
+++ b/src/store/open-in-new-tab/open-in-new-tab.actions.ts
@@ -3,21 +3,25 @@
// SPDX-License-Identifier: AGPL-3.0
import copy from 'copy-to-clipboard';
-import { getResourceUrl } from 'routes/routes';
-import { getClipboardUrl } from 'views-components/context-menu/actions/helpers';
+import { Dispatch } from 'redux';
+import { getNavUrl } from 'routes/routes';
+import { RootState } from 'store/store';
-export const openInNewTabAction = (resource: any) => () => {
- const url = getResourceUrl(resource.uuid);
+export const openInNewTabAction = (resource: any) => (dispatch: Dispatch, getState: () => RootState) => {
+ const url = getNavUrl(resource.uuid, getState().auth);
- if (url) {
+ if (url[0] === '/') {
window.open(`${window.location.origin}${url}`, '_blank');
+ } else if (url.length) {
+ window.open(url, '_blank');
}
};
-export const copyToClipboardAction = (resource: any) => () => {
- const url = getResourceUrl(resource.uuid);
+export const copyToClipboardAction = (resource: any) => (dispatch: Dispatch, getState: () => RootState) => {
+ // Copy to clipboard omits token to avoid accidental sharing
+ const url = getNavUrl(resource.uuid, getState().auth, false);
if (url) {
- copy(getClipboardUrl(url, false));
+ copy(url);
}
};
diff --git a/src/views-components/context-menu/actions/copy-to-clipboard-action.tsx b/src/views-components/context-menu/actions/copy-to-clipboard-action.tsx
index c3408740..50ed20fd 100644
--- a/src/views-components/context-menu/actions/copy-to-clipboard-action.tsx
+++ b/src/views-components/context-menu/actions/copy-to-clipboard-action.tsx
@@ -6,12 +6,12 @@ import React from "react";
import copy from 'copy-to-clipboard';
import { ListItemIcon, ListItemText, ListItem } from "@material-ui/core";
import { Link } from "components/icon/icon";
-import { getClipboardUrl } from "./helpers";
+import { getCollectionItemClipboardUrl } from "./helpers";
export const CopyToClipboardAction = (props: { href?: any, download?: any, onClick?: () => void, kind?: string, currentCollectionUuid?: string; }) => {
const copyToClipboard = () => {
if (props.href) {
- const clipboardUrl = getClipboardUrl(props.href, true, true);
+ const clipboardUrl = getCollectionItemClipboardUrl(props.href, true, true);
copy(clipboardUrl);
}
diff --git a/src/views-components/context-menu/actions/helpers.test.ts b/src/views-components/context-menu/actions/helpers.test.ts
index b3b7f7f8..7776d0e5 100644
--- a/src/views-components/context-menu/actions/helpers.test.ts
+++ b/src/views-components/context-menu/actions/helpers.test.ts
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: AGPL-3.0
-import { sanitizeToken, getClipboardUrl, getInlineFileUrl } from "./helpers";
+import { sanitizeToken, getCollectionItemClipboardUrl, getInlineFileUrl } from "./helpers";
describe('helpers', () => {
// given
@@ -22,7 +22,7 @@ describe('helpers', () => {
describe('getClipboardUrl', () => {
it('should add redirectTo query param', () => {
// when
- const result = getClipboardUrl(url);
+ const result = getCollectionItemClipboardUrl(url);
// then
expect(result).toBe('http://localhost?redirectToDownload=https://example.com/c=zzzzz-4zz18-0123456789abcde/LIMS/1.html');
diff --git a/src/views-components/context-menu/actions/helpers.ts b/src/views-components/context-menu/actions/helpers.ts
index f196074d..9140e457 100644
--- a/src/views-components/context-menu/actions/helpers.ts
+++ b/src/views-components/context-menu/actions/helpers.ts
@@ -14,7 +14,10 @@ export const sanitizeToken = (href: string, tokenAsQueryParam = true): string =>
return `${[prefix, ...rest].join('/')}${tokenAsQueryParam ? `${sep}api_token=${token}` : ''}`;
};
-export const getClipboardUrl = (href: string, shouldSanitizeToken = true, inline = false): string => {
+/**
+ * @returns A shareable token-free WB2 url that redirects to keep-web after login
+ */
+export const getCollectionItemClipboardUrl = (href: string, shouldSanitizeToken = true, inline = false): string => {
const { origin } = window.location;
const url = shouldSanitizeToken ? sanitizeToken(href, false) : href;
const redirectKey = inline ? REDIRECT_TO_PREVIEW_KEY : REDIRECT_TO_DOWNLOAD_KEY;
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list