mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 08:52:26 +00:00
Merge pull request #10851 from strapi/subnav-notification
added subnav application notification
This commit is contained in:
commit
052eebe6b1
@ -1,16 +1,16 @@
|
|||||||
import { useEffect, useReducer } from 'react';
|
import { useEffect, useReducer } from 'react';
|
||||||
import { hasPermissions, useRBACProvider, useStrapiApp } from '@strapi/helper-plugin';
|
import { hasPermissions, useRBACProvider, useStrapiApp, useAppInfos } from '@strapi/helper-plugin';
|
||||||
|
|
||||||
import reducer, { initialState } from './reducer';
|
import reducer, { initialState } from './reducer';
|
||||||
import init from './init';
|
import init from './init';
|
||||||
|
|
||||||
const useSettingsMenu = (noCheck = false) => {
|
const useSettingsMenu = (noCheck = false) => {
|
||||||
const { allPermissions: permissions } = useRBACProvider();
|
const { allPermissions: permissions } = useRBACProvider();
|
||||||
|
const { shouldUpdateStrapi } = useAppInfos();
|
||||||
const { settings } = useStrapiApp();
|
const { settings } = useStrapiApp();
|
||||||
|
|
||||||
const [{ isLoading, menu }, dispatch] = useReducer(reducer, initialState, () =>
|
const [{ isLoading, menu }, dispatch] = useReducer(reducer, initialState, () =>
|
||||||
init(initialState, settings)
|
init(initialState, { settings, shouldUpdateStrapi })
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -4,11 +4,15 @@ import adminPermissions from '../../permissions';
|
|||||||
import formatLinks from './utils/formatLinks';
|
import formatLinks from './utils/formatLinks';
|
||||||
import globalLinks from './utils/globalLinks';
|
import globalLinks from './utils/globalLinks';
|
||||||
|
|
||||||
const init = (initialState, settings) => {
|
const init = (initialState, { settings, shouldUpdateStrapi }) => {
|
||||||
// Retrieve the links that will be injected into the global section
|
// Retrieve the links that will be injected into the global section
|
||||||
const pluginsGlobalLinks = settings.global.links;
|
const pluginsGlobalLinks = settings.global.links;
|
||||||
// Sort the links by name
|
// Sort the links by name
|
||||||
const sortedGlobalLinks = sortLinks([...pluginsGlobalLinks, ...globalLinks]);
|
const sortedGlobalLinks = sortLinks([...pluginsGlobalLinks, ...globalLinks]).map(link => ({
|
||||||
|
...link,
|
||||||
|
hasNotification: link.id === 'application-infos' && shouldUpdateStrapi,
|
||||||
|
}));
|
||||||
|
|
||||||
const otherSections = Object.values(omit(settings, 'global'));
|
const otherSections = Object.values(omit(settings, 'global'));
|
||||||
|
|
||||||
const menu = [
|
const menu = [
|
||||||
|
@ -38,7 +38,7 @@ const SettingsNav = ({ menu }) => {
|
|||||||
{sections.map(section => (
|
{sections.map(section => (
|
||||||
<SubNavSection key={section.id} label={formatMessage(section.intlLabel)}>
|
<SubNavSection key={section.id} label={formatMessage(section.intlLabel)}>
|
||||||
{section.links.map(link => (
|
{section.links.map(link => (
|
||||||
<SubNavLink to={link.to} key={link.id}>
|
<SubNavLink withBullet={link.hasNotification} to={link.to} key={link.id}>
|
||||||
{formatMessage(link.intlLabel)}
|
{formatMessage(link.intlLabel)}
|
||||||
</SubNavLink>
|
</SubNavLink>
|
||||||
))}
|
))}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user