[ARVADOS-WORKBENCH2] updated: 2.2.1-127-ge2d58af5
Git user
git at public.arvados.org
Thu Nov 11 01:35:28 UTC 2021
Summary of changes:
src/store/groups-panel/groups-panel-actions.ts | 29 +++++++++++++++++++++-
src/store/projects/project-update-actions.ts | 6 +++--
src/store/workbench/workbench-actions.ts | 14 +++++++++++
.../context-menu/action-sets/group-action-set.ts | 5 ++--
.../dialog-forms/update-project-dialog.ts | 19 +++++++++++---
src/views/groups-panel/groups-panel.tsx | 3 ++-
6 files changed, 65 insertions(+), 11 deletions(-)
via e2d58af5865064bb5b864507e9d29c349572e38a (commit)
from 474f94018be47f25c69b982112d8ac07908d7124 (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 e2d58af5865064bb5b864507e9d29c349572e38a
Author: Stephen Smith <stephen at curii.com>
Date: Wed Nov 10 20:34:19 2021 -0500
18123: Add group edit dialog actions to re-use edit project dialog.
Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen at curii.com>
diff --git a/src/store/groups-panel/groups-panel-actions.ts b/src/store/groups-panel/groups-panel-actions.ts
index 1c4a0732..e961b347 100644
--- a/src/store/groups-panel/groups-panel-actions.ts
+++ b/src/store/groups-panel/groups-panel-actions.ts
@@ -3,7 +3,7 @@
// SPDX-License-Identifier: AGPL-3.0
import { Dispatch } from 'redux';
-import { reset, startSubmit, stopSubmit, FormErrors } from 'redux-form';
+import { reset, startSubmit, stopSubmit, FormErrors, initialize } from 'redux-form';
import { bindDataExplorerActions } from "store/data-explorer/data-explorer-action";
import { dialogActions } from 'store/dialog/dialog-actions';
import { Participant } from 'views-components/sharing-dialog/participant-select';
@@ -16,6 +16,7 @@ import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions';
import { PermissionLevel } from 'models/permission';
import { PermissionService } from 'services/permission-service/permission-service';
import { FilterBuilder } from 'services/api/filter-builder';
+import { ProjectUpdateFormDialogData, PROJECT_UPDATE_FORM_NAME } from 'store/projects/project-update-actions';
export const GROUPS_PANEL_ID = "groupsPanel";
@@ -66,6 +67,32 @@ export const openRemoveGroupDialog = (uuid: string) =>
}));
};
+// Group edit dialog uses project update dialog with sourcePanel set to reload the appropriate parts
+export const openGroupUpdateDialog = (resource: ProjectUpdateFormDialogData) =>
+ (dispatch: Dispatch, getState: () => RootState) => {
+ dispatch(initialize(PROJECT_UPDATE_FORM_NAME, resource));
+ dispatch(dialogActions.OPEN_DIALOG({ id: PROJECT_UPDATE_FORM_NAME, data: {sourcePanel: GroupClass.ROLE} }));
+ };
+
+export const updateGroup = (project: ProjectUpdateFormDialogData) =>
+ async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const uuid = project.uuid || '';
+ dispatch(startSubmit(PROJECT_UPDATE_FORM_NAME));
+ try {
+ const updatedGroup = await services.groupsService.update(uuid, { name: project.name, description: project.description });
+ dispatch(GroupsPanelActions.REQUEST_ITEMS());
+ dispatch(reset(PROJECT_UPDATE_FORM_NAME));
+ dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_UPDATE_FORM_NAME }));
+ return updatedGroup;
+ } catch (e) {
+ const error = getCommonResourceServiceError(e);
+ if (error === CommonResourceServiceError.UNIQUE_NAME_VIOLATION) {
+ dispatch(stopSubmit(PROJECT_UPDATE_FORM_NAME, { name: 'Group with the same name already exists.' } as FormErrors));
+ }
+ return ;
+ }
+ };
+
export interface CreateGroupFormData {
[CREATE_GROUP_NAME_FIELD_NAME]: string;
[CREATE_GROUP_USERS_FIELD_NAME]?: Participant[];
diff --git a/src/store/projects/project-update-actions.ts b/src/store/projects/project-update-actions.ts
index 35100eb6..45065b62 100644
--- a/src/store/projects/project-update-actions.ts
+++ b/src/store/projects/project-update-actions.ts
@@ -3,12 +3,13 @@
// SPDX-License-Identifier: AGPL-3.0
import { Dispatch } from "redux";
-import { FormErrors, initialize, startSubmit, stopSubmit } from 'redux-form';
+import { FormErrors, initialize, reset, startSubmit, stopSubmit } from 'redux-form';
import { RootState } from "store/store";
import { dialogActions } from "store/dialog/dialog-actions";
import { getCommonResourceServiceError, CommonResourceServiceError } from "services/common-service/common-resource-service";
import { ServiceRepository } from "services/services";
import { projectPanelActions } from 'store/project-panel/project-panel-action';
+import { GroupClass } from "models/group";
export interface ProjectUpdateFormDialogData {
uuid: string;
@@ -21,7 +22,7 @@ export const PROJECT_UPDATE_FORM_NAME = 'projectUpdateFormName';
export const openProjectUpdateDialog = (resource: ProjectUpdateFormDialogData) =>
(dispatch: Dispatch, getState: () => RootState) => {
dispatch(initialize(PROJECT_UPDATE_FORM_NAME, resource));
- dispatch(dialogActions.OPEN_DIALOG({ id: PROJECT_UPDATE_FORM_NAME, data: {} }));
+ dispatch(dialogActions.OPEN_DIALOG({ id: PROJECT_UPDATE_FORM_NAME, data: {sourcePanel: GroupClass.PROJECT} }));
};
export const updateProject = (project: ProjectUpdateFormDialogData) =>
@@ -31,6 +32,7 @@ export const updateProject = (project: ProjectUpdateFormDialogData) =>
try {
const updatedProject = await services.projectService.update(uuid, { name: project.name, description: project.description });
dispatch(projectPanelActions.REQUEST_ITEMS());
+ dispatch(reset(PROJECT_UPDATE_FORM_NAME));
dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_UPDATE_FORM_NAME }));
return updatedProject;
} catch (e) {
diff --git a/src/store/workbench/workbench-actions.ts b/src/store/workbench/workbench-actions.ts
index 9c89d199..527d9d74 100644
--- a/src/store/workbench/workbench-actions.ts
+++ b/src/store/workbench/workbench-actions.ts
@@ -272,6 +272,20 @@ export const updateProject = (data: projectUpdateActions.ProjectUpdateFormDialog
}
};
+export const updateGroup = (data: projectUpdateActions.ProjectUpdateFormDialogData) =>
+ async (dispatch: Dispatch) => {
+ const updatedGroup = await dispatch<any>(groupPanelActions.updateGroup(data));
+ if (updatedGroup) {
+ dispatch(snackbarActions.OPEN_SNACKBAR({
+ message: "Group has been successfully updated.",
+ hideDuration: 2000,
+ kind: SnackbarKind.SUCCESS
+ }));
+ await dispatch<any>(loadSidePanelTreeProjects(updatedGroup.ownerUuid));
+ dispatch<any>(reloadProjectMatchingUuid([updatedGroup.ownerUuid, updatedGroup.uuid]));
+ }
+ };
+
export const loadCollection = (uuid: string) =>
handleFirstTimeLoad(
async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
diff --git a/src/views-components/context-menu/action-sets/group-action-set.ts b/src/views-components/context-menu/action-sets/group-action-set.ts
index f2c9b92f..874a601b 100644
--- a/src/views-components/context-menu/action-sets/group-action-set.ts
+++ b/src/views-components/context-menu/action-sets/group-action-set.ts
@@ -5,14 +5,13 @@
import { ContextMenuActionSet } from "views-components/context-menu/context-menu-action-set";
import { RenameIcon, AdvancedIcon, RemoveIcon, AttributesIcon } from "components/icon/icon";
import { openAdvancedTabDialog } from "store/advanced-tab/advanced-tab";
-import { openGroupAttributes, openRemoveGroupDialog } from "store/groups-panel/groups-panel-actions";
-import { openProjectUpdateDialog } from "store/projects/project-update-actions";
+import { openGroupAttributes, openRemoveGroupDialog, openGroupUpdateDialog } from "store/groups-panel/groups-panel-actions";
export const groupActionSet: ContextMenuActionSet = [[{
name: "Rename",
icon: RenameIcon,
execute: (dispatch, resource) => {
- dispatch<any>(openProjectUpdateDialog(resource));
+ dispatch<any>(openGroupUpdateDialog(resource));
}
}, {
name: "Attributes",
diff --git a/src/views-components/dialog-forms/update-project-dialog.ts b/src/views-components/dialog-forms/update-project-dialog.ts
index dca51b96..119e9256 100644
--- a/src/views-components/dialog-forms/update-project-dialog.ts
+++ b/src/views-components/dialog-forms/update-project-dialog.ts
@@ -7,14 +7,25 @@ import { reduxForm } from 'redux-form';
import { withDialog } from "store/dialog/with-dialog";
import { DialogProjectUpdate } from 'views-components/dialog-update/dialog-project-update';
import { PROJECT_UPDATE_FORM_NAME, ProjectUpdateFormDialogData } from 'store/projects/project-update-actions';
-import { updateProject } from 'store/workbench/workbench-actions';
+import { updateProject, updateGroup } from 'store/workbench/workbench-actions';
+import { GroupClass } from "models/group";
export const UpdateProjectDialog = compose(
withDialog(PROJECT_UPDATE_FORM_NAME),
reduxForm<ProjectUpdateFormDialogData>({
form: PROJECT_UPDATE_FORM_NAME,
- onSubmit: (data, dispatch) => {
- dispatch(updateProject(data));
+ onSubmit: (data, dispatch, props) => {
+ console.log(props);
+ switch (props.data.sourcePanel) {
+ case GroupClass.PROJECT:
+ dispatch(updateProject(data));
+ break;
+ case GroupClass.ROLE:
+ dispatch(updateGroup(data));
+ break;
+ default:
+ break;
+ }
}
})
-)(DialogProjectUpdate);
\ No newline at end of file
+)(DialogProjectUpdate);
diff --git a/src/views/groups-panel/groups-panel.tsx b/src/views/groups-panel/groups-panel.tsx
index a9f59f68..4f25f6e5 100644
--- a/src/views/groups-panel/groups-panel.tsx
+++ b/src/views/groups-panel/groups-panel.tsx
@@ -101,8 +101,9 @@ export const GroupsPanel = connect(
const resource = getResource<GroupResource>(resourceUuid)(this.props.resources);
if (resource) {
this.props.onContextMenu(event, {
- name: '',
+ name: resource.name,
uuid: resource.uuid,
+ description: resource.description,
ownerUuid: resource.ownerUuid,
kind: resource.kind,
menuKind: ContextMenuKind.GROUPS
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list