[ARVADOS-WORKBENCH2] updated: 2.1.0-21-g67d77b20
Git user
git at public.arvados.org
Mon Oct 19 19:39:26 UTC 2020
Summary of changes:
.../collection-service/collection-service.ts | 4 ++--
.../open-in-new-tab/open-in-new-tab.actions.ts | 28 ++++++++++++++++++++++
.../context-menu/actions/download-action.tsx | 2 +-
.../actions/download-collection-file-action.tsx | 3 ++-
.../context-menu/actions/helpers.test.ts | 4 ++--
.../context-menu/actions/helpers.ts | 4 ++--
6 files changed, 37 insertions(+), 8 deletions(-)
create mode 100644 src/store/open-in-new-tab/open-in-new-tab.actions.ts
via 67d77b206ebee7c776bd4d7dbc112ebb0c7ba800 (commit)
from 7b3802bf303c74f321317742a146c286ff047b00 (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 67d77b206ebee7c776bd4d7dbc112ebb0c7ba800
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date: Mon Oct 19 21:37:24 2020 +0200
16812: Cleared token code
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
diff --git a/src/services/collection-service/collection-service.ts b/src/services/collection-service/collection-service.ts
index 90441a64..0aa0aa84 100644
--- a/src/services/collection-service/collection-service.ts
+++ b/src/services/collection-service/collection-service.ts
@@ -65,8 +65,8 @@ export class CollectionService extends TrashableResourceService<CollectionResour
? this.webdavClient.defaults.baseURL.slice(0, -1)
: this.webdavClient.defaults.baseURL;
const apiToken = this.authService.getApiToken();
- const splittedApiToken = apiToken ? apiToken.split('/') : [];
- const userApiToken = `/t=${splittedApiToken[2]}/`;
+ const encodedApiToken = apiToken ? encodeURI(apiToken) : '';
+ const userApiToken = `/t=${encodedApiToken}/`;
const splittedPrevFileUrl = file.url.split('/');
const url = `${baseUrl}/${splittedPrevFileUrl[1]}${userApiToken}${splittedPrevFileUrl.slice(2).join('/')}`;
return {
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
new file mode 100644
index 00000000..42bdc4cc
--- /dev/null
+++ b/src/store/open-in-new-tab/open-in-new-tab.actions.ts
@@ -0,0 +1,28 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch } from 'redux';
+import { ResourceKind } from '~/models/resource';
+import { unionize, ofType } from '~/common/unionize';
+
+export const openInNewTabActions = unionize({
+ COPY_STORE: ofType<{}>(),
+ OPEN_COLLECTION_IN_NEW_TAB: ofType<string>(),
+ OPEN_PROJECT_IN_NEW_TAB: ofType<string>()
+});
+
+export const openInNewTabAction = (resource: any) => (dispatch: Dispatch) => {
+ const { uuid, kind } = resource;
+
+ dispatch(openInNewTabActions.COPY_STORE());
+
+ if (kind === ResourceKind.COLLECTION) {
+ dispatch(openInNewTabActions.OPEN_COLLECTION_IN_NEW_TAB(uuid));
+ }
+ if (kind === ResourceKind.PROJECT) {
+ dispatch(openInNewTabActions.OPEN_PROJECT_IN_NEW_TAB(uuid));
+ }
+
+ console.log(uuid);
+};
\ No newline at end of file
diff --git a/src/views-components/context-menu/actions/download-action.tsx b/src/views-components/context-menu/actions/download-action.tsx
index 7468954f..86694c8b 100644
--- a/src/views-components/context-menu/actions/download-action.tsx
+++ b/src/views-components/context-menu/actions/download-action.tsx
@@ -47,7 +47,7 @@ export const DownloadAction = (props: { href?: any, download?: any, onClick?: ()
return props.href || props.kind === 'files'
? <a
style={{ textDecoration: 'none' }}
- href={props.kind === 'files' ? undefined : `${props.href}?disposition=attachment`}
+ href={props.kind === 'files' ? undefined : `${props.href}&disposition=attachment`}
onClick={props.onClick}
{...downloadProps}>
<ListItem button onClick={() => props.kind === 'files' ? createZip(props.href, props.download) : undefined}>
diff --git a/src/views-components/context-menu/actions/download-collection-file-action.tsx b/src/views-components/context-menu/actions/download-collection-file-action.tsx
index 7849109d..3e4e4a0b 100644
--- a/src/views-components/context-menu/actions/download-collection-file-action.tsx
+++ b/src/views-components/context-menu/actions/download-collection-file-action.tsx
@@ -8,6 +8,7 @@ import { DownloadAction } from "./download-action";
import { getNodeValue } from "../../../models/tree";
import { ContextMenuKind } from '../context-menu';
import { filterCollectionFilesBySelection } from "~/store/collection-panel/collection-panel-files/collection-panel-files-state";
+import { sanitizeToken } from "./helpers";
const mapStateToProps = (state: RootState) => {
const { resource } = state.contextMenu;
@@ -16,7 +17,7 @@ const mapStateToProps = (state: RootState) => {
const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
if (file) {
return {
- href: file.url,
+ href: sanitizeToken(file.url, true),
kind: 'file',
currentCollectionUuid
};
diff --git a/src/views-components/context-menu/actions/helpers.test.ts b/src/views-components/context-menu/actions/helpers.test.ts
index 6aaacc2f..9750a1cc 100644
--- a/src/views-components/context-menu/actions/helpers.test.ts
+++ b/src/views-components/context-menu/actions/helpers.test.ts
@@ -6,7 +6,7 @@ import { sanitizeToken, getClipboardUrl } from "./helpers";
describe('helpers', () => {
// given
- const url = 'https://collections.ardev.roche.com/c=ardev-4zz18-k0hamvtwyit6q56/t=1ha4ykd3w14ed19b2gh3uyjrjup38vsx27x1utwdne0bxcfg5d/LIMS/1.html';
+ const url = 'https://collections.ardev.roche.com/c=ardev-4zz18-k0hamvtwyit6q56/t=v2/arlog-gj3su-stk5unu8570brvs/fryzaq6z1ow1npak5nngldtkoup918isrvlualf134uf1fbtd/LIMS/1.html';
describe('sanitizeToken', () => {
it('should sanitize token from the url', () => {
@@ -14,7 +14,7 @@ describe('helpers', () => {
const result = sanitizeToken(url);
// then
- expect(result).toBe('https://collections.ardev.roche.com/c=ardev-4zz18-k0hamvtwyit6q56/LIMS/1.html?api_token=1ha4ykd3w14ed19b2gh3uyjrjup38vsx27x1utwdne0bxcfg5d');
+ expect(result).toBe('https://collections.ardev.roche.com/c=ardev-4zz18-k0hamvtwyit6q56/LIMS/1.html?api_token=v2/arlog-gj3su-stk5unu8570brvs/fryzaq6z1ow1npak5nngldtkoup918isrvlualf134uf1fbtd');
});
});
diff --git a/src/views-components/context-menu/actions/helpers.ts b/src/views-components/context-menu/actions/helpers.ts
index 419c796d..8dfcaca0 100644
--- a/src/views-components/context-menu/actions/helpers.ts
+++ b/src/views-components/context-menu/actions/helpers.ts
@@ -4,8 +4,8 @@
export const sanitizeToken = (href: string, tokenAsQueryParam: boolean = true): string => {
const [prefix, suffix] = href.split('/t=');
- const [token, ...rest] = suffix.split('/');
-
+ const [token1, token2, token3, ...rest] = suffix.split('/');
+ const token = `${token1}/${token2}/${token3}`;
const sep = href.indexOf("?") > -1 ? "&" : "?";
return `${[prefix, ...rest].join('/')}${tokenAsQueryParam ? `${sep}api_token=${token}` : ''}`;
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list