[arvados] updated: 2.7.0-5842-g4c06248097

git repository hosting git at public.arvados.org
Thu Jan 25 19:01:44 UTC 2024


Summary of changes:
 .../multiselect-toolbar/MultiselectToolbar.tsx     | 41 ++++++++++++++++++----
 .../workbench2/src/store/users/users-actions.ts    |  1 +
 .../multiselect-toolbar/ms-menu-actions.ts         |  2 ++
 .../multiselect-toolbar/ms-user-action-set.ts      |  8 +++--
 4 files changed, 43 insertions(+), 9 deletions(-)

       via  4c06248097735c7dbaf3364cb387e055e1ae8e35 (commit)
      from  ec491638051a00f89f613caecd7ed571ac7a2bfd (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 4c06248097735c7dbaf3364cb387e055e1ae8e35
Author: Lisa Knox <lisaknox83 at gmail.com>
Date:   Thu Jan 25 14:01:38 2024 -0500

    21224: user card admin filter up Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox at curii.com>

diff --git a/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx b/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx
index d10a6ba615..ba42f9a924 100644
--- a/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx
+++ b/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx
@@ -26,7 +26,7 @@ import { resourceIsFrozen } from "common/frozen-resources";
 import { getResourceWithEditableStatus } from "store/resources/resources";
 import { GroupResource } from "models/group";
 import { EditableResource } from "models/resource";
-import { User } from "models/user";
+import { User, UserResource } from "models/user";
 import { GroupClass } from "models/group";
 import { isProcessCancelable } from "store/processes/process";
 import { CollectionResource } from "models/collection";
@@ -34,6 +34,11 @@ import { getProcess } from "store/processes/process";
 import { Process } from "store/processes/process";
 import { PublicFavoritesState } from "store/public-favorites/public-favorites-reducer";
 import { isExactlyOneSelected } from "store/multiselect/multiselect-actions";
+import { AuthState } from "store/auth/auth-reducer";
+import { BuiltinGroups, getBuiltinGroupUuid } from "models/group";
+import { LinkResource, LinkClass } from "models/link";
+import { filterResources } from "store/resources/resources";
+import { UserAccountStatus } from "store/users/users-actions";
 
 const WIDTH_TRANSITION = 150
 
@@ -89,7 +94,8 @@ export type MultiselectToolbarProps = {
     iconProps: IconProps
     user: User | null
     disabledButtons: Set<string>
-    executeMulti: (action: ContextMenuAction, inputSelectedUuid: string | undefined, checkedList: TCheckedList, resources: ResourcesState) => void;
+    auth: AuthState;
+    executeMulti: (action: ContextMenuAction | MultiSelectMenuAction, inputSelectedUuid: string | undefined, checkedList: TCheckedList, resources: ResourcesState) => void;
 };
 
 type IconProps = {
@@ -103,7 +109,7 @@ export const MultiselectToolbar = connect(
     mapDispatchToProps
 )(
     withStyles(styles)((props: MultiselectToolbarProps & WithStyles<CssRules>) => {
-        const { classes, checkedList, inputSelectedUuid, iconProps, user, disabledButtons } = props;
+        const { classes, checkedList, inputSelectedUuid, iconProps, user, disabledButtons, auth } = props;
         const singleSelectedUuid = inputSelectedUuid ?? props.singleSelectedUuid
         const singleResourceKind = singleSelectedUuid ? [resourceToMsResourceKind(singleSelectedUuid, iconProps.resources, user)] : null
         const currentResourceKinds = singleResourceKind ? singleResourceKind : Array.from(selectedToKindSet(checkedList));
@@ -126,12 +132,34 @@ export const MultiselectToolbar = connect(
             // eslint-disable-next-line
         }, [checkedList])
 
+        const getAccountStatus = (auth: AuthState, resources: ResourcesState) => {
+            const user = getResource<UserResource>(singleSelectedUuid as string)(resources);
+            if (!user) return;
+            const allUsersGroupUuid = getBuiltinGroupUuid(auth.localCluster, BuiltinGroups.ALL);
+            const permissions = filterResources(
+                (resource: LinkResource) =>
+                    resource.kind === ResourceKind.LINK &&
+                    resource.linkClass === LinkClass.PERMISSION &&
+                    resource.headUuid === allUsersGroupUuid &&
+                    resource.tailUuid === singleSelectedUuid
+            )(resources);
+
+            return user && user.isActive ? UserAccountStatus.ACTIVE : permissions.length > 0 ? UserAccountStatus.SETUP : UserAccountStatus.INACTIVE;
+        };
+
         const actions =
             currentPathIsTrash && selectedToKindSet(checkedList).size
                 ? [msToggleTrashAction]
-                : selectActionsByKind(currentResourceKinds as string[], multiselectActionsFilters).filter((action) =>
-                        singleSelectedUuid === null ? action.isForMulti : true
-                    );
+                : selectActionsByKind(currentResourceKinds as string[], multiselectActionsFilters)
+                      .filter((action) => (singleSelectedUuid === null ? action.isForMulti : true))
+                      .filter((action) => {
+                          if (action.filters && action.filters.length) {
+                              if (action.filters[0] === UserAccountStatus.OTHER && singleSelectedUuid !== auth.user?.uuid) return true;
+                              const accountStatus = getAccountStatus(auth, iconProps.resources);
+                              return accountStatus && action.filters.includes(accountStatus);
+                          }
+                          return true;
+                      });
 
         return (
             <React.Fragment>
@@ -334,6 +362,7 @@ function mapStateToProps({auth, multiselect, resources, favorites, publicFavorit
         singleSelectedUuid: isExactlyOneSelected(multiselect.checkedList),
         user: auth && auth.user ? auth.user : null,
         disabledButtons: new Set<string>(multiselect.disabledButtons),
+        auth,
         iconProps: {
             resources,
             favorites,
diff --git a/services/workbench2/src/store/users/users-actions.ts b/services/workbench2/src/store/users/users-actions.ts
index 62af580251..60b81b7ba4 100644
--- a/services/workbench2/src/store/users/users-actions.ts
+++ b/services/workbench2/src/store/users/users-actions.ts
@@ -146,6 +146,7 @@ export enum UserAccountStatus {
         ACTIVE = 'Active',
         INACTIVE = 'Inactive',
         SETUP = 'Setup',
+        OTHER = 'Other',
     }
 
 export const getUserAccountStatus = (state: RootState, uuid: string) => {
diff --git a/services/workbench2/src/views-components/multiselect-toolbar/ms-menu-actions.ts b/services/workbench2/src/views-components/multiselect-toolbar/ms-menu-actions.ts
index 4d78733dfd..da00e0be28 100644
--- a/services/workbench2/src/views-components/multiselect-toolbar/ms-menu-actions.ts
+++ b/services/workbench2/src/views-components/multiselect-toolbar/ms-menu-actions.ts
@@ -18,6 +18,7 @@ import { openSharingDialog } from 'store/sharing-dialog/sharing-dialog-actions';
 import { togglePublicFavorite } from "store/public-favorites/public-favorites-actions";
 import { publicFavoritePanelActions } from "store/public-favorites-panel/public-favorites-action";
 import { PublicFavoritesState } from 'store/public-favorites/public-favorites-reducer';
+import { UserAccountStatus } from 'store/users/users-actions';
 
 export enum MultiSelectMenuActionNames {
     ADD_TO_FAVORITES = 'Add to Favorites',
@@ -59,6 +60,7 @@ export type MultiSelectMenuAction = {
     useAlts?: (uuid: string | null, iconProps: {resources: ResourcesState, favorites: FavoritesState, publicFavorites: PublicFavoritesState}) => boolean;
     execute(dispatch: Dispatch, resources: ContextMenuResource[], state?: any): void;
     adminOnly?: boolean;
+    filters?: UserAccountStatus[]
 };
 
 export type MultiSelectMenuActionSet = MultiSelectMenuAction[][];
diff --git a/services/workbench2/src/views-components/multiselect-toolbar/ms-user-action-set.ts b/services/workbench2/src/views-components/multiselect-toolbar/ms-user-action-set.ts
index bb115fba97..5d25f285d0 100644
--- a/services/workbench2/src/views-components/multiselect-toolbar/ms-user-action-set.ts
+++ b/services/workbench2/src/views-components/multiselect-toolbar/ms-user-action-set.ts
@@ -6,13 +6,11 @@ import { ActiveIcon, AdminMenuIcon, AdvancedIcon, AttributesIcon, DeactivateUser
 import { MultiSelectMenuAction, MultiSelectMenuActionSet, MultiSelectMenuActionNames } from './ms-menu-actions';
 import { openAdvancedTabDialog } from 'store/advanced-tab/advanced-tab';
 import { openActivateDialog, openDeactivateDialog, openSetupDialog } from 'store/user-profile/user-profile-actions';
-import { openUserAttributes } from 'store/users/users-actions';
+import { UserAccountStatus, openUserAttributes } from 'store/users/users-actions';
 import { loginAs } from 'store/users/users-actions';
 
 const { ATTRIBUTES, API_DETAILS, SETUP_USER, ACTIVATE_USER, DEACTIVATE_USER, LOGIN_AS_USER } = MultiSelectMenuActionNames;
 
-export const USER_ATTRIBUTES_DIALOG = 'userAttributesDialog';
-
 const msUserAttributes: MultiSelectMenuAction = {
     name: ATTRIBUTES,
     icon: AttributesIcon,
@@ -41,6 +39,7 @@ const msActivateUser: MultiSelectMenuAction = {
     execute: (dispatch, resources) => {
         dispatch<any>(openActivateDialog(resources[0].uuid));
     },
+    filters: [UserAccountStatus.INACTIVE, UserAccountStatus.SETUP],
 };
 
 const msSetupUser: MultiSelectMenuAction = {
@@ -51,6 +50,7 @@ const msSetupUser: MultiSelectMenuAction = {
     execute: (dispatch, resources) => {
         dispatch<any>(openSetupDialog(resources[0].uuid));
     },
+    filters: [UserAccountStatus.INACTIVE],
 };
 
 const msDeactivateUser: MultiSelectMenuAction = {
@@ -61,6 +61,7 @@ const msDeactivateUser: MultiSelectMenuAction = {
     execute: (dispatch, resources) => {
         dispatch<any>(openDeactivateDialog(resources[0].uuid));
     },
+    filters: [UserAccountStatus.ACTIVE, UserAccountStatus.SETUP],
 };
 
 const msLoginAsUser: MultiSelectMenuAction = {
@@ -71,6 +72,7 @@ const msLoginAsUser: MultiSelectMenuAction = {
     execute: (dispatch, resources) => {
         dispatch<any>(loginAs(resources[0].uuid));
     },
+    filters: [UserAccountStatus.OTHER]
 };
 
 export const msUserActionSet: MultiSelectMenuActionSet = [[msAdvancedAction, msUserAttributes, msSetupUser, msActivateUser, msDeactivateUser, msLoginAsUser]];

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list