Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>
}
});
cy.get('[data-cy=collection-files-panel]')
- .contains(fileName).rightclick();
+ .contains(fileName).rightclick({ force: true });
cy.get('[data-cy=context-menu]')
.should('contain', 'Download')
.and('contain', 'Open in new tab')
cy.get('[data-cy=context-menu]').contains('Remove selected').click();
cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
cy.get('[data-cy=collection-files-panel]').contains('#foo').should('not.exist');
+
+ cy.get('[data-cy=collection-files-panel]').contains('bar').rightclick();
+ cy.get('[data-cy=context-menu]').contains('Rename').click();
+ cy.get('input[name=path]').type('bar 123 321 bar');
+ cy.get('[data-cy=form-submit-btn]').click();
+ cy.get('[data-cy=collection-files-panel]').contains('barbar 123 321 bar').should('exist');
});
});
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
export function getUrlParameter(search: string, name: string) {
const safeName = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
const regex = new RegExp('[\\?&]' + safeName + '=([^&#]*)');
}
return u.toString();
}
+
+export const escapeHashIfRequired = (name: string, defaultTransformation?: Function) =>
+ name.indexOf('#') > -1 ?
+ encodeURIComponent(name) :
+ defaultTransformation ?
+ defaultTransformation(name) :
+ name;
\ No newline at end of file
//
// SPDX-License-Identifier: AGPL-3.0
+import { escapeHashIfRequired } from "./url";
+
export class WebDAV {
defaults: WebDAVDefaults = {
r.open(config.method,
`${this.defaults.baseURL
? this.defaults.baseURL+'/'
- : ''}${encodeURIComponent(config.url)}`);
+ : ''}${escapeHashIfRequired(config.url, encodeURI)}`);
const headers = { ...this.defaults.headers, ...config.headers };
Object
.keys(headers)
// SPDX-License-Identifier: AGPL-3.0
import { CollectionFile } from '~/models/collection-file';
-import { getFileFullPath } from './collection-service-files-response';
+import { getFileFullPath, extractFilesData } from './collection-service-files-response';
describe('collection-service-files-response', () => {
+
+ describe('extractFilesData', () => {
+ it('should extract', () => {
+ // given
+ const xmlString = '<D:multistatus xmlns:D="DAV:"><D:response><D:href>/c=xxxxx-zzzzz-vvvvvvvvvvvvvvv/</D:href><D:propstat><D:prop><D:resourcetype><D:collection xmlns:D="DAV:"/></D:resourcetype><D:getlastmodified>Wed, 24 Feb 2021 22:16:19 GMT</D:getlastmodified><D:supportedlock><D:lockentry xmlns:D="DAV:"><D:lockscope><D:exclusive/></D:lockscope><D:locktype><D:write/></D:locktype></D:lockentry></D:supportedlock><D:displayname></D:displayname></D:prop><D:status>HTTP/1.1 200 OK</D:status></D:propstat></D:response><D:response><D:href>/c=zzzzz-xxxxx-vvvvvvvvvvvvvvv/2</D:href><D:propstat><D:prop><D:getcontentlength>1582976</D:getcontentlength><D:getetag>"1666cee048aa7f98182780"</D:getetag><D:resourcetype></D:resourcetype><D:displayname>2</D:displayname><D:getlastmodified>Wed, 24 Feb 2021 22:16:19 GMT</D:getlastmodified><D:getcontenttype>text/plain; charset=utf-8</D:getcontenttype><D:supportedlock><D:lockentry xmlns:D="DAV:"><D:lockscope><D:exclusive/></D:lockscope><D:locktype><D:write/></D:locktype></D:lockentry></D:supportedlock></D:prop><D:status>HTTP/1.1 200 OK</D:status></D:propstat></D:response><D:response><D:href>/c=zzzzz-xxxxx-vvvvvvvvvvvvvvv/table%201%202%203</D:href><D:propstat><D:prop><D:resourcetype></D:resourcetype><D:getcontentlength>133352</D:getcontentlength><D:getetag>"1666cee048aa7f98208e8"</D:getetag><D:displayname>table 1 2 3</D:displayname><D:getlastmodified>Wed, 24 Feb 2021 22:16:19 GMT</D:getlastmodified><D:getcontenttype>text/plain; charset=utf-8</D:getcontenttype><D:supportedlock><D:lockentry xmlns:D="DAV:"><D:lockscope><D:exclusive/></D:lockscope><D:locktype><D:write/></D:locktype></D:lockentry></D:supportedlock></D:prop><D:status>HTTP/1.1 200 OK</D:status></D:propstat></D:response></D:multistatus>';
+ const parser = new DOMParser();
+ const xmlDoc = parser.parseFromString(xmlString, "text/xml");
+
+ // when
+ const result = extractFilesData(xmlDoc);
+
+ // then
+ expect(result).toEqual([{ id: "zzzzz-xxxxx-vvvvvvvvvvvvvvv/2", name: "2", path: "", size: 1582976, type: "file", url: "/c=zzzzz-xxxxx-vvvvvvvvvvvvvvv/2" }, { id: "zzzzz-xxxxx-vvvvvvvvvvvvvvv/table 1 2 3", name: "table 1 2 3", path: "", size: 133352, type: "file", url: "/c=zzzzz-xxxxx-vvvvvvvvvvvvvvv/table 1 2 3" }]);
+ });
+ });
+
describe('getFileFullPath', () => {
it('should encode weird names', async () => {
// given
- const file = {
+ const file = {
name: '#test',
path: 'http://localhost',
- } as CollectionFile;
+ } as CollectionFile;
// when
const result = getFileFullPath(file);
import { CollectionDirectory, CollectionFile, CollectionFileType, createCollectionDirectory, createCollectionFile } from "../../models/collection-file";
import { getTagValue } from "~/common/xml";
import { getNodeChildren, Tree, mapTree } from '~/models/tree';
+import { escapeHashIfRequired } from "~/common/url";
export const sortFilesTree = (tree: Tree<CollectionDirectory | CollectionFile>) => {
return mapTree<CollectionDirectory | CollectionFile>(node => {
const name = getTagValue(element, 'D:displayname', '');
const size = parseInt(getTagValue(element, 'D:getcontentlength', '0'), 10);
const url = getTagValue(element, 'D:href', '');
- const nameSuffix = `/${encodeURIComponent(name) || ''}`;
+ const nameSuffix = `/${escapeHashIfRequired(name) || ''}`;
const collectionUuidMatch = collectionUrlPrefix.exec(url);
const collectionUuid = collectionUuidMatch ? collectionUuidMatch.pop() : '';
const directory = url