show credentials tab in oss

This commit is contained in:
miloschwartz
2025-12-06 13:11:53 -05:00
parent d714f7d52c
commit 22941c0653
6 changed files with 110 additions and 126 deletions

View File

@@ -138,6 +138,8 @@ export default function CredentialsPage() {
</SettingsSectionDescription>
</SettingsSectionHeader>
<SettingsSectionBody>
<SecurityFeaturesAlert />
<InfoSections cols={3}>
<InfoSection>
<InfoSectionTitle>
@@ -194,6 +196,7 @@ export default function CredentialsPage() {
</Alert>
)}
</SettingsSectionBody>
{build !== "oss" && (
<SettingsSectionFooter>
<div className="flex gap-2">
<Button
@@ -217,6 +220,7 @@ export default function CredentialsPage() {
</Button>
</div>
</SettingsSectionFooter>
)}
</SettingsSection>
</SettingsContainer>
@@ -236,19 +240,27 @@ export default function CredentialsPage() {
{shouldDisconnect ? (
<>
<p>
{t("remoteExitNodeRegenerateAndDisconnectConfirmation")}
{t(
"remoteExitNodeRegenerateAndDisconnectConfirmation"
)}
</p>
<p>
{t("remoteExitNodeRegenerateAndDisconnectWarning")}
{t(
"remoteExitNodeRegenerateAndDisconnectWarning"
)}
</p>
</>
) : (
<>
<p>
{t("remoteExitNodeRegenerateCredentialsConfirmation")}
{t(
"remoteExitNodeRegenerateCredentialsConfirmation"
)}
</p>
<p>
{t("remoteExitNodeRegenerateCredentialsWarning")}
{t(
"remoteExitNodeRegenerateCredentialsWarning"
)}
</p>
</>
)}

View File

@@ -44,12 +44,13 @@ export default function CredentialsPage() {
const [modalOpen, setModalOpen] = useState(false);
const [clientDefaults, setClientDefaults] =
useState<PickClientDefaultsResponse | null>(null);
const [currentOlmId, setCurrentOlmId] = useState<string | null>(client.olmId);
const [currentOlmId, setCurrentOlmId] = useState<string | null>(
client.olmId
);
const [regeneratedSecret, setRegeneratedSecret] = useState<string | null>(
null
);
const [showCredentialsAlert, setShowCredentialsAlert] = useState(false);
const [shouldDisconnect, setShouldDisconnect] = useState(true);
const { licenseStatus, isUnlocked } = useLicenseStatusContext();
const subscription = useSubscriptionStatusContext();
@@ -70,8 +71,7 @@ export default function CredentialsPage() {
const rekeyRes = await api.post(
`/re-key/${client?.clientId}/regenerate-client-secret`,
{
secret: data.olmSecret,
disconnect: shouldDisconnect
secret: data.olmSecret
}
);
@@ -125,6 +125,8 @@ export default function CredentialsPage() {
</SettingsSectionDescription>
</SettingsSectionHeader>
<SettingsSectionBody>
<SecurityFeaturesAlert />
<InfoSections cols={3}>
<InfoSection>
<InfoSectionTitle>
@@ -156,7 +158,9 @@ export default function CredentialsPage() {
{displaySecret ? (
<CopyToClipboard text={displaySecret} />
) : (
<span>{"••••••••••••••••••••••••••••••••"}</span>
<span>
{"••••••••••••••••••••••••••••••••"}
</span>
)}
</InfoSectionContent>
</InfoSection>
@@ -174,29 +178,16 @@ export default function CredentialsPage() {
</Alert>
)}
</SettingsSectionBody>
{build !== "oss" && (
<SettingsSectionFooter>
<div className="flex gap-2">
<Button
variant="outline"
onClick={() => {
setShouldDisconnect(false);
setModalOpen(true);
}}
onClick={() => setModalOpen(true)}
disabled={isSecurityFeatureDisabled()}
>
{t("regenerateCredentialsButton")}
</Button>
<Button
onClick={() => {
setShouldDisconnect(true);
setModalOpen(true);
}}
disabled={isSecurityFeatureDisabled()}
>
{t("clientRegenerateAndDisconnect")}
</Button>
</div>
</SettingsSectionFooter>
)}
</SettingsSection>
</SettingsContainer>
@@ -213,32 +204,11 @@ export default function CredentialsPage() {
}}
dialog={
<div className="space-y-2">
{shouldDisconnect ? (
<>
<p>
{t("clientRegenerateAndDisconnectConfirmation")}
</p>
<p>
{t("clientRegenerateAndDisconnectWarning")}
</p>
</>
) : (
<>
<p>
{t("clientRegenerateCredentialsConfirmation")}
</p>
<p>
{t("clientRegenerateCredentialsWarning")}
</p>
</>
)}
<p>{t("regenerateCredentialsConfirmation")}</p>
<p>{t("regenerateCredentialsWarning")}</p>
</div>
}
buttonText={
shouldDisconnect
? t("clientRegenerateAndDisconnect")
: t("regenerateCredentialsButton")
}
buttonText={t("regenerateCredentialsButton")}
onConfirm={handleConfirmRegenerate}
string={getConfirmationString()}
title={t("regenerateCredentials")}

View File

@@ -39,14 +39,10 @@ export default async function SettingsLayout(props: SettingsLayoutProps) {
title: t("general"),
href: `/{orgId}/settings/clients/machine/{clientId}/general`
},
...(build === "enterprise"
? [
{
title: t("credentials"),
href: `/{orgId}/settings/clients/machine/{clientId}/credentials`
}
]
: [])
];
return (

View File

@@ -202,6 +202,9 @@ export default function CredentialsPage() {
{t("siteNewtCredentialsDescription")}
</SettingsSectionDescription>
</SettingsSectionHeader>
<SecurityFeaturesAlert />
<SettingsSectionBody>
<InfoSections cols={3}>
<InfoSection>
@@ -260,6 +263,7 @@ export default function CredentialsPage() {
</Alert>
)}
</SettingsSectionBody>
{build !== "oss" && (
<SettingsSectionFooter>
<div className="flex gap-2">
<Button
@@ -283,6 +287,7 @@ export default function CredentialsPage() {
</Button>
</div>
</SettingsSectionFooter>
)}
</SettingsSection>
)}
@@ -367,6 +372,7 @@ export default function CredentialsPage() {
</>
)}
</SettingsSectionBody>
{build === "enterprise" && (
<SettingsSectionFooter>
<Button
onClick={() => setModalOpen(true)}
@@ -375,6 +381,7 @@ export default function CredentialsPage() {
{t("siteRegenerateAndDisconnect")}
</Button>
</SettingsSectionFooter>
)}
</SettingsSection>
)}
</SettingsContainer>

View File

@@ -35,25 +35,24 @@ export default async function SettingsLayout(props: SettingsLayoutProps) {
const navItems = [
{
title: t('general'),
href: `/${params.orgId}/settings/sites/${params.niceId}/general`,
title: t("general"),
href: `/${params.orgId}/settings/sites/${params.niceId}/general`
},
...(site.type !== 'local' && build === 'enterprise'
...(site.type !== "local"
? [
{
title: t('credentials'),
href: `/${params.orgId}/settings/sites/${params.niceId}/credentials`,
},
title: t("credentials"),
href: `/${params.orgId}/settings/sites/${params.niceId}/credentials`
}
]
: []),
: [])
];
return (
<>
<SettingsSectionTitle
title={t('siteSetting', { siteName: site?.name })}
description={t('siteSettingDescription')}
title={t("siteSetting", { siteName: site?.name })}
description={t("siteSettingDescription")}
/>
<SiteProvider site={site}>

View File

@@ -14,7 +14,7 @@ const alertVariants = cva(
"border-destructive/50 border bg-destructive/10 text-destructive dark:border-destructive [&>svg]:text-destructive",
success:
"border-green-500/50 border bg-green-500/10 text-green-500 dark:border-success [&>svg]:text-green-500",
info: "border-blue-500/50 border bg-blue-500/10 text-blue-800 dark:border-blue-400 [&>svg]:text-blue-500",
info: "border-blue-500/50 border bg-blue-500/10 text-blue-800 dark:text-blue-400 dark:border-blue-400 [&>svg]:text-blue-500",
warning:
"border-yellow-500 border text-yellow-800 bg-yellow-500/20 dark:bg-yellow-800/20 dark:text-yellow-100 dark:border-yellow-700 [&>svg]:text-yellow-500"
}