fix(i18n): resolve build/type errors, sync main, and address CodeRabbit items
This commit is contained in:
@@ -10,12 +10,14 @@ import useFetchApi from "@utils/api";
|
||||
import { isNetBirdCloud } from "@utils/netbird";
|
||||
import { ExternalLinkIcon, User2 } from "lucide-react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import React, { lazy, Suspense } from "react";
|
||||
import { lazy, Suspense } from "react";
|
||||
import TeamIcon from "@/assets/icons/TeamIcon";
|
||||
import { useGroups } from "@/contexts/GroupsProvider";
|
||||
import { usePermissions } from "@/contexts/PermissionsProvider";
|
||||
import { User } from "@/interfaces/User";
|
||||
import PageContainer from "@/layouts/PageContainer";
|
||||
import { AccountMfaCard } from "@/cloud/mfa/AccountMFACard";
|
||||
import { IdentityProviderCard } from "@/modules/integrations/idp-sync/IdentityProviderCard";
|
||||
|
||||
const UsersTable = lazy(() => import("@/modules/users/UsersTable"));
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ interface MultiSelectProps {
|
||||
showRoutes?: boolean;
|
||||
disabledGroups?: Group[];
|
||||
"data-testid"?: string;
|
||||
dataCy?: string;
|
||||
showResourceCounter?: boolean;
|
||||
showResources?: boolean;
|
||||
showPeers?: boolean;
|
||||
@@ -120,6 +121,7 @@ export function PeerGroupSelector({
|
||||
showRoutes = false,
|
||||
disabledGroups,
|
||||
"data-testid": dataTestId = "group-selector-dropdown",
|
||||
dataCy,
|
||||
showResourceCounter = true,
|
||||
showResources = false,
|
||||
showPeers = false,
|
||||
@@ -394,6 +396,7 @@ export function PeerGroupSelector({
|
||||
)}
|
||||
disabled={disabled}
|
||||
data-testid={dataTestId}
|
||||
data-cy={dataCy}
|
||||
ref={inputRef}
|
||||
>
|
||||
<div
|
||||
|
||||
@@ -14,15 +14,9 @@ import { cn } from "@utils/helpers";
|
||||
import { CheckIcon, GlobeIcon } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { useLocale } from "@/contexts/LocaleProvider";
|
||||
import { locales, type Locale } from "@/i18n/config";
|
||||
import { locales, type Locale, LOCALE_LABELS } from "@/i18n/config";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
/** Human-readable label for each locale, shown in the switcher. */
|
||||
const LOCALE_LABELS: Record<Locale, string> = {
|
||||
en: "English",
|
||||
zh: "中文",
|
||||
};
|
||||
|
||||
/**
|
||||
* Header control that switches the active locale. Writes the choice to the
|
||||
* `NEXT_LOCALE` cookie (via {@link useLocale}) so it persists across reloads
|
||||
|
||||
@@ -25,10 +25,16 @@ export type Locale = (typeof locales)[number];
|
||||
/** Locale used when no preference is stored or detectable. */
|
||||
export const defaultLocale: Locale = "en";
|
||||
|
||||
/** Human-readable label for each locale, shown in selectors and switchers. */
|
||||
export const LOCALE_LABELS: Record<Locale, string> = {
|
||||
en: "English",
|
||||
zh: "中文",
|
||||
};
|
||||
|
||||
/** Message catalog keyed by locale. */
|
||||
export const messages: Record<Locale, typeof en> = {
|
||||
en,
|
||||
zh: zh as unknown as typeof en,
|
||||
zh,
|
||||
};
|
||||
|
||||
/** Cookie name used to persist the user's locale choice. */
|
||||
|
||||
@@ -65,8 +65,8 @@ type Props = {
|
||||
};
|
||||
|
||||
function createAccessControlTableColumns(
|
||||
t: (key: string, params?: Record<string, unknown>) => string,
|
||||
tCommon: (key: string) => string,
|
||||
t: ReturnType<typeof useTranslations<"policies">>,
|
||||
tCommon: ReturnType<typeof useTranslations<"common">>,
|
||||
): ColumnDef<Policy>[] {
|
||||
return [
|
||||
{
|
||||
|
||||
@@ -864,10 +864,7 @@ export default function ActivityDescription({ event }: Props) {
|
||||
ip: m?.ip,
|
||||
platform: m?.platform,
|
||||
original_reason: m?.original_reason
|
||||
? t.rich("desc_compliance_original_reason", {
|
||||
reason: m?.original_reason,
|
||||
Value: (chunks) => <Value>{chunks}</Value>,
|
||||
})
|
||||
? ` (original non-compliant reason: ${m.original_reason})`
|
||||
: "",
|
||||
Value: (chunks) => <Value>{chunks}</Value>,
|
||||
})}
|
||||
|
||||
@@ -40,7 +40,6 @@ type Props = {
|
||||
onCanceled?: () => void;
|
||||
};
|
||||
export const PeerMultiSelect = ({ selectedPeers = {}, onCanceled }: Props) => {
|
||||
const t = useTranslations("peers");
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{Object.keys(selectedPeers).length > 0 && (
|
||||
@@ -57,6 +56,7 @@ const PeerGroupMassAssignmentContent = ({
|
||||
selectedPeers = {},
|
||||
onCanceled,
|
||||
}: Props) => {
|
||||
const t = useTranslations("peers");
|
||||
const { mutate } = useSWRConfig();
|
||||
const { confirm } = useDialog();
|
||||
const { permission } = usePermissions();
|
||||
|
||||
@@ -8,7 +8,7 @@ import { notify } from "@components/Notification";
|
||||
import * as Tabs from "@radix-ui/react-tabs";
|
||||
import { useApiCall } from "@utils/api";
|
||||
import { cn } from "@utils/helpers";
|
||||
import { isLocalDev, isNetBirdHosted } from "@utils/netbird";
|
||||
import { isLocalDev, isNetBirdCloud } from "@utils/netbird";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import { isEmpty } from "lodash";
|
||||
import {
|
||||
@@ -175,7 +175,7 @@ export default function GroupsSettings({ account }: Props) {
|
||||
helpText={t("groupPropagationHelp")}
|
||||
disabled={!permission.settings.update}
|
||||
/>
|
||||
{(!isNetBirdHosted() || isLocalDev()) && (
|
||||
{(!isNetBirdCloud() || isLocalDev()) && (
|
||||
<FancyToggleSwitch
|
||||
value={jwtGroupSync}
|
||||
onChange={setJwtGroupSync}
|
||||
@@ -191,7 +191,7 @@ export default function GroupsSettings({ account }: Props) {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{(!isNetBirdHosted() || isLocalDev()) && (
|
||||
{(!isNetBirdCloud() || isLocalDev()) && (
|
||||
<AnimatePresence>
|
||||
{jwtGroupSync && (
|
||||
<div className={"overflow-hidden -top-4 relative z-0"}>
|
||||
|
||||
@@ -12,13 +12,7 @@ import { LanguagesIcon } from "lucide-react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import React from "react";
|
||||
import { useLocale } from "@/contexts/LocaleProvider";
|
||||
import { locales, type Locale } from "@/i18n/config";
|
||||
|
||||
/** Human-readable label for each locale, shown in the selector. */
|
||||
const LOCALE_LABELS: Record<Locale, string> = {
|
||||
en: "English",
|
||||
zh: "中文",
|
||||
};
|
||||
import { locales, type Locale, LOCALE_LABELS } from "@/i18n/config";
|
||||
|
||||
const options: SelectOption[] = locales.map((locale) => ({
|
||||
value: locale,
|
||||
|
||||
@@ -11,7 +11,7 @@ import { useHasChanges } from "@hooks/useHasChanges";
|
||||
import * as Tabs from "@radix-ui/react-tabs";
|
||||
import { useApiCall } from "@utils/api";
|
||||
import { validator } from "@utils/helpers";
|
||||
import { isNetBirdHosted } from "@utils/netbird";
|
||||
import { isNetBirdCloud } from "@utils/netbird";
|
||||
import cidr from "ip-cidr";
|
||||
import { ExternalLinkIcon, GlobeIcon, NetworkIcon } from "lucide-react";
|
||||
import React, { useMemo, useState } from "react";
|
||||
@@ -234,7 +234,7 @@ function NetworkSettingsTabContent({ account }: Readonly<Props>) {
|
||||
<div className={"w-full"}>
|
||||
<Input
|
||||
placeholder={
|
||||
isNetBirdHosted()
|
||||
isNetBirdCloud()
|
||||
? t("dnsDomainHostedPlaceholder")
|
||||
: t("dnsDomainSelfhostedPlaceholder")
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export const UserResendInviteButton = ({ user }: Props) => {
|
||||
setIsLoading(true);
|
||||
notify({
|
||||
title: t("resendInviteNotify"),
|
||||
description: t("resendingInviteTo", { email: user.email }),
|
||||
description: t("resendingInviteTo", { email: user.email || "" }),
|
||||
promise: userRequest
|
||||
.post("", `/${user.id}/invite`)
|
||||
.finally(() => setIsLoading(false)),
|
||||
|
||||
Reference in New Issue
Block a user