Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ActionFunctionArgs, LoaderFunctionArgs, redirect } from "react-router";
|
||||
import { Outlet, useLocation, useNavigate, useParams } from "react-router";
|
||||
import AppLayout from "~/components/app/AppLayout";
|
||||
@@ -8,7 +9,7 @@ import {
|
||||
getAuthUserWithoutPasswordById as getUser,
|
||||
getTenantMembershipByIds as getTenantUserByIds,
|
||||
updateAuthUserDefaultTenantId as updateUserDefaultTenantId,
|
||||
} from "@toolctrl/db/auth-boundary.server";
|
||||
} from "@hivegrid/db/auth-boundary.server";
|
||||
import { getTenantIdFromUrl } from "~/utils/services/.server/urlService";
|
||||
import { getUserInfo, validateCSRFToken } from "~/utils/session.server";
|
||||
import { getAppConfiguration } from "~/utils/db/appConfiguration.db.server";
|
||||
@@ -26,7 +27,7 @@ import SupportTicketsServer from "~/modules/helpDesk/services/SupportTickets.ser
|
||||
import clsx from "clsx";
|
||||
import { useThemePreviewStore } from "~/stores/themePreviewStore";
|
||||
import { getThemeStyle, parseThemeConfig } from "~/utils/theme/ThemeConfig";
|
||||
import { loadRequiredWebConfig } from "@toolctrl/config";
|
||||
import { loadRequiredWebConfig } from "@hivegrid/config";
|
||||
import { absoluteAppRootPath } from "~/utils/app/CrossHostUrls";
|
||||
import { appTenantDeactivatedPath, appTenantPlanRequiredPath, appTenantSubscriptionRequiredPath } from "~/utils/app/AppTenantStatusPaths";
|
||||
import { withMetrics } from "~/lib/metrics/ssr";
|
||||
@@ -34,6 +35,7 @@ import { getIsSuperAdminByUserId, requireAuth } from "~/utils/loaders.middleware
|
||||
import { ensureTenantUserAppRoles } from "~/utils/db/permissions/userRoles.db.server";
|
||||
import { evaluatePasswordPolicyBanner } from "~/services/auth/password-policy-banner.server";
|
||||
import PasswordPolicyBanner from "~/components/app/PasswordPolicyBanner";
|
||||
import { buildBillingStatusBannerVm, getTenantBillingReadOnlyState, type BillingStatusBannerVm } from "~/utils/services/.server/billingStatusService";
|
||||
export { serverTimingHeaders as headers };
|
||||
export { appTenantDeactivatedPath, appTenantPlanRequiredPath, appTenantSubscriptionRequiredPath } from "~/utils/app/AppTenantStatusPaths";
|
||||
|
||||
@@ -81,7 +83,7 @@ export const loader = withMetrics("app-tenant", async ({ request, params }: Load
|
||||
);
|
||||
}
|
||||
|
||||
const data = await time(loadAppData({ request, params, t, time, tenantId, userInfo, user }), "loadAppData");
|
||||
const data = await time(loadAppData({ request, params, t, time, tenantId, userInfo, user, isOperatorAdmin }), "loadAppData");
|
||||
if (!isOperatorAdmin && user?.defaultTenantId !== tenantId) {
|
||||
await time(updateUserDefaultTenantId({ defaultTenantId: tenantId }, userInfo.userId), "updateUserDefaultTenantId");
|
||||
}
|
||||
@@ -114,7 +116,13 @@ export const loader = withMetrics("app-tenant", async ({ request, params }: Load
|
||||
cookieHeader: request.headers.get("cookie"),
|
||||
});
|
||||
|
||||
return Response.json({ ...data, passwordPolicyBanner }, { headers: getServerTimingHeader() });
|
||||
const billingStatusBanner = buildBillingStatusBannerVm({
|
||||
status: data.mySubscription?.status,
|
||||
tenantSlug: params.tenant ?? tenantId,
|
||||
trialEndsAt: data.mySubscription?.trialEndsAt,
|
||||
});
|
||||
|
||||
return Response.json({ ...data, passwordPolicyBanner, billingStatusBanner }, { headers: getServerTimingHeader() });
|
||||
});
|
||||
|
||||
export const action = async ({ request, params }: ActionFunctionArgs) => {
|
||||
@@ -130,6 +138,10 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
|
||||
const message = form.get("message")?.toString() || "";
|
||||
const fromUrl = form.get("fromUrl")?.toString() || "";
|
||||
const tenantId = await getTenantIdFromUrl(params);
|
||||
const billingState = await getTenantBillingReadOnlyState(tenantId);
|
||||
if (billingState.readOnly) {
|
||||
return Response.json({ error: t("billing:status.readOnly") }, { status: 423 });
|
||||
}
|
||||
if (!message) {
|
||||
return Response.json({ error: t("feedback.messageRequired") }, { status: 400 });
|
||||
}
|
||||
@@ -154,6 +166,10 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
|
||||
const subject = form.get("subject")?.toString() || "";
|
||||
const fromUrl = form.get("fromUrl")?.toString() || "";
|
||||
const tenantId = await getTenantIdFromUrl(params);
|
||||
const billingState = await getTenantBillingReadOnlyState(tenantId);
|
||||
if (billingState.readOnly) {
|
||||
return Response.json({ error: t("billing:status.readOnly") }, { status: 423 });
|
||||
}
|
||||
try {
|
||||
await SupportTicketsServer.createInline({
|
||||
t,
|
||||
@@ -173,6 +189,7 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
|
||||
|
||||
type AppTenantLoaderExtras = {
|
||||
passwordPolicyBanner?: { show: boolean; reason?: string };
|
||||
billingStatusBanner?: BillingStatusBannerVm;
|
||||
};
|
||||
|
||||
export default function AppTenantRoute() {
|
||||
@@ -180,6 +197,7 @@ export default function AppTenantRoute() {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const params = useParams();
|
||||
const { t } = useTranslation();
|
||||
const { appConfiguration, userSession } = useRootData();
|
||||
const isDarkMode = userSession?.lightOrDarkMode === "dark";
|
||||
const tenantSlug = params.tenant ?? "";
|
||||
@@ -224,6 +242,13 @@ export default function AppTenantRoute() {
|
||||
<PasswordPolicyBanner changePasswordHref={changePasswordHref} />
|
||||
</div>
|
||||
) : null}
|
||||
{appData.billingStatusBanner?.visible ? (
|
||||
<div className="px-4 pt-4 sm:px-6 lg:px-8">
|
||||
<div className="rounded-md border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-950 dark:border-amber-800 dark:bg-amber-950 dark:text-amber-50">
|
||||
{t(appData.billingStatusBanner.messageKey)}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
<Outlet />
|
||||
</AppLayout>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user