372 lines
12 KiB
JavaScript
372 lines
12 KiB
JavaScript
import {
|
|
LAYOUT_DATA,
|
|
Number,
|
|
STATES,
|
|
VerticalDivider
|
|
} from "./chunk-7XW66K7Y.js";
|
|
import {
|
|
Widget
|
|
} from "./chunk-E4IFZ6ZT.js";
|
|
import {
|
|
useGuidedTour
|
|
} from "./chunk-PFI4R5WA.js";
|
|
import {
|
|
useEnterprise
|
|
} from "./chunk-W6ICJ5TB.js";
|
|
import {
|
|
useTracking
|
|
} from "./chunk-GSN7U3BK.js";
|
|
import {
|
|
Layouts
|
|
} from "./chunk-TIVRAWTC.js";
|
|
import {
|
|
Page
|
|
} from "./chunk-5CAWUBTQ.js";
|
|
import {
|
|
useAuth,
|
|
useStrapiApp
|
|
} from "./chunk-W2TBR6J3.js";
|
|
import {
|
|
Box,
|
|
Button,
|
|
Flex,
|
|
Grid,
|
|
LinkButton,
|
|
Main,
|
|
Typography,
|
|
useIntl
|
|
} from "./chunk-7XB6XSWQ.js";
|
|
import {
|
|
Link,
|
|
NavLink
|
|
} from "./chunk-TUXTO2Z5.js";
|
|
import {
|
|
ForwardRef$19,
|
|
ForwardRef$5d
|
|
} from "./chunk-WRD5KPDH.js";
|
|
import {
|
|
require_jsx_runtime
|
|
} from "./chunk-NIAJZ5MX.js";
|
|
import {
|
|
require_react
|
|
} from "./chunk-MADUDGYZ.js";
|
|
import {
|
|
__toESM
|
|
} from "./chunk-PLDDJCW6.js";
|
|
|
|
// node_modules/@strapi/admin/dist/admin/admin/src/pages/Home/HomePage.mjs
|
|
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
|
|
var React = __toESM(require_react(), 1);
|
|
|
|
// node_modules/@strapi/admin/dist/admin/admin/src/pages/Home/components/GuidedTour.mjs
|
|
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
|
|
|
|
// node_modules/@strapi/admin/dist/admin/admin/src/components/GuidedTour/Homepage.mjs
|
|
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
var GuidedTourHomepage = () => {
|
|
const guidedTourState = useGuidedTour("GuidedTourHomepage", (state) => state.guidedTourState);
|
|
const setSkipped = useGuidedTour("GuidedTourHomepage", (state) => state.setSkipped);
|
|
const { formatMessage } = useIntl();
|
|
const { trackUsage } = useTracking();
|
|
const sections = Object.entries(LAYOUT_DATA).map(([key, val]) => ({
|
|
key,
|
|
title: val.home.title,
|
|
content: (0, import_jsx_runtime.jsx)(LinkButton, {
|
|
onClick: () => trackUsage(val.home.trackingEvent),
|
|
tag: NavLink,
|
|
to: val.home.cta.target,
|
|
endIcon: (0, import_jsx_runtime.jsx)(ForwardRef$5d, {}),
|
|
children: formatMessage(val.home.cta.title)
|
|
}),
|
|
isDone: Object.values(guidedTourState[key]).every((value) => value === true)
|
|
}));
|
|
const activeSectionIndex = sections.findIndex((section) => !section.isDone);
|
|
const handleSkip = () => {
|
|
setSkipped(true);
|
|
trackUsage("didSkipGuidedtour");
|
|
};
|
|
return (0, import_jsx_runtime.jsxs)(Box, {
|
|
hasRadius: true,
|
|
shadow: "tableShadow",
|
|
paddingTop: 7,
|
|
paddingRight: 4,
|
|
paddingLeft: 7,
|
|
paddingBottom: 4,
|
|
background: "neutral0",
|
|
children: [
|
|
(0, import_jsx_runtime.jsxs)(Flex, {
|
|
direction: "column",
|
|
alignItems: "stretch",
|
|
gap: 6,
|
|
children: [
|
|
(0, import_jsx_runtime.jsx)(Typography, {
|
|
variant: "beta",
|
|
tag: "h2",
|
|
children: formatMessage({
|
|
id: "app.components.GuidedTour.title",
|
|
defaultMessage: "3 steps to get started"
|
|
})
|
|
}),
|
|
(0, import_jsx_runtime.jsx)(Box, {
|
|
children: sections.map((section, index) => {
|
|
const state = getState(activeSectionIndex, index);
|
|
return (0, import_jsx_runtime.jsxs)(Box, {
|
|
children: [
|
|
(0, import_jsx_runtime.jsxs)(Flex, {
|
|
children: [
|
|
(0, import_jsx_runtime.jsx)(Box, {
|
|
minWidth: `3rem`,
|
|
marginRight: 5,
|
|
children: (0, import_jsx_runtime.jsx)(Number, {
|
|
state,
|
|
children: index + 1
|
|
})
|
|
}),
|
|
(0, import_jsx_runtime.jsx)(Typography, {
|
|
variant: "delta",
|
|
tag: "h3",
|
|
children: formatMessage(section.title)
|
|
})
|
|
]
|
|
}),
|
|
(0, import_jsx_runtime.jsxs)(Flex, {
|
|
alignItems: "flex-start",
|
|
children: [
|
|
(0, import_jsx_runtime.jsx)(Flex, {
|
|
justifyContent: "center",
|
|
minWidth: `3rem`,
|
|
marginBottom: 3,
|
|
marginTop: 3,
|
|
marginRight: 5,
|
|
children: index === sections.length - 1 ? null : (0, import_jsx_runtime.jsx)(VerticalDivider, {
|
|
state
|
|
})
|
|
}),
|
|
(0, import_jsx_runtime.jsx)(Box, {
|
|
marginTop: 2,
|
|
children: state === STATES.IS_ACTIVE ? section.content : null
|
|
})
|
|
]
|
|
})
|
|
]
|
|
}, section.key);
|
|
})
|
|
})
|
|
]
|
|
}),
|
|
(0, import_jsx_runtime.jsx)(Flex, {
|
|
justifyContent: "flex-end",
|
|
children: (0, import_jsx_runtime.jsx)(Button, {
|
|
variant: "tertiary",
|
|
onClick: handleSkip,
|
|
children: formatMessage({
|
|
id: "app.components.GuidedTour.skip",
|
|
defaultMessage: "Skip the tour"
|
|
})
|
|
})
|
|
})
|
|
]
|
|
});
|
|
};
|
|
var getState = (activeSectionIndex, index) => {
|
|
if (activeSectionIndex === -1) {
|
|
return STATES.IS_DONE;
|
|
}
|
|
if (index < activeSectionIndex) {
|
|
return STATES.IS_DONE;
|
|
}
|
|
if (index > activeSectionIndex) {
|
|
return STATES.IS_NOT_DONE;
|
|
}
|
|
return STATES.IS_ACTIVE;
|
|
};
|
|
|
|
// node_modules/@strapi/admin/dist/admin/admin/src/pages/Home/components/GuidedTour.mjs
|
|
var GuidedTour = () => {
|
|
const guidedTourState = useGuidedTour("HomePage", (state) => state.guidedTourState);
|
|
const isGuidedTourVisible = useGuidedTour("HomePage", (state) => state.isGuidedTourVisible);
|
|
const isSkipped = useGuidedTour("HomePage", (state) => state.isSkipped);
|
|
const showGuidedTour = !Object.values(guidedTourState).every((section) => Object.values(section).every((step) => step)) && isGuidedTourVisible && !isSkipped;
|
|
if (!showGuidedTour) {
|
|
return null;
|
|
}
|
|
return (0, import_jsx_runtime2.jsx)(GuidedTourHomepage, {});
|
|
};
|
|
|
|
// node_modules/@strapi/admin/dist/admin/admin/src/pages/Home/HomePage.mjs
|
|
var WidgetRoot = ({ title, icon = ForwardRef$19, permissions = [], children, link }) => {
|
|
const { formatMessage } = useIntl();
|
|
const id = React.useId();
|
|
const Icon = icon;
|
|
const [permissionStatus, setPermissionStatus] = React.useState("loading");
|
|
const checkUserHasPermissions = useAuth("WidgetRoot", (state) => state.checkUserHasPermissions);
|
|
React.useEffect(() => {
|
|
const checkPermissions = async () => {
|
|
const matchingPermissions = await checkUserHasPermissions(permissions);
|
|
const shouldGrant = matchingPermissions.length >= permissions.length;
|
|
setPermissionStatus(shouldGrant ? "granted" : "forbidden");
|
|
};
|
|
if (!permissions || permissions.length === 0) {
|
|
setPermissionStatus("granted");
|
|
} else {
|
|
checkPermissions();
|
|
}
|
|
}, [
|
|
checkUserHasPermissions,
|
|
permissions
|
|
]);
|
|
return (0, import_jsx_runtime3.jsxs)(Flex, {
|
|
width: "100%",
|
|
hasRadius: true,
|
|
direction: "column",
|
|
alignItems: "flex-start",
|
|
background: "neutral0",
|
|
borderColor: "neutral150",
|
|
shadow: "tableShadow",
|
|
tag: "section",
|
|
gap: 4,
|
|
padding: 6,
|
|
"aria-labelledby": id,
|
|
children: [
|
|
(0, import_jsx_runtime3.jsxs)(Flex, {
|
|
direction: "row",
|
|
gap: 2,
|
|
justifyContent: "space-between",
|
|
width: "100%",
|
|
tag: "header",
|
|
children: [
|
|
(0, import_jsx_runtime3.jsxs)(Flex, {
|
|
gap: 2,
|
|
children: [
|
|
(0, import_jsx_runtime3.jsx)(Icon, {
|
|
fill: "neutral500",
|
|
"aria-hidden": true
|
|
}),
|
|
(0, import_jsx_runtime3.jsx)(Typography, {
|
|
textColor: "neutral500",
|
|
variant: "sigma",
|
|
tag: "h2",
|
|
id,
|
|
children: formatMessage(title)
|
|
})
|
|
]
|
|
}),
|
|
link && (0, import_jsx_runtime3.jsx)(Typography, {
|
|
tag: Link,
|
|
variant: "omega",
|
|
textColor: "primary600",
|
|
style: {
|
|
textDecoration: "none"
|
|
},
|
|
to: link.href,
|
|
children: formatMessage(link.label)
|
|
})
|
|
]
|
|
}),
|
|
(0, import_jsx_runtime3.jsxs)(Box, {
|
|
width: "100%",
|
|
height: "261px",
|
|
overflow: "auto",
|
|
tag: "main",
|
|
children: [
|
|
permissionStatus === "loading" && (0, import_jsx_runtime3.jsx)(Widget.Loading, {}),
|
|
permissionStatus === "forbidden" && (0, import_jsx_runtime3.jsx)(Widget.NoPermissions, {}),
|
|
permissionStatus === "granted" && children
|
|
]
|
|
})
|
|
]
|
|
});
|
|
};
|
|
var WidgetComponent = ({ component }) => {
|
|
const [loadedComponent, setLoadedComponent] = React.useState(null);
|
|
React.useEffect(() => {
|
|
const loadComponent = async () => {
|
|
const resolvedComponent = await component();
|
|
setLoadedComponent(() => resolvedComponent);
|
|
};
|
|
loadComponent();
|
|
}, [
|
|
component
|
|
]);
|
|
const Component = loadedComponent;
|
|
if (!Component) {
|
|
return (0, import_jsx_runtime3.jsx)(Widget.Loading, {});
|
|
}
|
|
return (0, import_jsx_runtime3.jsx)(Component, {});
|
|
};
|
|
var HomePageCE = () => {
|
|
const { formatMessage } = useIntl();
|
|
const user = useAuth("HomePageCE", (state) => state.user);
|
|
const displayName = (user == null ? void 0 : user.firstname) ?? (user == null ? void 0 : user.username) ?? (user == null ? void 0 : user.email);
|
|
const getAllWidgets = useStrapiApp("UnstableHomepageCe", (state) => state.widgets.getAll);
|
|
return (0, import_jsx_runtime3.jsxs)(Main, {
|
|
children: [
|
|
(0, import_jsx_runtime3.jsx)(Page.Title, {
|
|
children: formatMessage({
|
|
id: "HomePage.head.title",
|
|
defaultMessage: "Homepage"
|
|
})
|
|
}),
|
|
(0, import_jsx_runtime3.jsx)(Layouts.Header, {
|
|
title: formatMessage({
|
|
id: "HomePage.header.title",
|
|
defaultMessage: "Hello {name}"
|
|
}, {
|
|
name: displayName
|
|
}),
|
|
subtitle: formatMessage({
|
|
id: "HomePage.header.subtitle",
|
|
defaultMessage: "Welcome to your administration panel"
|
|
})
|
|
}),
|
|
(0, import_jsx_runtime3.jsx)(Layouts.Content, {
|
|
children: (0, import_jsx_runtime3.jsxs)(Flex, {
|
|
direction: "column",
|
|
alignItems: "stretch",
|
|
gap: 8,
|
|
paddingBottom: 10,
|
|
children: [
|
|
(0, import_jsx_runtime3.jsx)(GuidedTour, {}),
|
|
(0, import_jsx_runtime3.jsx)(Grid.Root, {
|
|
gap: 5,
|
|
children: getAllWidgets().map((widget) => {
|
|
return (0, import_jsx_runtime3.jsx)(Grid.Item, {
|
|
col: 6,
|
|
s: 12,
|
|
children: (0, import_jsx_runtime3.jsx)(WidgetRoot, {
|
|
title: widget.title,
|
|
icon: widget.icon,
|
|
permissions: widget.permissions,
|
|
link: widget.link,
|
|
children: (0, import_jsx_runtime3.jsx)(WidgetComponent, {
|
|
component: widget.component
|
|
})
|
|
})
|
|
}, widget.uid);
|
|
})
|
|
})
|
|
]
|
|
})
|
|
})
|
|
]
|
|
});
|
|
};
|
|
var HomePage = () => {
|
|
const Page2 = useEnterprise(
|
|
HomePageCE,
|
|
// eslint-disable-next-line import/no-cycle
|
|
async () => (await import("./HomePage-YIBA6A7C.js")).HomePageEE
|
|
);
|
|
if (!Page2) {
|
|
return null;
|
|
}
|
|
return (0, import_jsx_runtime3.jsx)(Page2, {});
|
|
};
|
|
|
|
export {
|
|
WidgetRoot,
|
|
HomePageCE,
|
|
HomePage
|
|
};
|
|
//# sourceMappingURL=chunk-7UVG5SMN.js.map
|