Merge pull request #1953 from automatisch/add-security-icon-in-additional-drawer

feat(Layout): support security icon in additional drawer link
This commit is contained in:
Ali BARIN
2024-07-15 14:01:10 +02:00
committed by GitHub
6 changed files with 48 additions and 15 deletions

View File

@@ -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',
};

View File

@@ -7,6 +7,7 @@ export default async (request, response) => {
disableNotificationsPage: appConfig.disableNotificationsPage,
disableFavicon: appConfig.disableFavicon,
additionalDrawerLink: appConfig.additionalDrawerLink,
additionalDrawerLinkIcon: appConfig.additionalDrawerLinkIcon,
additionalDrawerLinkText: appConfig.additionalDrawerLinkText,
};

View File

@@ -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');
});
});

View File

@@ -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",

View File

@@ -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,
});

View File

@@ -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"