Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,201 @@
|
||||
import { loadWebConfig } from "@toolctrl/config";
|
||||
import { Outlet, useLoaderData, useLocation, useNavigate, useParams } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { LoaderFunctionArgs, MetaFunction } from "react-router";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import UrlUtils from "~/utils/app/UrlUtils";
|
||||
import { useEffect } from "react";
|
||||
import { getUserHasPermission } from "~/utils/helpers/PermissionsHelper";
|
||||
import { useAppOrAdminData } from "~/utils/data/useAppOrAdminData";
|
||||
import SidebarIconsLayout, { IconDto } from "~/components/ui/layouts/SidebarIconsLayout";
|
||||
import CustomerIcon from "~/components/ui/icons/settings/CustomerIcon";
|
||||
import CustomerIconFilled from "~/components/ui/icons/settings/CustomerIconFilled";
|
||||
import PeopleIcon from "~/components/ui/icons/settings/PeopleIcon";
|
||||
import PeopleIconFilled from "~/components/ui/icons/settings/PeopleIconFilled";
|
||||
import MembershipCardIcon from "~/components/ui/icons/settings/MembershipCardIcon";
|
||||
import MembershipCardIconFilled from "~/components/ui/icons/settings/MembershipCardIconFilled";
|
||||
import CompanyIcon from "~/components/ui/icons/crm/CompanyIcon";
|
||||
import CompanyIconFilled from "~/components/ui/icons/crm/CompanyIconFilled";
|
||||
import RestApiIcon from "~/components/ui/icons/entities/RestApiIcon";
|
||||
import RestApiIconFilled from "~/components/ui/icons/entities/RestApiIconFilled";
|
||||
import ActivityHistoryIcon from "~/components/ui/icons/entities/ActivityHistoryIcon";
|
||||
import ActivityHistoryIconFilled from "~/components/ui/icons/entities/ActivityHistoryIconFilled";
|
||||
import ModulesIcon from "~/components/ui/icons/entities/ModulesIcon";
|
||||
import ModulesIconFilled from "~/components/ui/icons/entities/ModulesIconFilled";
|
||||
import { useRootData } from "~/utils/data/useRootData";
|
||||
import CreditsIcon from "~/components/ui/icons/CreditsIcon";
|
||||
import CreditsIconFilled from "~/components/ui/icons/CreditsIconFilled";
|
||||
import { CreditTypes } from "~/modules/usage/dtos/CreditType";
|
||||
import { BellIcon, FileTextIcon, PaintbrushIcon, PlugIcon, ShieldCheckIcon } from "~/components/ui/icons/vendor";
|
||||
|
||||
type LoaderData = {
|
||||
title: string;
|
||||
isProduction?: boolean;
|
||||
};
|
||||
|
||||
export const loader = async ({ request }: LoaderFunctionArgs) => {
|
||||
const { t } = await getTranslations(request);
|
||||
const data: LoaderData = {
|
||||
title: `${t("app.navbar.settings")} | ${process.env.APP_NAME}`,
|
||||
isProduction: loadWebConfig().config.nodeEnv === "production",
|
||||
};
|
||||
return data;
|
||||
};
|
||||
|
||||
export const meta: MetaFunction<typeof loader> = ({ data }) => [{ title: data?.title }];
|
||||
|
||||
export default function SettingsRoute() {
|
||||
const { t } = useTranslation();
|
||||
useLoaderData<LoaderData>();
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const params = useParams();
|
||||
const appOrAdminData = useAppOrAdminData();
|
||||
const rootData = useRootData();
|
||||
|
||||
const getTabs = () => {
|
||||
const tabs: IconDto[] = [];
|
||||
tabs.push({
|
||||
name: t("settings.profile.profileTitle"),
|
||||
href: UrlUtils.currentTenantUrl(params, "settings/profile"),
|
||||
icon: <CustomerIcon className="size-4" aria-hidden="true" />,
|
||||
iconSelected: <CustomerIconFilled className="size-4" aria-hidden="true" />,
|
||||
});
|
||||
// Sicherheit (aktive Sitzungen + vertrauenswürdige Geräte) — jeder verwaltet seine eigenen, daher ungated.
|
||||
tabs.push({
|
||||
name: t("settings.security.title"),
|
||||
href: UrlUtils.currentTenantUrl(params, "settings/security"),
|
||||
icon: <ShieldCheckIcon className="size-4" aria-hidden="true" />,
|
||||
iconSelected: <ShieldCheckIcon className="size-4" aria-hidden="true" />,
|
||||
});
|
||||
if (getUserHasPermission(appOrAdminData, "app.settings.members.view")) {
|
||||
tabs.push({
|
||||
name: t("settings.members.title"),
|
||||
href: UrlUtils.currentTenantUrl(params, "settings/members"),
|
||||
icon: <PeopleIcon className="size-4" aria-hidden="true" />,
|
||||
iconSelected: <PeopleIconFilled className="size-4" aria-hidden="true" />,
|
||||
});
|
||||
}
|
||||
// Gruppen-Screen (Davids GroupsListView) erreichbar machen — nur bei aktivem row-groups-Flag + Permission,
|
||||
// damit kein toter Tab erscheint (analog zum Feature-Gate des Screens selbst).
|
||||
if (rootData.featureFlags?.includes("row-groups") && getUserHasPermission(appOrAdminData, "app.settings.groups.full")) {
|
||||
tabs.push({
|
||||
name: t("models.group.plural"),
|
||||
href: UrlUtils.currentTenantUrl(params, "settings/groups"),
|
||||
icon: <ModulesIcon className="size-4" aria-hidden="true" />,
|
||||
iconSelected: <ModulesIconFilled className="size-4" aria-hidden="true" />,
|
||||
});
|
||||
}
|
||||
if (getUserHasPermission(appOrAdminData, "app.settings.subscription.view")) {
|
||||
tabs.push({
|
||||
name: t("settings.subscription.title"),
|
||||
href: UrlUtils.currentTenantUrl(params, `settings/subscription`),
|
||||
icon: <MembershipCardIcon className="size-4" aria-hidden="true" />,
|
||||
iconSelected: <MembershipCardIconFilled className="size-4" aria-hidden="true" />,
|
||||
});
|
||||
if (CreditTypes.length > 0) {
|
||||
tabs.push({
|
||||
name: t("models.credit.plural"),
|
||||
href: UrlUtils.currentTenantUrl(params, "settings/credits"),
|
||||
icon: <CreditsIcon className="h-5 w-5" />,
|
||||
iconSelected: <CreditsIconFilled className="h-5 w-5" />,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (getUserHasPermission(appOrAdminData, "app.settings.account.view")) {
|
||||
tabs.push({
|
||||
name: t("settings.tenant.title"),
|
||||
href: UrlUtils.currentTenantUrl(params, "settings/account"),
|
||||
exact: true,
|
||||
icon: <CompanyIcon className="size-4" aria-hidden="true" />,
|
||||
iconSelected: <CompanyIconFilled className="size-4" aria-hidden="true" />,
|
||||
});
|
||||
tabs.push({
|
||||
name: t("settings.theme.title"),
|
||||
href: UrlUtils.currentTenantUrl(params, "settings/theme"),
|
||||
icon: <PaintbrushIcon className="size-4" aria-hidden="true" />,
|
||||
iconSelected: <PaintbrushIcon className="size-4" aria-hidden="true" />,
|
||||
});
|
||||
}
|
||||
// if (rootData.appConfiguration.app.features.tenantTypes && getUserHasPermission(appOrAdminData, "app.settings.accounts.view")) {
|
||||
// tabs.push({
|
||||
// name: t("models.tenant.plural"),
|
||||
// href: UrlUtils.currentTenantUrl(params, "settings/accounts"),
|
||||
// icon: <LinkIcon className="size-4" aria-hidden="true" />,
|
||||
// iconSelected: <LinkIconFilled className="size-4" aria-hidden="true" />,
|
||||
// });
|
||||
// }
|
||||
if (getUserHasPermission(appOrAdminData, "app.settings.roles.view")) {
|
||||
tabs.push({
|
||||
name: t("models.role.plural"),
|
||||
href: UrlUtils.currentTenantUrl(params, "settings/roles-and-permissions"),
|
||||
icon: <ShieldCheckIcon className="size-4" aria-hidden="true" />,
|
||||
iconSelected: <ShieldCheckIcon className="size-4" aria-hidden="true" />,
|
||||
});
|
||||
}
|
||||
tabs.push({
|
||||
name: t("settings.notifications.title"),
|
||||
href: UrlUtils.currentTenantUrl(params, "settings/notifications"),
|
||||
icon: <BellIcon className="size-4" aria-hidden="true" />,
|
||||
iconSelected: <BellIcon className="size-4" aria-hidden="true" />,
|
||||
});
|
||||
if (getUserHasPermission(appOrAdminData, "app.settings.account.view")) {
|
||||
tabs.push({
|
||||
name: t("settings.policies.title"),
|
||||
href: UrlUtils.currentTenantUrl(params, "settings/policies"),
|
||||
icon: <FileTextIcon className="size-4" aria-hidden="true" />,
|
||||
iconSelected: <FileTextIcon className="size-4" aria-hidden="true" />,
|
||||
});
|
||||
}
|
||||
if (rootData.appConfiguration.app.features.tenantApiKeys && getUserHasPermission(appOrAdminData, "app.settings.apiKeys.view")) {
|
||||
tabs.push({
|
||||
name: t("settings.api.title"),
|
||||
href: UrlUtils.currentTenantUrl(params, "settings/api"),
|
||||
icon: <RestApiIcon className="size-4" aria-hidden="true" />,
|
||||
iconSelected: <RestApiIconFilled className="size-4" aria-hidden="true" />,
|
||||
});
|
||||
}
|
||||
if (getUserHasPermission(appOrAdminData, "app.settings.auditTrails.view")) {
|
||||
tabs.push({
|
||||
name: t("models.log.plural"),
|
||||
href: UrlUtils.currentTenantUrl(params, "settings/logs"),
|
||||
icon: <ActivityHistoryIcon className="size-4" aria-hidden="true" />,
|
||||
iconSelected: <ActivityHistoryIconFilled className="size-4" aria-hidden="true" />,
|
||||
});
|
||||
}
|
||||
if (getUserHasPermission(appOrAdminData, "app.plugins.use")) {
|
||||
tabs.push({
|
||||
name: t("settings.plugins.title"),
|
||||
href: UrlUtils.currentTenantUrl(params, "settings/plugins"),
|
||||
icon: <PlugIcon className="size-4" aria-hidden="true" />,
|
||||
iconSelected: <PlugIcon className="size-4" aria-hidden="true" />,
|
||||
});
|
||||
}
|
||||
if (rootData.appConfiguration.app.features.tenantEntityCustomization && getUserHasPermission(appOrAdminData, "app.settings.account.update")) {
|
||||
tabs.push({
|
||||
name: t("models.entity.plural"),
|
||||
href: UrlUtils.currentTenantUrl(params, "settings/entities"),
|
||||
icon: <ModulesIcon className="size-4" aria-hidden="true" />,
|
||||
iconSelected: <ModulesIconFilled className="size-4" aria-hidden="true" />,
|
||||
});
|
||||
}
|
||||
// setTabs(tabs);
|
||||
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
|
||||
return tabs;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (UrlUtils.stripTrailingSlash(location.pathname) === UrlUtils.currentTenantUrl(params, "settings")) {
|
||||
navigate(UrlUtils.currentTenantUrl(params, "settings/profile"));
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [location.pathname]);
|
||||
|
||||
return (
|
||||
<SidebarIconsLayout label={{ align: "right" }} items={getTabs()}>
|
||||
<Outlet />
|
||||
</SidebarIconsLayout>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user