18692: added lock iton to the breadcrumbs
authorDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Fri, 3 Jun 2022 06:47:24 +0000 (08:47 +0200)
committerDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Fri, 3 Jun 2022 06:47:24 +0000 (08:47 +0200)
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>

cypress/integration/project.spec.js
src/components/breadcrumbs/breadcrumbs.tsx
src/store/breadcrumbs/breadcrumbs-middleware.ts [new file with mode: 0644]
src/store/store.ts
src/views-components/context-menu/actions/lock-action.tsx

index 5929fb90c05e38351adfe9f14666172e26394419..520ad26aa7f3f624ad76ed2aaf5e895777ab4160 100644 (file)
@@ -261,7 +261,7 @@ describe('Project tests', function() {
         });
     });
 
-    describe.only('Frozen projects', () => {
+    describe('Frozen projects', () => {
         beforeEach(() => {  
             cy.createGroup(activeUser.token, {
                 name: `Main project ${Math.floor(Math.random() * 999999)}`,
@@ -296,11 +296,11 @@ describe('Project tests', function() {
 
                 cy.get('[data-cy=project-panel]').contains(mainProject.name).rightclick();
 
-                cy.get('[data-cy=context-menu]').contains('Lock').click();
+                cy.get('[data-cy=context-menu]').contains('Freeze').click();
 
                 cy.get('[data-cy=project-panel]').contains(mainProject.name).rightclick();
 
-                cy.get('[data-cy=context-menu]').contains('Lock').should('not.exist');
+                cy.get('[data-cy=context-menu]').contains('Freeze').should('not.exist');
             });
         });
 
@@ -310,7 +310,7 @@ describe('Project tests', function() {
 
                 cy.get('[data-cy=project-panel]').contains(mainProject.name).rightclick();
 
-                cy.get('[data-cy=context-menu]').contains('Lock').click();
+                cy.get('[data-cy=context-menu]').contains('Freeze').click();
 
                 cy.get('[data-cy=project-panel]').contains(mainProject.name).click();
 
@@ -328,11 +328,11 @@ describe('Project tests', function() {
 
                 cy.get('main').contains(adminProject.name).rightclick();
 
-                cy.get('[data-cy=context-menu]').contains('Lock').click();
+                cy.get('[data-cy=context-menu]').contains('Freeze').click();
 
                 cy.get('main').contains(adminProject.name).rightclick();
 
-                cy.get('[data-cy=context-menu]').contains('Lock').should('exist');
+                cy.get('[data-cy=context-menu]').contains('Freeze').should('exist');
             });
         });
 
@@ -342,17 +342,17 @@ describe('Project tests', function() {
 
                 cy.get('main').contains(adminProject.name).rightclick();
 
-                cy.get('[data-cy=context-menu]').contains('Lock').click();
+                cy.get('[data-cy=context-menu]').contains('Freeze').click();
 
                 cy.wait(1000);
 
                 cy.get('main').contains(adminProject.name).rightclick();
 
-                cy.get('[data-cy=context-menu]').contains('Unlock').click();
+                cy.get('[data-cy=context-menu]').contains('Unfreeze').click();
 
                 cy.get('main').contains(adminProject.name).rightclick();
                 
-                cy.get('[data-cy=context-menu]').contains('Lock').should('exist');
+                cy.get('[data-cy=context-menu]').contains('Freeze').should('exist');
             });
         });
     });
index 3d668856ecd5d1c20e4faebc3b51d54466045277..c081c314b607d8cb36916629981b682f1acb601b 100644 (file)
@@ -7,12 +7,13 @@ import { Button, Grid, StyleRulesCallback, WithStyles, Typography, Tooltip } fro
 import ChevronRightIcon from '@material-ui/icons/ChevronRight';
 import { withStyles } from '@material-ui/core';
 import { IllegalNamingWarning } from '../warning/warning';
-import { IconType } from 'components/icon/icon';
+import { IconType, LockIcon } from 'components/icon/icon';
 import grey from '@material-ui/core/colors/grey';
 
 export interface Breadcrumb {
     label: string;
     icon?: IconType;
+    isFrozen?: boolean;
 }
 
 type CssRules = "item" | "currentItem" | "label" | "icon";
@@ -63,6 +64,9 @@ export const Breadcrumbs = withStyles(styles)(
                             onClick={() => onClick(item)}
                             onContextMenu={event => onContextMenu(event, item)}>
                             <Icon className={classes.icon} />
+                            {
+                                item.isFrozen ? <LockIcon className={classes.icon} /> : null
+                            }
                             <Typography
                                 noWrap
                                 color="inherit"
diff --git a/src/store/breadcrumbs/breadcrumbs-middleware.ts b/src/store/breadcrumbs/breadcrumbs-middleware.ts
new file mode 100644 (file)
index 0000000..df8dd00
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { propertiesActions } from "store/properties/properties-actions";
+import { BREADCRUMBS } from "./breadcrumbs-actions";
+
+export const breadcrumbsMiddleware = store => next => action => {
+    propertiesActions.match(action, {
+        SET_PROPERTY: () => {
+
+            if (action.payload.key === BREADCRUMBS && Array.isArray(action.payload.value)) {
+                action.payload.value = action.payload
+                    .value.map((value)=> ({ ...value, isFrozen: !!store.getState().resources[value.uuid]?.frozenByUuid }));
+            }
+
+            next(action);
+        },
+        default: () => next(action)
+    });
+};
index 94f110a09563ab17537b44445b964f650fef2ce5..7bc28ff4b5de6adb0492a0cda1cc63d5a0a7f206 100644 (file)
@@ -73,6 +73,7 @@ import { ALL_PROCESSES_PANEL_ID } from './all-processes-panel/all-processes-pane
 import { Config } from 'common/config';
 import { pluginConfig } from 'plugins';
 import { MiddlewareListReducer } from 'common/plugintypes';
+import { breadcrumbsMiddleware } from './breadcrumbs/breadcrumbs-middleware';
 
 declare global {
     interface Window {
@@ -174,6 +175,7 @@ export function configureStore(history: History, services: ServiceRepository, co
         publicFavoritesMiddleware,
         collectionsContentAddress,
         subprocessMiddleware,
+        breadcrumbsMiddleware,
     ];
 
     const reduceMiddlewaresFn: (a: Middleware[],
index aa867ded380db7fa7d251adf0a57142b8ead9a23..9e66763091d95dbed40cf323ebbbb6e7cc67b55a 100644 (file)
@@ -28,7 +28,7 @@ export const ToggleLockAction = withRouter(connect(mapStateToProps)((props: { is
             </ListItemIcon>
             <ListItemText style={{ textDecoration: 'none' }}>
                 {props.isLocked
-                    ? <>Unlock project</>
-                    : <>Lock project</>}
+                    ? <>Unfreeze project</>
+                    : <>Freeze project</>}
             </ListItemText>
         </ListItem >));