[ARVADOS-WORKBENCH2] updated: 2.1.0-15-g9525ed95

Git user git at public.arvados.org
Tue Oct 13 21:57:30 UTC 2020


Summary of changes:
 src/common/redirect-to.test.ts                               | 12 ++++++------
 src/common/redirect-to.ts                                    |  7 +++++--
 src/index.tsx                                                |  2 +-
 src/store/auth/auth-action.test.ts                           |  3 ++-
 src/store/auth/auth-middleware.test.ts                       |  3 ++-
 src/store/store.ts                                           |  6 +++---
 .../actions/collection-copy-to-clipboard-action.tsx          |  5 ++---
 .../context-menu/actions/collection-file-viewer-action.tsx   |  2 --
 .../context-menu/actions/download-collection-file-action.tsx |  8 +++-----
 .../context-menu/actions/file-viewer-action.tsx              |  6 ++----
 src/views-components/context-menu/actions/helpers.ts         |  3 ++-
 11 files changed, 28 insertions(+), 29 deletions(-)

       via  9525ed95bef2a8de63b48a0682c342465d29bae9 (commit)
      from  42ec7892e74f6d9d19f2f0155830565f447a861f (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 9525ed95bef2a8de63b48a0682c342465d29bae9
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date:   Tue Oct 13 23:56:04 2020 +0200

    16812: Removed download attribute, fixed redirectTo
    
    Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>

diff --git a/src/common/redirect-to.test.ts b/src/common/redirect-to.test.ts
index ad8ac9e0..177e1656 100644
--- a/src/common/redirect-to.test.ts
+++ b/src/common/redirect-to.test.ts
@@ -6,7 +6,10 @@ import { storeRedirects, handleRedirects } from './redirect-to';
 
 describe('redirect-to', () => {
     const { location } = window;
-    const redirectTo = 'http://localhost/test123';
+    const config: any = {
+        keepWebServiceUrl: 'http://localhost'
+    };
+    const redirectTo = '/test123';
     const locationTemplate = {
         hash: '',
         hostname: '',
@@ -68,14 +71,11 @@ describe('redirect-to', () => {
         });
 
         it('should redirect to page when it is present in session storage', () => {
-            // given
-            const token = 'testToken';
-
             // when
-            handleRedirects(token);
+            handleRedirects(config);
 
             // then
-            expect(window.location.href).toBe(`${redirectTo}?api_token=${token}`);
+            expect(window.location.href).toBe(`${config.keepWebServiceUrl}${redirectTo}`);
         });
     });
 });
\ No newline at end of file
diff --git a/src/common/redirect-to.ts b/src/common/redirect-to.ts
index 54268c24..86fac71c 100644
--- a/src/common/redirect-to.ts
+++ b/src/common/redirect-to.ts
@@ -2,6 +2,8 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
+import { Config } from './config';
+
 const REDIRECT_TO_KEY = 'redirectTo';
 
 export const storeRedirects = () => {
@@ -15,12 +17,13 @@ export const storeRedirects = () => {
     }
 };
 
-export const handleRedirects = (token: string) => {
+export const handleRedirects = (config: Config) => {
     const { sessionStorage } = window;
+    const { keepWebServiceUrl } = config;
 
     if (sessionStorage && sessionStorage.getItem(REDIRECT_TO_KEY)) {
         const redirectUrl = sessionStorage.getItem(REDIRECT_TO_KEY);
         sessionStorage.removeItem(REDIRECT_TO_KEY);
-        window.location.href = `${redirectUrl}?api_token=${token}`;
+        window.location.href = `${keepWebServiceUrl}${redirectUrl}`;
     }
 };
\ No newline at end of file
diff --git a/src/index.tsx b/src/index.tsx
index f87ff384..92a2716b 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -127,7 +127,7 @@ fetchConfig()
                 }
             }
         });
-        const store = configureStore(history, services);
+        const store = configureStore(history, services, config);
 
         store.subscribe(initListener(history, store, services, config));
         store.dispatch(initAuth(config));
