Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>
? 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 {
--- /dev/null
+// 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
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}>
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;
const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
if (file) {
return {
- href: file.url,
+ href: sanitizeToken(file.url, true),
kind: 'file',
currentCollectionUuid
};
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', () => {
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');
});
});
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}` : ''}`;