mirror of
https://github.com/inventree/InvenTree.git
synced 2026-05-09 03:03:41 +00:00
[UI] Adjust default dashboard (#11889)
- Only display "news" for superuser Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -16,6 +16,7 @@ import { type Layout, Responsive, WidthProvider } from 'react-grid-layout';
|
|||||||
import { useShallow } from 'zustand/react/shallow';
|
import { useShallow } from 'zustand/react/shallow';
|
||||||
import { useDashboardItems } from '../../hooks/UseDashboardItems';
|
import { useDashboardItems } from '../../hooks/UseDashboardItems';
|
||||||
import { useLocalState } from '../../states/LocalState';
|
import { useLocalState } from '../../states/LocalState';
|
||||||
|
import { useUserState } from '../../states/UserState';
|
||||||
import DashboardMenu from './DashboardMenu';
|
import DashboardMenu from './DashboardMenu';
|
||||||
import DashboardWidget, { type DashboardWidgetProps } from './DashboardWidget';
|
import DashboardWidget, { type DashboardWidgetProps } from './DashboardWidget';
|
||||||
import DashboardWidgetDrawer from './DashboardWidgetDrawer';
|
import DashboardWidgetDrawer from './DashboardWidgetDrawer';
|
||||||
@@ -23,6 +24,8 @@ import DashboardWidgetDrawer from './DashboardWidgetDrawer';
|
|||||||
const ReactGridLayout = WidthProvider(Responsive);
|
const ReactGridLayout = WidthProvider(Responsive);
|
||||||
|
|
||||||
export default function DashboardLayout() {
|
export default function DashboardLayout() {
|
||||||
|
const user = useUserState();
|
||||||
|
|
||||||
// Dashboard layout definition
|
// Dashboard layout definition
|
||||||
const [layouts, setLayouts] = useState({});
|
const [layouts, setLayouts] = useState({});
|
||||||
// Dashboard widget selection
|
// Dashboard widget selection
|
||||||
@@ -224,8 +227,8 @@ export default function DashboardLayout() {
|
|||||||
setLayouts({});
|
setLayouts({});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const defaultLayouts = {
|
const defaultLayouts: any = useMemo(() => {
|
||||||
lg: [
|
const layouts: any[] = [
|
||||||
{
|
{
|
||||||
w: 6,
|
w: 6,
|
||||||
h: 4,
|
h: 4,
|
||||||
@@ -236,8 +239,12 @@ export default function DashboardLayout() {
|
|||||||
minH: 4,
|
minH: 4,
|
||||||
moved: false,
|
moved: false,
|
||||||
static: false
|
static: false
|
||||||
},
|
}
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (user.isSuperuser()) {
|
||||||
|
// Superuser can also view the "news" widget
|
||||||
|
layouts.push({
|
||||||
w: 6,
|
w: 6,
|
||||||
h: 4,
|
h: 4,
|
||||||
x: 6,
|
x: 6,
|
||||||
@@ -247,9 +254,13 @@ export default function DashboardLayout() {
|
|||||||
minH: 4,
|
minH: 4,
|
||||||
moved: false,
|
moved: false,
|
||||||
static: false
|
static: false
|
||||||
|
});
|
||||||
}
|
}
|
||||||
]
|
|
||||||
|
return {
|
||||||
|
lg: layouts
|
||||||
};
|
};
|
||||||
|
}, [user]);
|
||||||
const loadWigs = ['news', 'gstart'];
|
const loadWigs = ['news', 'gstart'];
|
||||||
const defaultWidgets = useMemo(() => {
|
const defaultWidgets = useMemo(() => {
|
||||||
return loadWigs
|
return loadWigs
|
||||||
|
|||||||
Reference in New Issue
Block a user