From 45b7a399f23fcb2da0adc3a4f4f6cd527cec0784 Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Mon, 8 Jul 2024 13:13:38 +0000 Subject: [PATCH 1/2] feat(Layout): support security icon in additional drawer link --- packages/backend/src/config/app.js | 1 + .../controllers/api/v1/automatisch/config.ee.js | 1 + .../api/v1/automatisch/config.ee.test.js | 15 +++++++++++++++ packages/web/src/components/Layout/index.jsx | 14 ++++++++++++-- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/config/app.js b/packages/backend/src/config/app.js index de2d2c0e..72892bb2 100644 --- a/packages/backend/src/config/app.js +++ b/packages/backend/src/config/app.js @@ -97,6 +97,7 @@ const appConfig = { disableNotificationsPage: process.env.DISABLE_NOTIFICATIONS_PAGE === 'true', disableFavicon: process.env.DISABLE_FAVICON === 'true', additionalDrawerLink: process.env.ADDITIONAL_DRAWER_LINK, + additionalDrawerLinkIcon: process.env.ADDITIONAL_DRAWER_LINK_ICON, additionalDrawerLinkText: process.env.ADDITIONAL_DRAWER_LINK_TEXT, disableSeedUser: process.env.DISABLE_SEED_USER === 'true', }; diff --git a/packages/backend/src/controllers/api/v1/automatisch/config.ee.js b/packages/backend/src/controllers/api/v1/automatisch/config.ee.js index 44fd957c..e8538cde 100644 --- a/packages/backend/src/controllers/api/v1/automatisch/config.ee.js +++ b/packages/backend/src/controllers/api/v1/automatisch/config.ee.js @@ -7,6 +7,7 @@ export default async (request, response) => { disableNotificationsPage: appConfig.disableNotificationsPage, disableFavicon: appConfig.disableFavicon, additionalDrawerLink: appConfig.additionalDrawerLink, + additionalDrawerLinkIcon: appConfig.additionalDrawerLinkIcon, additionalDrawerLinkText: appConfig.additionalDrawerLinkText, }; diff --git a/packages/backend/src/controllers/api/v1/automatisch/config.ee.test.js b/packages/backend/src/controllers/api/v1/automatisch/config.ee.test.js index 438d39c5..28b8bde3 100644 --- a/packages/backend/src/controllers/api/v1/automatisch/config.ee.test.js +++ b/packages/backend/src/controllers/api/v1/automatisch/config.ee.test.js @@ -4,6 +4,7 @@ import { createConfig } from '../../../../../test/factories/config.js'; import app from '../../../../app.js'; import configMock from '../../../../../test/mocks/rest/api/v1/automatisch/config.js'; import * as license from '../../../../helpers/license.ee.js'; +import appConfig from '../../../../config/app.js'; describe('GET /api/v1/automatisch/config', () => { it('should return Automatisch config', async () => { @@ -48,4 +49,18 @@ describe('GET /api/v1/automatisch/config', () => { expect(response.body).toEqual(expectedPayload); }); + + it('should return additional environment variables', async () => { + vi.spyOn(appConfig, 'disableNotificationsPage', 'get').mockReturnValue(true); + vi.spyOn(appConfig, 'disableFavicon', 'get').mockReturnValue(true); + vi.spyOn(appConfig, 'additionalDrawerLink', 'get').mockReturnValue('link'); + vi.spyOn(appConfig, 'additionalDrawerLinkIcon', 'get').mockReturnValue('icon'); + vi.spyOn(appConfig, 'additionalDrawerLinkText', 'get').mockReturnValue('text'); + + expect(appConfig.disableNotificationsPage).toEqual(true); + expect(appConfig.disableFavicon).toEqual(true); + expect(appConfig.additionalDrawerLink).toEqual('link'); + expect(appConfig.additionalDrawerLinkIcon).toEqual('icon'); + expect(appConfig.additionalDrawerLinkText).toEqual('text'); + }); }); diff --git a/packages/web/src/components/Layout/index.jsx b/packages/web/src/components/Layout/index.jsx index c36026d8..3e96442b 100644 --- a/packages/web/src/components/Layout/index.jsx +++ b/packages/web/src/components/Layout/index.jsx @@ -8,8 +8,9 @@ import AppsIcon from '@mui/icons-material/Apps'; import SwapCallsIcon from '@mui/icons-material/SwapCalls'; import HistoryIcon from '@mui/icons-material/History'; import NotificationsIcon from '@mui/icons-material/Notifications'; -import ArrowBackIosNew from '@mui/icons-material/ArrowBackIosNew'; import PropTypes from 'prop-types'; +import ArrowBackIosNewIcon from '@mui/icons-material/ArrowBackIosNew'; +import SecurityIcon from '@mui/icons-material/Security'; import * as URLS from 'config/urls'; import useFormatMessage from 'hooks/useFormatMessage'; @@ -18,6 +19,11 @@ import AppBar from 'components/AppBar'; import Drawer from 'components/Drawer'; import useAutomatischConfig from 'hooks/useAutomatischConfig'; +const additionalDrawerLinkIcons = { + Security: SecurityIcon, + ArrowBackIosNew: ArrowBackIosNewIcon, +}; + const drawerLinks = [ { Icon: SwapCallsIcon, @@ -43,6 +49,7 @@ const generateDrawerBottomLinks = async ({ disableNotificationsPage, notificationBadgeContent = 0, additionalDrawerLink, + additionalDrawerLinkIcon, additionalDrawerLinkText, formatMessage, }) => { @@ -57,7 +64,9 @@ const generateDrawerBottomLinks = async ({ additionalDrawerLink && additionalDrawerLinkText; const additionalDrawerLinkObject = { - Icon: ArrowBackIosNew, + Icon: + additionalDrawerLinkIcons[additionalDrawerLinkIcon] || + ArrowBackIosNewIcon, primary: additionalDrawerLinkText || '', to: additionalDrawerLink || '', target: '_blank', @@ -95,6 +104,7 @@ function PublicLayout({ children }) { notificationBadgeContent: version.newVersionCount, disableNotificationsPage: config?.disableNotificationsPage, additionalDrawerLink: config?.additionalDrawerLink, + additionalDrawerLinkIcon: config?.additionalDrawerLinkIcon, additionalDrawerLinkText: config?.additionalDrawerLinkText, formatMessage, }); From 61e90aed60eb9905537d71480067dcda5e1aa4be Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Fri, 12 Jul 2024 13:40:51 +0000 Subject: [PATCH 2/2] chore: upgrade @playwright/test with 1.45.1 --- packages/e2e-tests/package.json | 2 +- yarn.lock | 30 ++++++++++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/packages/e2e-tests/package.json b/packages/e2e-tests/package.json index 48d395e0..33ef98a6 100644 --- a/packages/e2e-tests/package.json +++ b/packages/e2e-tests/package.json @@ -25,7 +25,7 @@ }, "devDependencies": { "@faker-js/faker": "^8.2.0", - "@playwright/test": "^1.36.2" + "@playwright/test": "^1.45.1" }, "dependencies": { "dotenv": "^16.3.1", diff --git a/yarn.lock b/yarn.lock index b4f61f02..90c5211f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3315,15 +3315,12 @@ resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== -"@playwright/test@^1.36.2": - version "1.36.2" - resolved "https://registry.npmjs.org/@playwright/test/-/test-1.36.2.tgz" - integrity sha512-2rVZeyPRjxfPH6J0oGJqE8YxiM1IBRyM8hyrXYK7eSiAqmbNhxwcLa7dZ7fy9Kj26V7FYia5fh9XJRq4Dqme+g== +"@playwright/test@^1.45.1": + version "1.45.1" + resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.45.1.tgz#819b90fa43d17000fce5ebd127043fd661938b7a" + integrity sha512-Wo1bWTzQvGA7LyKGIZc8nFSTFf2TkthGIFBR+QVNilvwouGzFd4PYukZe3rvf5PSqjHi1+1NyKSDZKcQWETzaA== dependencies: - "@types/node" "*" - playwright-core "1.36.2" - optionalDependencies: - fsevents "2.3.2" + playwright "1.45.1" "@pmmmwh/react-refresh-webpack-plugin@^0.5.3": version "0.5.4" @@ -13048,10 +13045,19 @@ pkg-up@^3.1.0: dependencies: find-up "^3.0.0" -playwright-core@1.36.2: - version "1.36.2" - resolved "https://registry.npmjs.org/playwright-core/-/playwright-core-1.36.2.tgz" - integrity sha512-sQYZt31dwkqxOrP7xy2ggDfEzUxM1lodjhsQ3NMMv5uGTRDsLxU0e4xf4wwMkF2gplIxf17QMBCodSFgm6bFVQ== +playwright-core@1.45.1: + version "1.45.1" + resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.45.1.tgz#549a2701556b58245cc75263f9fc2795c1158dc1" + integrity sha512-LF4CUUtrUu2TCpDw4mcrAIuYrEjVDfT1cHbJMfwnE2+1b8PZcFzPNgvZCvq2JfQ4aTjRCCHw5EJ2tmr2NSzdPg== + +playwright@1.45.1: + version "1.45.1" + resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.45.1.tgz#aaa6b0d6db14796b599d80c6679e63444e942534" + integrity sha512-Hjrgae4kpSQBr98nhCj3IScxVeVUixqj+5oyif8TdIn2opTCPEzqAqNMeK42i3cWDCVu9MI+ZsGWw+gVR4ISBg== + dependencies: + playwright-core "1.45.1" + optionalDependencies: + fsevents "2.3.2" pluralize@^8.0.0: version "8.0.0"