diff --git a/src/store/auth/auth-action.test.ts b/src/store/auth/auth-action.test.ts
index 83a699a7..4e4a85e3 100644
--- a/src/store/auth/auth-action.test.ts
+++ b/src/store/auth/auth-action.test.ts
@@ -23,6 +23,7 @@ describe('auth-actions', () => {
 
     let store: RootStore;
     let services: ServiceRepository;
+    const config: any = {};
     const actions: ApiActions = {
         progressFn: (id: string, working: boolean) => { },
         errorFn: (id: string, message: string) => { }
@@ -32,7 +33,7 @@ describe('auth-actions', () => {
     beforeEach(() => {
         axiosMock.reset();
         services = createServices(mockConfig({}), actions, axiosInst);
-        store = configureStore(createBrowserHistory(), services);
+        store = configureStore(createBrowserHistory(), services, config);
         localStorage.clear();
         importMocks = [];
     });
diff --git a/src/store/auth/auth-middleware.test.ts b/src/store/auth/auth-middleware.test.ts
index 1fe34381..bcc942e1 100644
--- a/src/store/auth/auth-middleware.test.ts
+++ b/src/store/auth/auth-middleware.test.ts
@@ -18,6 +18,7 @@ describe("AuthMiddleware", () => {
     let store: RootStore;
     let services: ServiceRepository;
     let axiosInst: AxiosInstance;
+    const config: any = {};
     const actions: ApiActions = {
         progressFn: (id: string, working: boolean) => { },
         errorFn: (id: string, message: string) => { }
@@ -26,7 +27,7 @@ describe("AuthMiddleware", () => {
     beforeEach(() => {
         axiosInst = Axios.create({ headers: {} });
         services = createServices(mockConfig({}), actions, axiosInst);
-        store = configureStore(createBrowserHistory(), services);
+        store = configureStore(createBrowserHistory(), services, config);
         localStorage.clear();
     });
 
diff --git a/src/store/store.ts b/src/store/store.ts
index 0bc351bb..a6e0cbbe 100644
--- a/src/store/store.ts
+++ b/src/store/store.ts
@@ -69,6 +69,7 @@ import { ownerNameReducer } from '~/store/owner-name/owner-name-reducer';
 import { SubprocessMiddlewareService } from '~/store/subprocess-panel/subprocess-panel-middleware-service';
 import { SUBPROCESS_PANEL_ID } from '~/store/subprocess-panel/subprocess-panel-actions';
 import { ALL_PROCESSES_PANEL_ID } from './all-processes-panel/all-processes-panel-action';
+import { Config } from '~/common/config';
 
 const composeEnhancers =
     (process.env.NODE_ENV === 'development' &&
@@ -80,7 +81,7 @@ export type RootState = ReturnType<ReturnType<typeof createRootReducer>>;
 
 export type RootStore = Store<RootState, Action> & { dispatch: Dispatch<any> };
 
-export function configureStore(history: History, services: ServiceRepository): RootStore {
+export function configureStore(history: History, services: ServiceRepository, config: Config): RootStore {
     const rootReducer = createRootReducer(services);
 
     const projectPanelMiddleware = dataExplorerMiddleware(
@@ -135,8 +136,7 @@ export function configureStore(history: History, services: ServiceRepository): R
         const state = store.getState();
 
         if (state.auth && state.auth.apiToken) {
-            const { apiToken } = state.auth;
-            handleRedirects(apiToken);
+            handleRedirects(config);
         }
 
         return next(action);
diff --git a/src/views-components/context-menu/actions/collection-copy-to-clipboard-action.tsx b/src/views-components/context-menu/actions/collection-copy-to-clipboard-action.tsx
index 4ecdef70..f6038b80 100644
--- a/src/views-components/context-menu/actions/collection-copy-to-clipboard-action.tsx
+++ b/src/views-components/context-menu/actions/collection-copy-to-clipboard-action.tsx
@@ -5,19 +5,18 @@
 import { connect } from "react-redux";
 import { RootState } from "../../../store/store";
 import { getNodeValue } from "~/models/tree";
-import { CollectionFileType } from "~/models/collection-file";
 import { ContextMenuKind } from '~/views-components/context-menu/context-menu';
 import { CopyToClipboardAction } from "./copy-to-clipboard-action";
 
 const mapStateToProps = (state: RootState) => {
     const { resource } = state.contextMenu;
     const currentCollectionUuid = state.collectionPanel.item ? state.collectionPanel.item.uuid : '';
+    const { keepWebServiceUrl } = state.auth.config;
     if (resource && resource.menuKind === ContextMenuKind.COLLECTION_FILES_ITEM) {
         const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
         if (file) {
             return {
-                href: file.url,
-                download: file.type === CollectionFileType.DIRECTORY ? undefined : file.name,
+                href: file.url.replace(keepWebServiceUrl, ''),
                 kind: 'file',
                 currentCollectionUuid
             };
diff --git a/src/views-components/context-menu/actions/collection-file-viewer-action.tsx b/src/views-components/context-menu/actions/collection-file-viewer-action.tsx
index 0a202daf..cdc0c829 100644
--- a/src/views-components/context-menu/actions/collection-file-viewer-action.tsx
+++ b/src/views-components/context-menu/actions/collection-file-viewer-action.tsx
@@ -6,7 +6,6 @@ import { connect } from "react-redux";
 import { RootState } from "../../../store/store";
 import { FileViewerAction } from '~/views-components/context-menu/actions/file-viewer-action';
 import { getNodeValue } from "~/models/tree";
-import { CollectionFileType } from "~/models/collection-file";
 import { ContextMenuKind } from '~/views-components/context-menu/context-menu';
 
 const mapStateToProps = (state: RootState) => {
@@ -17,7 +16,6 @@ const mapStateToProps = (state: RootState) => {
         if (file) {
             return {
                 href: file.url,
-                download: file.type === CollectionFileType.DIRECTORY ? undefined : file.name,
                 kind: 'file',
                 currentCollectionUuid
             };
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 aadc1d11..9332d170 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
@@ -6,9 +6,9 @@ import { connect } from "react-redux";
 import { RootState } from "../../../store/store";
 import { DownloadAction } from "./download-action";
 import { getNodeValue } from "../../../models/tree";
-import { CollectionFileType } from "../../../models/collection-file";
 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;
@@ -17,8 +17,7 @@ const mapStateToProps = (state: RootState) => {
         const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
         if (file) {
             return {
-                href: file.url,
-                download: file.type === CollectionFileType.DIRECTORY ? undefined : file.name,
+                href: sanitizeToken(file.url, false),
                 kind: 'file',
                 currentCollectionUuid
             };
@@ -26,8 +25,7 @@ const mapStateToProps = (state: RootState) => {
     } else {
         const files = filterCollectionFilesBySelection(state.collectionPanelFiles, true);
         return {
-            href: files.map(file => file.url),
-            download: files.map(file => file.name),
+            href: files.map(file => sanitizeToken(file.url, false)),
             kind: 'files',
             currentCollectionUuid
         };
diff --git a/src/views-components/context-menu/actions/file-viewer-action.tsx b/src/views-components/context-menu/actions/file-viewer-action.tsx
index a2c32bea..e58ea6a7 100644
--- a/src/views-components/context-menu/actions/file-viewer-action.tsx
+++ b/src/views-components/context-menu/actions/file-viewer-action.tsx
@@ -8,15 +8,13 @@ import { OpenIcon } from "~/components/icon/icon";
 import { sanitizeToken } from "./helpers";
 
 export const FileViewerAction = (props: { href?: any, download?: any, onClick?: () => void, kind?: string, currentCollectionUuid?: string; }) => {
-    const fileProps = props.download ? { download: props.download } : {};
 
     return props.href
         ? <a
             style={{ textDecoration: 'none' }}
-            href={sanitizeToken(props.href)}
+            href={sanitizeToken(props.href, false)}
             target="_blank"
-            onClick={props.onClick}
-            {...fileProps}>
+            onClick={props.onClick}>
             <ListItem button>
                     <ListItemIcon>
                         <OpenIcon />
diff --git a/src/views-components/context-menu/actions/helpers.ts b/src/views-components/context-menu/actions/helpers.ts
index a8cc24b3..38368606 100644
--- a/src/views-components/context-menu/actions/helpers.ts
+++ b/src/views-components/context-menu/actions/helpers.ts
@@ -11,6 +11,7 @@ export const sanitizeToken = (href: string, tokenAsQueryParam: boolean = true):
 
 export const getClipboardUrl = (href: string): string => {
     const { origin } = window.location;
+    const url = sanitizeToken(href, false);
 
-    return `${origin}?redirectTo=${sanitizeToken(href, false)}`;
+    return `${origin}?redirectTo=${url}`;
 };
\ No newline at end of file

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list