const childrenCollection = Array.prototype.slice.call(Cypress.$(body).find('dict')[0].children);
const map = {};
let i, j = 2;
-
+
for (i=0; i < childrenCollection.length; i += j) {
map[childrenCollection[i].outerText] = childrenCollection[i + 1].outerText;
}
// on this loop may pass an assertion from the first iteration by looking
// for the same file name.
const fileName = isWritable ? 'bar' : 'foo';
+ const subDirName = 'subdir';
cy.createGroup(adminUser.token, {
name: 'Shared project',
group_class: 'project',
name: 'Test collection',
owner_uuid: this.sharedGroup.uuid,
properties: { someKey: 'someValue' },
- manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`
+ manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n./${subDirName} 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`
})
.as('testCollection').then(function () {
// Share the group with active user.
.should(`${isWritable ? '' : 'not.'}contain`, 'Upload data');
}
});
+ // Test context menus
cy.get('[data-cy=collection-files-panel]')
.contains(fileName).rightclick({ force: true });
cy.get('[data-cy=context-menu]')
.and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
.and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
cy.get('body').click(); // Collapse the menu
+ cy.get('[data-cy=collection-files-panel]')
+ .contains(subDirName).rightclick({ force: true });
+ cy.get('[data-cy=context-menu]')
+ .should('not.contain', 'Download')
+ .and('contain', 'Open in new tab')
+ .and('contain', 'Copy to clipboard')
+ .and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
+ .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
+ cy.get('body').click(); // Collapse the menu
// Hamburger 'more options' menu button
cy.get('[data-cy=collection-files-panel-options-btn]')
.click()
cy.get('[data-cy=collection-files-panel-options-btn]')
.click()
cy.get('[data-cy=context-menu]')
- // .should('contain', 'Download selected')
.should(`${isWritable ? '' : 'not.'}contain`, 'Remove selected')
cy.get('body').click(); // Collapse the menu
- // File item 'more options' button
- cy.get('[data-cy=file-item-options-btn')
- .click()
- cy.get('[data-cy=context-menu]')
- .should('contain', 'Download')
- .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
- cy.get('body').click(); // Collapse the menu
})
})
})
import { resourceActionSet } from '~/views-components/context-menu/action-sets/resource-action-set';
import { favoriteActionSet } from "~/views-components/context-menu/action-sets/favorite-action-set";
import { collectionFilesActionSet, readOnlyCollectionFilesActionSet } from '~/views-components/context-menu/action-sets/collection-files-action-set';
-import { collectionFilesItemActionSet, readOnlyCollectionFilesItemActionSet } from '~/views-components/context-menu/action-sets/collection-files-item-action-set';
+import { collectionDirectoryItemActionSet, collectionFileItemActionSet, readOnlyCollectionDirectoryItemActionSet, readOnlyCollectionFileItemActionSet } from '~/views-components/context-menu/action-sets/collection-files-item-action-set';
import { collectionFilesNotSelectedActionSet } from '~/views-components/context-menu/action-sets/collection-files-not-selected-action-set';
import { collectionActionSet, collectionAdminActionSet, oldCollectionVersionActionSet, readOnlyCollectionActionSet } from '~/views-components/context-menu/action-sets/collection-action-set';
import { processActionSet } from '~/views-components/context-menu/action-sets/process-action-set';
addMenuActionSet(ContextMenuKind.COLLECTION_FILES, collectionFilesActionSet);
addMenuActionSet(ContextMenuKind.READONLY_COLLECTION_FILES, readOnlyCollectionFilesActionSet);
addMenuActionSet(ContextMenuKind.COLLECTION_FILES_NOT_SELECTED, collectionFilesNotSelectedActionSet);
-addMenuActionSet(ContextMenuKind.COLLECTION_FILES_ITEM, collectionFilesItemActionSet);
-addMenuActionSet(ContextMenuKind.READONLY_COLLECTION_FILES_ITEM, readOnlyCollectionFilesItemActionSet);
+addMenuActionSet(ContextMenuKind.COLLECTION_DIRECTORY_ITEM, collectionDirectoryItemActionSet);
+addMenuActionSet(ContextMenuKind.READONLY_COLLECTION_DIRECTORY_ITEM, readOnlyCollectionDirectoryItemActionSet);
+addMenuActionSet(ContextMenuKind.COLLECTION_FILE_ITEM, collectionFileItemActionSet);
+addMenuActionSet(ContextMenuKind.READONLY_COLLECTION_FILE_ITEM, readOnlyCollectionFileItemActionSet);
addMenuActionSet(ContextMenuKind.COLLECTION, collectionActionSet);
addMenuActionSet(ContextMenuKind.READONLY_COLLECTION, readOnlyCollectionActionSet);
addMenuActionSet(ContextMenuKind.OLD_VERSION_COLLECTION, oldCollectionVersionActionSet);
dispatch(collectionPanelFilesAction.TOGGLE_COLLECTION_FILE_SELECTION({ id: item.id }));
},
onItemMenuOpen: (event, item, isWritable) => {
+ const isDirectory = item.data.type === 'directory';
dispatch<any>(openContextMenu(
event,
{
menuKind: isWritable
- ? ContextMenuKind.COLLECTION_FILES_ITEM
- : ContextMenuKind.READONLY_COLLECTION_FILES_ITEM,
+ ? isDirectory
+ ? ContextMenuKind.COLLECTION_DIRECTORY_ITEM
+ : ContextMenuKind.COLLECTION_FILE_ITEM
+ : isDirectory
+ ? ContextMenuKind.READONLY_COLLECTION_DIRECTORY_ITEM
+ : ContextMenuKind.READONLY_COLLECTION_FILE_ITEM,
kind: ResourceKind.COLLECTION,
name: item.data.name,
uuid: item.id,
import { ContextMenuActionSet } from "~/views-components/context-menu/context-menu-action-set";
import { collectionPanelFilesAction, openMultipleFilesRemoveDialog } from "~/store/collection-panel/collection-panel-files/collection-panel-files-actions";
import { openCollectionPartialCopyDialog, openCollectionPartialCopyToSelectedCollectionDialog } from '~/store/collections/collection-partial-copy-actions';
-// import { DownloadCollectionFileAction } from "~/views-components/context-menu/actions/download-collection-file-action";
+// These action sets are used on the multi-select actions button.
export const readOnlyCollectionFilesActionSet: ContextMenuActionSet = [[
{
name: "Select all",
dispatch(collectionPanelFilesAction.UNSELECT_ALL_COLLECTION_FILES());
}
},
- // { // Disabled for now as we need to create backend version of this feature which will be less buggy
- // component: DownloadCollectionFileAction,
- // execute: () => { return; }
- // },
{
name: "Create a new collection with selected",
execute: dispatch => {
import { CollectionFileViewerAction } from '~/views-components/context-menu/actions/collection-file-viewer-action';
import { CollectionCopyToClipboardAction } from "../actions/collection-copy-to-clipboard-action";
-export const readOnlyCollectionFilesItemActionSet: ContextMenuActionSet = [[
- {
- component: DownloadCollectionFileAction,
- execute: () => { return; }
- },
+export const readOnlyCollectionDirectoryItemActionSet: ContextMenuActionSet = [[
{
component: CollectionFileViewerAction,
execute: () => { return; },
}
]];
-export const collectionFilesItemActionSet: ContextMenuActionSet = readOnlyCollectionFilesItemActionSet.concat([[
+export const readOnlyCollectionFileItemActionSet: ContextMenuActionSet = [[
+ {
+ component: DownloadCollectionFileAction,
+ execute: () => { return; }
+ },
+ ...readOnlyCollectionDirectoryItemActionSet.reduce((prev, next) => prev.concat(next), []),
+]];
+
+const writableActionSet: ContextMenuActionSet = [[
{
name: "Rename",
icon: RenameIcon,
dispatch<any>(openFileRemoveDialog(resource.uuid));
}
}
-]]);
\ No newline at end of file
+]];
+
+export const collectionDirectoryItemActionSet: ContextMenuActionSet = readOnlyCollectionDirectoryItemActionSet.concat(writableActionSet);
+
+export const collectionFileItemActionSet: ContextMenuActionSet = readOnlyCollectionFileItemActionSet.concat(writableActionSet);
\ No newline at end of file
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 ||
- resource.menuKind === ContextMenuKind.READONLY_COLLECTION_FILES_ITEM)) {
+ if (resource && [
+ ContextMenuKind.COLLECTION_FILE_ITEM,
+ ContextMenuKind.READONLY_COLLECTION_FILE_ITEM,
+ ContextMenuKind.COLLECTION_DIRECTORY_ITEM,
+ ContextMenuKind.READONLY_COLLECTION_DIRECTORY_ITEM ].indexOf(resource.menuKind as ContextMenuKind) > -1) {
const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
if (file) {
return {
const mapStateToProps = (state: RootState) => {
const { resource } = state.contextMenu;
const currentCollectionUuid = state.collectionPanel.item ? state.collectionPanel.item.uuid : '';
- if (resource && (
- resource.menuKind === ContextMenuKind.COLLECTION_FILES_ITEM ||
- resource.menuKind === ContextMenuKind.READONLY_COLLECTION_FILES_ITEM)) {
+ if (resource && [
+ ContextMenuKind.COLLECTION_FILE_ITEM,
+ ContextMenuKind.READONLY_COLLECTION_FILE_ITEM,
+ ContextMenuKind.COLLECTION_DIRECTORY_ITEM,
+ ContextMenuKind.READONLY_COLLECTION_DIRECTORY_ITEM ].indexOf(resource.menuKind as ContextMenuKind) > -1) {
const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
if (file) {
const fileUrl = sanitizeToken(getInlineFileUrl(
const mapStateToProps = (state: RootState) => {
const { resource } = state.contextMenu;
const currentCollectionUuid = state.collectionPanel.item ? state.collectionPanel.item.uuid : '';
- if (resource && (
- resource.menuKind === ContextMenuKind.COLLECTION_FILES_ITEM ||
- resource.menuKind === ContextMenuKind.READONLY_COLLECTION_FILES_ITEM)) {
+ if (resource && [
+ ContextMenuKind.COLLECTION_FILE_ITEM,
+ ContextMenuKind.READONLY_COLLECTION_FILE_ITEM,
+ ContextMenuKind.COLLECTION_DIRECTORY_ITEM,
+ ContextMenuKind.READONLY_COLLECTION_DIRECTORY_ITEM ].indexOf(resource.menuKind as ContextMenuKind) > -1) {
const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
if (file) {
return {
TRASH = "Trash",
COLLECTION_FILES = "CollectionFiles",
READONLY_COLLECTION_FILES = "ReadOnlyCollectionFiles",
- COLLECTION_FILES_ITEM = "CollectionFilesItem",
- READONLY_COLLECTION_FILES_ITEM = "ReadOnlyCollectionFilesItem",
+ COLLECTION_FILE_ITEM = "CollectionFileItem",
+ COLLECTION_DIRECTORY_ITEM = "CollectionDirectoryItem",
+ READONLY_COLLECTION_FILE_ITEM = "ReadOnlyCollectionFileItem",
+ READONLY_COLLECTION_DIRECTORY_ITEM = "ReadOnlyCollectionDirectoryItem",
COLLECTION_FILES_NOT_SELECTED = "CollectionFilesNotSelected",
COLLECTION = 'Collection',
COLLECTION_ADMIN = 'CollectionAdmin',