[ARVADOS-WORKBENCH2] updated: 1.1.4-372-gd75f24f
Git user
git at public.curoverse.com
Tue Jul 24 05:16:17 EDT 2018
Summary of changes:
.../favorite-service/favorite-service.test.ts | 4 ++--
src/services/favorite-service/favorite-service.ts | 10 ++++----
src/store/context-menu/context-menu-reducer.ts | 1 +
src/store/favorites/favorites-actions.ts | 12 +++++-----
.../context-menu/action-sets/project-action-set.ts | 2 +-
.../action-sets/resource-action-set.ts | 2 +-
src/views/workbench/workbench.tsx | 28 +++++++++++++++++-----
7 files changed, 38 insertions(+), 21 deletions(-)
via d75f24fb44ef0f09359508bc3c4d80340ec023b1 (commit)
from 464d663738d61871a3a0a88be18e8f79e99bb5f3 (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 d75f24fb44ef0f09359508bc3c4d80340ec023b1
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Tue Jul 24 11:11:51 2018 +0200
Save resource name when creating favorite
Feature #13784
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/services/favorite-service/favorite-service.test.ts b/src/services/favorite-service/favorite-service.test.ts
index 58c3bf4..e3a3bdf 100644
--- a/src/services/favorite-service/favorite-service.test.ts
+++ b/src/services/favorite-service/favorite-service.test.ts
@@ -23,14 +23,14 @@ describe("FavoriteService", () => {
linkService.create = jest.fn().mockReturnValue(Promise.resolve({ uuid: "newUuid" }));
const favoriteService = new FavoriteService(linkService, groupService);
- const newFavorite = await favoriteService.create({ userUuid: "userUuid", resourceUuid: "resourceUuid" });
+ const newFavorite = await favoriteService.create({ userUuid: "userUuid", resource: { uuid: "resourceUuid", name: "resource" } });
expect(linkService.create).toHaveBeenCalledWith({
ownerUuid: "userUuid",
tailUuid: "userUuid",
headUuid: "resourceUuid",
linkClass: LinkClass.STAR,
- name: "resourceUuid"
+ name: "resource"
});
expect(newFavorite.uuid).toEqual("newUuid");
diff --git a/src/services/favorite-service/favorite-service.ts b/src/services/favorite-service/favorite-service.ts
index f211a38..6ceaa36 100644
--- a/src/services/favorite-service/favorite-service.ts
+++ b/src/services/favorite-service/favorite-service.ts
@@ -19,13 +19,13 @@ export class FavoriteService {
private groupsService: GroupsService
) { }
- create(data: { userUuid: string; resourceUuid: string; }) {
+ create(data: { userUuid: string; resource: { uuid: string; name: string } }) {
return this.linkService.create({
ownerUuid: data.userUuid,
tailUuid: data.userUuid,
- headUuid: data.resourceUuid,
+ headUuid: data.resource.uuid,
linkClass: LinkClass.STAR,
- name: data.resourceUuid
+ name: data.resource.name
});
}
@@ -73,9 +73,9 @@ export class FavoriteService {
.addEqual("tailUuid", userUuid)
.addEqual("linkClass", LinkClass.STAR)
})
- .then(({items}) => resourceUuids.reduce((results, uuid) => {
+ .then(({ items }) => resourceUuids.reduce((results, uuid) => {
const isFavorite = items.some(item => item.headUuid === uuid);
- return {...results, [uuid]: isFavorite};
+ return { ...results, [uuid]: isFavorite };
}, {}));
}
diff --git a/src/store/context-menu/context-menu-reducer.ts b/src/store/context-menu/context-menu-reducer.ts
index d0ad85e..7ce2b3e 100644
--- a/src/store/context-menu/context-menu-reducer.ts
+++ b/src/store/context-menu/context-menu-reducer.ts
@@ -19,6 +19,7 @@ export interface ContextMenuPosition {
export interface ContextMenuResource {
uuid: string;
kind: string;
+ name: string;
}
const initialState = {
diff --git a/src/store/favorites/favorites-actions.ts b/src/store/favorites/favorites-actions.ts
index ddb1492..c8d1d07 100644
--- a/src/store/favorites/favorites-actions.ts
+++ b/src/store/favorites/favorites-actions.ts
@@ -16,18 +16,18 @@ export const favoritesActions = unionize({
export type FavoritesAction = UnionOf<typeof favoritesActions>;
-export const toggleFavorite = (resourceUuid: string) =>
+export const toggleFavorite = (resource: { uuid: string; name: string }) =>
(dispatch: Dispatch, getState: () => RootState) => {
const userUuid = getState().auth.user!.uuid;
- dispatch(favoritesActions.TOGGLE_FAVORITE({ resourceUuid }));
- const isFavorite = checkFavorite(resourceUuid, getState().favorites);
+ dispatch(favoritesActions.TOGGLE_FAVORITE({ resourceUuid: resource.uuid }));
+ const isFavorite = checkFavorite(resource.uuid, getState().favorites);
const promise = isFavorite
- ? favoriteService.delete({ userUuid, resourceUuid })
- : favoriteService.create({ userUuid, resourceUuid });
+ ? favoriteService.delete({ userUuid, resourceUuid: resource.uuid })
+ : favoriteService.create({ userUuid, resource });
promise
.then(fav => {
- dispatch(favoritesActions.UPDATE_FAVORITES({ [resourceUuid]: !isFavorite }));
+ dispatch(favoritesActions.UPDATE_FAVORITES({ [resource.uuid]: !isFavorite }));
});
};
diff --git a/src/views-components/context-menu/action-sets/project-action-set.ts b/src/views-components/context-menu/action-sets/project-action-set.ts
index dd257b7..e0a5e54 100644
--- a/src/views-components/context-menu/action-sets/project-action-set.ts
+++ b/src/views-components/context-menu/action-sets/project-action-set.ts
@@ -17,6 +17,6 @@ export const projectActionSet: ContextMenuActionSet = [[{
}, {
component: ToggleFavoriteAction,
execute: (dispatch, resource) => {
- dispatch<any>(toggleFavorite(resource.uuid));
+ dispatch<any>(toggleFavorite(resource));
}
}]];
diff --git a/src/views-components/context-menu/action-sets/resource-action-set.ts b/src/views-components/context-menu/action-sets/resource-action-set.ts
index 59af117..8915283 100644
--- a/src/views-components/context-menu/action-sets/resource-action-set.ts
+++ b/src/views-components/context-menu/action-sets/resource-action-set.ts
@@ -9,6 +9,6 @@ import { toggleFavorite } from "../../../store/favorites/favorites-actions";
export const resourceActionSet: ContextMenuActionSet = [[{
component: ToggleFavoriteAction,
execute: (dispatch, resource) => {
- dispatch<any>(toggleFavorite(resource.uuid));
+ dispatch<any>(toggleFavorite(resource));
}
}]];
diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx
index 96fd223..99212d3 100644
--- a/src/views/workbench/workbench.tsx
+++ b/src/views/workbench/workbench.tsx
@@ -175,11 +175,19 @@ export const Workbench = withStyles(styles)(
toggleOpen={this.toggleSidePanelOpen}
toggleActive={this.toggleSidePanelActive}
sidePanelItems={this.props.sidePanelItems}
- onContextMenu={(event) => this.openContextMenu(event, authService.getUuid() || "", ContextMenuKind.RootProject)}>
+ onContextMenu={(event) => this.openContextMenu(event, {
+ uuid: authService.getUuid() || "",
+ name: "",
+ kind: ContextMenuKind.RootProject
+ })}>
<ProjectTree
projects={this.props.projects}
toggleOpen={itemId => this.props.dispatch<any>(setProjectItem(itemId, ItemMode.OPEN))}
- onContextMenu={(event, item) => this.openContextMenu(event, item.data.uuid, ContextMenuKind.Project)}
+ onContextMenu={(event, item) => this.openContextMenu(event, {
+ uuid: item.data.uuid,
+ name: item.data.name,
+ kind: ContextMenuKind.Project
+ })}
toggleActive={itemId => {
this.props.dispatch<any>(setProjectItem(itemId, ItemMode.ACTIVE));
this.props.dispatch<any>(loadDetails(itemId, ResourceKind.Project));
@@ -205,7 +213,11 @@ export const Workbench = withStyles(styles)(
onItemRouteChange={itemId => this.props.dispatch<any>(setProjectItem(itemId, ItemMode.ACTIVE))}
onContextMenu={(event, item) => {
const kind = item.kind === ResourceKind.Project ? ContextMenuKind.Project : ContextMenuKind.Resource;
- this.openContextMenu(event, item.uuid, kind);
+ this.openContextMenu(event, {
+ uuid: item.uuid,
+ name: item.name,
+ kind
+ });
}}
onDialogOpen={this.handleCreationDialogOpen}
onItemClick={item => {
@@ -231,7 +243,11 @@ export const Workbench = withStyles(styles)(
this.props.dispatch(detailsPanelActions.TOGGLE_DETAILS_PANEL());
},
onContextMenu: (event: React.MouseEvent<HTMLElement>, breadcrumb: NavBreadcrumb) => {
- this.openContextMenu(event, breadcrumb.itemId, ContextMenuKind.Project);
+ this.openContextMenu(event, {
+ uuid: breadcrumb.itemId,
+ name: breadcrumb.label,
+ kind: ContextMenuKind.Project
+ });
}
};
@@ -249,12 +265,12 @@ export const Workbench = withStyles(styles)(
this.props.dispatch(projectActions.OPEN_PROJECT_CREATOR({ ownerUuid: itemUuid }));
}
- openContextMenu = (event: React.MouseEvent<HTMLElement>, itemUuid: string, kind: ContextMenuKind) => {
+ openContextMenu = (event: React.MouseEvent<HTMLElement>, resource: { name: string; uuid: string; kind: ContextMenuKind; }) => {
event.preventDefault();
this.props.dispatch(
contextMenuActions.OPEN_CONTEXT_MENU({
position: { x: event.clientX, y: event.clientY },
- resource: { uuid: itemUuid, kind }
+ resource
})
);
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list