diff --git a/docs/docs/concepts/ui/index.md b/docs/docs/concepts/ui/index.md index 74f814587c..a38b39c26e 100644 --- a/docs/docs/concepts/ui/index.md +++ b/docs/docs/concepts/ui/index.md @@ -63,7 +63,7 @@ The user menu provides access to the following items: - **Admin Center:** Access to the [admin center](../../settings/admin.md#admin-center) for operational administration - **Database Admin Interface:** Low level administration via the [Database Admin Interface](../../settings/db_admin.md). *Note: Access may be restricted based on user permissions.* - **Change Color Mode:** Toggle between light and dark color modes. -- **About InvenTree:** View version and license information about InvenTree. *Note: Only available to staff users.* +- **About InvenTree:** View version and license information about InvenTree. - **Logout:** Log out of the InvenTree system. ### Page Panels diff --git a/docs/docs/settings/global.md b/docs/docs/settings/global.md index d9394387d2..375fe4db87 100644 --- a/docs/docs/settings/global.md +++ b/docs/docs/settings/global.md @@ -31,6 +31,7 @@ Configuration of basic server settings: {{ globalsetting("INVENTREE_LINK_PROOF") }} {{ globalsetting("INVENTREE_SHOW_SUPERUSER_BANNER") }} {{ globalsetting("INVENTREE_SHOW_ADMIN_BANNER") }} +{{ globalsetting("INVENTREE_RESTRICT_ABOUT") }} {{ globalsetting("DISPLAY_FULL_NAMES") }} {{ globalsetting("DISPLAY_PROFILE_INFO") }} {{ globalsetting("WEEK_STARTS_ON") }} diff --git a/src/backend/InvenTree/common/setting/system.py b/src/backend/InvenTree/common/setting/system.py index fc0d29c958..e9bf4bb364 100644 --- a/src/backend/InvenTree/common/setting/system.py +++ b/src/backend/InvenTree/common/setting/system.py @@ -216,6 +216,12 @@ SYSTEM_SETTINGS: dict[str, InvenTreeSettingsKeyType] = { 'validator': bool, 'default': False, }, + 'INVENTREE_RESTRICT_ABOUT': { + 'name': _('Restrict showing `about`'), + 'description': _('Show the `about` modal only to superusers'), + 'validator': bool, + 'default': False, + }, 'INVENTREE_SHOW_SUPERUSER_BANNER': { 'name': _('Show superuser banner'), 'description': _('Show a warning banner in the UI when logged in as superuser'), diff --git a/src/backend/InvenTree/common/tests.py b/src/backend/InvenTree/common/tests.py index 550d06189c..c743cde786 100644 --- a/src/backend/InvenTree/common/tests.py +++ b/src/backend/InvenTree/common/tests.py @@ -816,7 +816,7 @@ class GlobalSettingsApiTest(InvenTreeAPITestCase): def test_cast(self): """Test that values are cast to the correct type.""" - key = 'INVENTREE_SHOW_ADMIN_BANNER' + key = 'INVENTREE_RESTRICT_ABOUT' # Delete the associated setting object InvenTreeSetting.objects.filter(key=key).delete() diff --git a/src/backend/InvenTree/config_template.yaml b/src/backend/InvenTree/config_template.yaml index e72c853df0..e4b9c985ab 100644 --- a/src/backend/InvenTree/config_template.yaml +++ b/src/backend/InvenTree/config_template.yaml @@ -242,7 +242,7 @@ ldap: # Override global settings #global_settings: # INVENTREE_DEFAULT_CURRENCY: 'CNY' -# INVENTREE_SHOW_ADMIN_BANNER: true +# INVENTREE_RESTRICT_ABOUT: true # Override plugin settings (by plugin slug) # Settings specified here will be locked and cannot be changed via the UI diff --git a/src/frontend/src/components/nav/FirstUseTour.tsx b/src/frontend/src/components/nav/FirstUseTour.tsx index 2cc1e4921f..3b1a6b97ee 100644 --- a/src/frontend/src/components/nav/FirstUseTour.tsx +++ b/src/frontend/src/components/nav/FirstUseTour.tsx @@ -106,17 +106,15 @@ export function FirstUseTour() { title: t`Admin Center`, description: t`The admin center provides access to administrative functions and can be used to manage various functions required for operation of the instance like user management, templates, parameters, plugins.` }); - - // The 'about' menu item is only shown to staff users - _steps.push({ - target: 'tip-ftu-about', - title: t`About InvenTree`, - description: t`Provides information about the InvenTree instance, including version details and relevant links. Important for bug reports.` - }); } + _steps.push({ + target: 'tip-ftu-about', + title: t`About InvenTree`, + description: t`Provides information about the InvenTree instance, including version details and relevant links. Important for bug reports.` + }); return _steps; - }, [userSettings, globalSettings, user]); + }, [userSettings, globalSettings]); const completeTour = () => { setActive(false); diff --git a/src/frontend/src/components/nav/MainMenu.tsx b/src/frontend/src/components/nav/MainMenu.tsx index 6f57a23631..ad4617046c 100644 --- a/src/frontend/src/components/nav/MainMenu.tsx +++ b/src/frontend/src/components/nav/MainMenu.tsx @@ -120,15 +120,13 @@ export function MainMenu() { > Change Color Mode - {user?.is_staff && ( - aboutInvenTree()} - leftSection={} - id='tip-ftu-about' - > - About InvenTree - - )} + aboutInvenTree()} + leftSection={} + id='tip-ftu-about' + > + About InvenTree + } diff --git a/src/frontend/src/components/nav/NavigationDrawer.tsx b/src/frontend/src/components/nav/NavigationDrawer.tsx index 66b7ec6d5f..6a209d8196 100644 --- a/src/frontend/src/components/nav/NavigationDrawer.tsx +++ b/src/frontend/src/components/nav/NavigationDrawer.tsx @@ -159,8 +159,8 @@ function DrawerContent({ closeFunc }: Readonly<{ closeFunc?: () => void }>) { }, [user]); const menuItemsAbout: MenuLinkItem[] = useMemo( - () => AboutLinks(user), - [user] + () => AboutLinks(globalSettings, user), + [] ); return ( diff --git a/src/frontend/src/defaults/actions.tsx b/src/frontend/src/defaults/actions.tsx index f50d4fb4dd..90e844e7a6 100644 --- a/src/frontend/src/defaults/actions.tsx +++ b/src/frontend/src/defaults/actions.tsx @@ -73,6 +73,13 @@ export function getActions(navigate: NavigateFunction) { }, leftSection: }, + { + id: 'about', + label: t`About InvenTree`, + description: t`About the InvenTree org`, + onClick: () => aboutInvenTree(), + leftSection: + }, { id: 'server-info', label: t`Server Information`, @@ -110,16 +117,6 @@ export function getActions(navigate: NavigateFunction) { } ]; - // The 'about' modal requires staff access to the version API endpoint - staff && - _actions.push({ - id: 'about', - label: t`About InvenTree`, - description: t`About the InvenTree org`, - onClick: () => aboutInvenTree(), - leftSection: - }); - staff && _actions.push({ id: 'data-import', diff --git a/src/frontend/src/defaults/links.tsx b/src/frontend/src/defaults/links.tsx index 794fe32625..da7a9b614c 100644 --- a/src/frontend/src/defaults/links.tsx +++ b/src/frontend/src/defaults/links.tsx @@ -4,6 +4,7 @@ import { openContextModal } from '@mantine/modals'; import { StylishText } from '@lib/components/StylishText'; import { UserRoles } from '@lib/enums/Roles'; +import type { SettingsStateProps } from '@lib/types/Settings'; import type { UserStateProps } from '@lib/types/User'; import { IconBox, @@ -169,7 +170,10 @@ export function licenseInfo() { }); } -export function AboutLinks(user: UserStateProps): MenuLinkItem[] { +export function AboutLinks( + settings: SettingsStateProps, + user: UserStateProps +): MenuLinkItem[] { const base_items: MenuLinkItem[] = [ { id: 'documentation', @@ -203,8 +207,8 @@ export function AboutLinks(user: UserStateProps): MenuLinkItem[] { } ]; - // The 'about' modal requires staff access to the version API endpoint - if (user.isStaff()) { + // Restrict the about link if that setting is set + if (user.isSuperuser() || !settings.isSet('INVENTREE_RESTRICT_ABOUT')) { base_items.push({ id: 'about', title: t`About InvenTree`, diff --git a/src/frontend/src/pages/Index/Settings/SystemSettings.tsx b/src/frontend/src/pages/Index/Settings/SystemSettings.tsx index 5ae02e4827..15a643b96f 100644 --- a/src/frontend/src/pages/Index/Settings/SystemSettings.tsx +++ b/src/frontend/src/pages/Index/Settings/SystemSettings.tsx @@ -55,6 +55,7 @@ export default function SystemSettings() { 'INVENTREE_LINK_PROOF', 'INVENTREE_SHOW_SUPERUSER_BANNER', 'INVENTREE_SHOW_ADMIN_BANNER', + 'INVENTREE_RESTRICT_ABOUT', 'INVENTREE_UPLOAD_MAX_SIZE', 'INVENTREE_STRICT_URLS' ]} diff --git a/src/frontend/tests/pui_modals.spec.ts b/src/frontend/tests/pui_modals.spec.ts index efdba32337..e9810e83ad 100644 --- a/src/frontend/tests/pui_modals.spec.ts +++ b/src/frontend/tests/pui_modals.spec.ts @@ -1,4 +1,4 @@ -import { expect, systemKey, test } from './baseFixtures.js'; +import { systemKey, test } from './baseFixtures.js'; import { adminuser } from './defaults.js'; import { doCachedLogin } from './login.js'; import { setPluginState } from './settings.js'; @@ -139,19 +139,14 @@ test('Spotlight - No Keys', async ({ browser }) => { await page.keyboard.press('Escape'); - // The 'about' action is only available to staff users + // use about await page.getByLabel('open-spotlight').click(); await page - .getByRole('button', { - name: 'Documentation Visit the documentation to learn more about InvenTree' - }) - .waitFor(); - await expect( - page.getByRole('button', { - name: 'About InvenTree About the InvenTree org' - }) - ).toHaveCount(0); - await page.keyboard.press('Escape'); + .getByRole('button', { name: 'About InvenTree About the InvenTree org' }) + .click(); + await page.getByText('This information is only').waitFor(); + + await page.getByLabel('About InvenTree').getByRole('button').click(); // use documentation await page.getByLabel('open-spotlight').click();