[ARVADOS-WORKBENCH2] created: 1.4.1-289-gbac226c8
Git user
git at public.arvados.org
Thu Feb 27 16:13:34 UTC 2020
at bac226c86a2177e24b78aac2a836fadf3fce18c6 (commit)
commit bac226c86a2177e24b78aac2a836fadf3fce18c6
Author: PiotrAleksander <piotrhugonow at gmail.com>
Date: Wed Feb 26 12:44:37 2020 +0100
16118 WIP removed default writableBy value
diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx
index 3e0aab65..faaf623b 100644
--- a/src/views/collection-panel/collection-panel.tsx
+++ b/src/views/collection-panel/collection-panel.tsx
@@ -155,7 +155,7 @@ export const CollectionPanel = withStyles(styles)(
handleContextMenu = (event: React.MouseEvent<any>) => {
const { userUuid } = this.props;
- const { uuid, ownerUuid, name, description, kind, isTrashed, writableBy = [] } = this.props.item;
+ const { uuid, ownerUuid, name, description, kind, isTrashed, writableBy } = this.props.item;
const writable = writableBy.indexOf(userUuid) >= 0;
const menuKind = writable ? isTrashed
? ContextMenuKind.TRASHED_COLLECTION
commit 177c1c9ef2900fe814bccacba958ce11d4f07062
Author: PiotrAleksander <piotrhugonow at gmail.com>
Date: Wed Feb 26 11:58:13 2020 +0100
16118 WIP added non_writable_collection contextMenuKind used if writableBy does not contain userUuid
diff --git a/public/config.json b/public/config.json
new file mode 100644
index 00000000..d51bce26
--- /dev/null
+++ b/public/config.json
@@ -0,0 +1,3 @@
+{
+ "API_HOST": "ce8i5.arvadosapi.com"
+}
diff --git a/src/index.tsx b/src/index.tsx
index bf810fb7..990aa398 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -28,6 +28,7 @@ import { collectionFilesActionSet } from '~/views-components/context-menu/action
import { collectionFilesItemActionSet } 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 } from '~/views-components/context-menu/action-sets/collection-action-set';
+import { nonWritableCollectionActionSet } from '~/views-components/context-menu/action-sets/non-writable-collection-action-set';
import { collectionResourceActionSet } from '~/views-components/context-menu/action-sets/collection-resource-action-set';
import { processActionSet } from '~/views-components/context-menu/action-sets/process-action-set';
import { loadWorkbench } from '~/store/workbench/workbench-actions';
@@ -73,6 +74,7 @@ addMenuActionSet(ContextMenuKind.COLLECTION_FILES, collectionFilesActionSet);
addMenuActionSet(ContextMenuKind.COLLECTION_FILES_NOT_SELECTED, collectionFilesNotSelectedActionSet);
addMenuActionSet(ContextMenuKind.COLLECTION_FILES_ITEM, collectionFilesItemActionSet);
addMenuActionSet(ContextMenuKind.COLLECTION, collectionActionSet);
+addMenuActionSet(ContextMenuKind.NON_WRITABLE_COLLECTION, nonWritableCollectionActionSet);
addMenuActionSet(ContextMenuKind.COLLECTION_RESOURCE, collectionResourceActionSet);
addMenuActionSet(ContextMenuKind.TRASHED_COLLECTION, trashedCollectionActionSet);
addMenuActionSet(ContextMenuKind.PROCESS, processActionSet);
diff --git a/src/models/collection.ts b/src/models/collection.ts
index baa25c7a..e22b44b3 100644
--- a/src/models/collection.ts
+++ b/src/models/collection.ts
@@ -23,6 +23,7 @@ export interface CollectionResource extends TrashableResource {
unsignedManifestText?: string;
fileCount: number;
fileSizeTotal: number;
+ writableBy: string[];
}
export const getCollectionUrl = (uuid: string) => {
diff --git a/src/store/advanced-tab/advanced-tab.tsx b/src/store/advanced-tab/advanced-tab.tsx
index f11e54ff..d60d0941 100644
--- a/src/store/advanced-tab/advanced-tab.tsx
+++ b/src/store/advanced-tab/advanced-tab.tsx
@@ -435,7 +435,7 @@ const containerRequestApiResponse = (apiResponse: ContainerRequestResource) => {
const collectionApiResponse = (apiResponse: CollectionResource) => {
const { uuid, ownerUuid, createdAt, modifiedAt, modifiedByClientUuid, modifiedByUserUuid, name, description, properties, portableDataHash, replicationDesired,
replicationConfirmedAt, replicationConfirmed, manifestText, deleteAt, trashAt, isTrashed, storageClassesDesired,
- storageClassesConfirmed, storageClassesConfirmedAt, currentVersionUuid, version, preserveVersion, fileCount, fileSizeTotal } = apiResponse;
+ storageClassesConfirmed, storageClassesConfirmedAt, currentVersionUuid, version, preserveVersion, fileCount, fileSizeTotal, writableBy } = apiResponse;
const response = `
"uuid": "${uuid}",
"owner_uuid": "${ownerUuid}",
@@ -461,7 +461,8 @@ const collectionApiResponse = (apiResponse: CollectionResource) => {
"version": ${version},
"preserve_version": ${preserveVersion},
"file_count": ${fileCount},
-"file_size_total": ${fileSizeTotal}`;
+"file_size_total": ${fileSizeTotal},
+"writable_by": ${writableBy}`;
return <span style={{ marginLeft: '-15px' }}>{'{'} {response} {'\n'} <span style={{ marginLeft: '-15px' }}>{'}'}</span></span>;
};
diff --git a/src/views-components/context-menu/action-sets/non-writable-collection-action-set.ts b/src/views-components/context-menu/action-sets/non-writable-collection-action-set.ts
new file mode 100644
index 00000000..7c15d424
--- /dev/null
+++ b/src/views-components/context-menu/action-sets/non-writable-collection-action-set.ts
@@ -0,0 +1,53 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { ContextMenuActionSet } from "../context-menu-action-set";
+import { ToggleFavoriteAction } from "../actions/favorite-action";
+import { toggleFavorite } from "~/store/favorites/favorites-actions";
+import { ShareIcon, CopyIcon, DetailsIcon } from "~/components/icon/icon";
+import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action";
+import { openCollectionCopyDialog } from "~/store/collections/collection-copy-actions";
+import { ToggleTrashAction } from "~/views-components/context-menu/actions/trash-action";
+import { toggleCollectionTrashed } from "~/store/trash/trash-actions";
+import { openSharingDialog } from '~/store/sharing-dialog/sharing-dialog-actions';
+import { toggleDetailsPanel } from '~/store/details-panel/details-panel-action';
+
+export const nonWritableCollectionActionSet: ContextMenuActionSet = [[
+ {
+ icon: ShareIcon,
+ name: "Share",
+ execute: (dispatch, { uuid }) => {
+ dispatch<any>(openSharingDialog(uuid));
+ }
+ },
+ {
+ component: ToggleFavoriteAction,
+ execute: (dispatch, resource) => {
+ dispatch<any>(toggleFavorite(resource)).then(() => {
+ dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
+ });
+ }
+ },
+ {
+ icon: CopyIcon,
+ name: "Copy to project",
+ execute: (dispatch, resource) => {
+ dispatch<any>(openCollectionCopyDialog(resource));
+ }
+
+ },
+ {
+ icon: DetailsIcon,
+ name: "View details",
+ execute: dispatch => {
+ dispatch<any>(toggleDetailsPanel());
+ }
+ },
+ {
+ component: ToggleTrashAction,
+ execute: (dispatch, resource) => {
+ dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!));
+ }
+ },
+]];
diff --git a/src/views-components/context-menu/context-menu.tsx b/src/views-components/context-menu/context-menu.tsx
index 65e98cc5..f1c27866 100644
--- a/src/views-components/context-menu/context-menu.tsx
+++ b/src/views-components/context-menu/context-menu.tsx
@@ -73,6 +73,7 @@ export enum ContextMenuKind {
COLLECTION_FILES_ITEM = "CollectionFilesItem",
COLLECTION_FILES_NOT_SELECTED = "CollectionFilesNotSelected",
COLLECTION = 'Collection',
+ NON_WRITABLE_COLLECTION = 'NonWritableCollection',
COLLECTION_ADMIN = 'CollectionAdmin',
COLLECTION_RESOURCE = 'CollectionResource',
TRASHED_COLLECTION = 'TrashedCollection',
diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx
index c4221937..3e0aab65 100644
--- a/src/views/collection-panel/collection-panel.tsx
+++ b/src/views/collection-panel/collection-panel.tsx
@@ -25,6 +25,7 @@ import { openDetailsPanel } from '~/store/details-panel/details-panel-action';
import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
import { getPropertyChip } from '~/views-components/resource-properties-form/property-chip';
import { IllegalNamingWarning } from '~/components/warning/warning';
+import { getUserUuid } from '~/common/getuser';
type CssRules = 'card' | 'iconHeader' | 'tag' | 'label' | 'value' | 'link';
@@ -58,6 +59,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
interface CollectionPanelDataProps {
item: CollectionResource;
+ userUuid: string;
}
type CollectionPanelProps = CollectionPanelDataProps & DispatchProp
@@ -66,7 +68,8 @@ type CollectionPanelProps = CollectionPanelDataProps & DispatchProp
export const CollectionPanel = withStyles(styles)(
connect((state: RootState, props: RouteComponentProps<{ id: string }>) => {
const item = getResource(props.match.params.id)(state.resources);
- return { item };
+ const userUuid = getUserUuid(state);
+ return { item, userUuid };
})(
class extends React.Component<CollectionPanelProps> {
@@ -90,7 +93,7 @@ export const CollectionPanel = withStyles(styles)(
</IconButton>
</Tooltip>
}
- title={item && <span><IllegalNamingWarning name={item.name}/>{item.name}</span>}
+ title={item && <span><IllegalNamingWarning name={item.name} />{item.name}</span>}
titleTypographyProps={this.titleProps}
subheader={item && item.description}
subheaderTypographyProps={this.titleProps} />
@@ -129,15 +132,15 @@ export const CollectionPanel = withStyles(styles)(
<Grid item xs={12}>
{Object.keys(item.properties).map(k =>
Array.isArray(item.properties[k])
- ? item.properties[k].map((v: string) =>
- getPropertyChip(
- k, v,
- this.handleDelete(k, v),
- classes.tag))
- : getPropertyChip(
- k, item.properties[k],
- this.handleDelete(k, item.properties[k]),
- classes.tag)
+ ? item.properties[k].map((v: string) =>
+ getPropertyChip(
+ k, v,
+ this.handleDelete(k, v),
+ classes.tag))
+ : getPropertyChip(
+ k, item.properties[k],
+ this.handleDelete(k, item.properties[k]),
+ classes.tag)
)}
</Grid>
</Grid>
@@ -151,16 +154,20 @@ export const CollectionPanel = withStyles(styles)(
}
handleContextMenu = (event: React.MouseEvent<any>) => {
- const { uuid, ownerUuid, name, description, kind, isTrashed } = this.props.item;
+ const { userUuid } = this.props;
+ const { uuid, ownerUuid, name, description, kind, isTrashed, writableBy = [] } = this.props.item;
+ const writable = writableBy.indexOf(userUuid) >= 0;
+ const menuKind = writable ? isTrashed
+ ? ContextMenuKind.TRASHED_COLLECTION
+ : ContextMenuKind.COLLECTION : ContextMenuKind.NON_WRITABLE_COLLECTION;
+
const resource = {
uuid,
ownerUuid,
name,
description,
kind,
- menuKind: isTrashed
- ? ContextMenuKind.TRASHED_COLLECTION
- : ContextMenuKind.COLLECTION
+ menuKind
};
this.props.dispatch<any>(openContextMenu(event, resource));
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list