mirror of
https://github.com/netbirdio/dashboard.git
synced 2026-09-23 00:30:43 -07:00
Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6845094723 | ||
|
|
b9f278360e | ||
|
|
6d3928d7c0 | ||
|
|
35fe6b6cbb | ||
|
|
dcfa2398e3 | ||
|
|
1cc2353957 | ||
|
|
7189a9913d | ||
|
|
6a37af081b | ||
|
|
4d21ce4680 | ||
|
|
9d8e4dc50d | ||
|
|
26edbb8add | ||
|
|
6791fb44a4 | ||
|
|
00a1fd8113 | ||
|
|
08bb65dfe8 | ||
|
|
f24775fe25 |
No files matched your search
+1
-6
@@ -35,9 +35,6 @@ yarn-error.log*
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
|
||||
# local UI sandbox (throwaway preview harness — never commit)
|
||||
/src/app/sandbox/
|
||||
|
||||
# config
|
||||
.local*config*.json
|
||||
.test-config.json
|
||||
@@ -56,6 +53,4 @@ playwright-report*.zip
|
||||
/public/ironrdp-pkg/
|
||||
/public/netbird.wasm
|
||||
.idea
|
||||
src/.local-config*
|
||||
# local mock data (throwaway preview — never commit)
|
||||
/src/utils/mockData.ts
|
||||
src/.local-config*
|
||||
@@ -926,16 +926,6 @@ services:
|
||||
# GeoLite2 download removes a startup stall of up to 2 minutes
|
||||
# when pkgs.netbird.io is slow.
|
||||
- NB_PROXY_DISABLE_GEOLOCATION=true
|
||||
# Declare the private capability so this cluster can host the agent
|
||||
# network endpoint. That endpoint is a private service — reachable only
|
||||
# from connected peers — and management refuses to bootstrap it onto a
|
||||
# cluster without a private-capable proxy; the connect-provider wizard
|
||||
# reads the same flag (supports_private) to pick its cluster. Without
|
||||
# it no cluster qualifies and the wizard stops at the provider tab,
|
||||
# which strands every spec that walks through it. The no-ports proxy
|
||||
# below stays centralised, so the pick has to skip past a cluster that
|
||||
# does not qualify.
|
||||
- NB_PROXY_PRIVATE=true
|
||||
volumes:
|
||||
- ./proxy-certs:/certs:ro
|
||||
command: [
|
||||
|
||||
@@ -1,206 +0,0 @@
|
||||
/**
|
||||
* Agent Network bootstrap-cluster spec.
|
||||
*
|
||||
* The account's agent network endpoint is assigned once, from the proxy
|
||||
* cluster the connect-provider wizard pins it to, and it is immutable after
|
||||
* that. Not every live cluster can host it: the endpoint is a private service,
|
||||
* reachable only from connected peers and authorised by their tunnel identity,
|
||||
* which only a cluster with private capabilities can serve. Management
|
||||
* reports that per cluster as supports_private and refuses a
|
||||
* bootstrap onto a cluster without it.
|
||||
*
|
||||
* This spec pins the wizard's half of that contract: it picks a
|
||||
* private-capable cluster even when a centralised one is listed first, and it
|
||||
* blocks setup — with a message naming what is missing — when no listed
|
||||
* cluster qualifies. Both the settings and domains routes are mocked, so the
|
||||
* assertions do not depend on which clusters the test backend happens to have
|
||||
* connected, and no provider is created against it.
|
||||
*/
|
||||
import { type Browser, expect, type Page, test } from "@playwright/test";
|
||||
import { loginToApp } from "../helpers/auth";
|
||||
|
||||
const AGENT_NETWORK_CONFIG_KEY = "netbird-test-agent-network";
|
||||
|
||||
// Listed first, and unusable: a centralised proxy cluster. Picking it is the
|
||||
// bug this spec guards against.
|
||||
const CENTRAL_CLUSTER = "central.proxy.netbird.io";
|
||||
// Listed second, and the only valid pick.
|
||||
const PRIVATE_CLUSTER = "private.proxy.netbird.io";
|
||||
|
||||
const UNBOOTSTRAPPED_DEFAULTS = {
|
||||
endpoint: "",
|
||||
proxy_address: "",
|
||||
dedicated: false,
|
||||
enable_log_collection: true,
|
||||
enable_prompt_collection: false,
|
||||
redact_pii: false,
|
||||
access_log_retention_days: 30,
|
||||
};
|
||||
|
||||
const BOOTSTRAPPED_SETTINGS = {
|
||||
...UNBOOTSTRAPPED_DEFAULTS,
|
||||
endpoint: `violet.${PRIVATE_CLUSTER}`,
|
||||
proxy_address: PRIVATE_CLUSTER,
|
||||
created_at: "2026-01-01T00:00:00Z",
|
||||
updated_at: "2026-01-01T00:00:00Z",
|
||||
};
|
||||
|
||||
/** A free (cluster-backed) domain as /reverse-proxies/domains reports it. */
|
||||
function freeDomain(name: string, supportsPrivate: boolean) {
|
||||
return {
|
||||
id: name,
|
||||
domain: name,
|
||||
validated: true,
|
||||
type: "free",
|
||||
supports_private: supportsPrivate,
|
||||
supports_custom_ports: true,
|
||||
require_subdomain: true,
|
||||
};
|
||||
}
|
||||
|
||||
async function json(route: import("@playwright/test").Route, body: unknown) {
|
||||
return route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the providers page for an account that has not been bootstrapped,
|
||||
* with the given clusters on the domains endpoint. Returns the page plus a
|
||||
* promise-friendly getter for the bootstrap POST body, which is captured and
|
||||
* answered locally so the real backend is never mutated.
|
||||
*/
|
||||
async function openWizard(
|
||||
browser: Browser,
|
||||
domains: ReturnType<typeof freeDomain>[],
|
||||
): Promise<{ page: Page; close: () => Promise<void> }> {
|
||||
const context = await browser.newContext({
|
||||
storageState: "e2e/fixtures/auth/owner.json",
|
||||
});
|
||||
try {
|
||||
await context.addInitScript(
|
||||
([key, value]) => {
|
||||
try {
|
||||
window.localStorage.setItem(key as string, value as string);
|
||||
} catch (e) {}
|
||||
},
|
||||
[AGENT_NETWORK_CONFIG_KEY, "enabled"],
|
||||
);
|
||||
const page = await context.newPage();
|
||||
|
||||
await page.route("**/api/agent-network/settings", (route) => {
|
||||
const method = route.request().method();
|
||||
if (method === "GET") return json(route, UNBOOTSTRAPPED_DEFAULTS);
|
||||
if (method === "POST") return json(route, BOOTSTRAPPED_SETTINGS);
|
||||
return route.continue();
|
||||
});
|
||||
await page.route("**/api/reverse-proxies/domains", (route) =>
|
||||
route.request().method() === "GET"
|
||||
? json(route, domains)
|
||||
: route.continue(),
|
||||
);
|
||||
// Keep the create hermetic: the wizard only reaches this once the
|
||||
// bootstrap it does first has succeeded.
|
||||
await page.route("**/api/agent-network/providers", (route) =>
|
||||
route.request().method() === "POST"
|
||||
? json(route, { id: "prov-e2e", name: "e2e-provider" })
|
||||
: route.continue(),
|
||||
);
|
||||
|
||||
await loginToApp(page, "owner");
|
||||
await page.goto("/agent-network/providers");
|
||||
await page.keyboard.press("Escape");
|
||||
return { page, close: () => context.close() };
|
||||
} catch (e) {
|
||||
await context.close();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/** Fills the provider tab with the minimum a create needs. */
|
||||
async function fillProviderTab(page: Page) {
|
||||
await page
|
||||
.getByPlaceholder("https://api.openai.com")
|
||||
.fill("https://api.openai.com");
|
||||
await page.getByPlaceholder("sk-...").first().fill("sk-e2e-bootstrap-key");
|
||||
}
|
||||
|
||||
test.describe("Agent Network bootstrap cluster @agent-network", () => {
|
||||
test("bootstraps onto a private-capable cluster, skipping a centralised one listed first", async ({
|
||||
browser,
|
||||
}) => {
|
||||
const { page, close } = await openWizard(browser, [
|
||||
freeDomain(CENTRAL_CLUSTER, false),
|
||||
freeDomain(PRIVATE_CLUSTER, true),
|
||||
]);
|
||||
try {
|
||||
await page
|
||||
.getByRole("button", { name: "Connect Provider" })
|
||||
.first()
|
||||
.click({ force: true });
|
||||
|
||||
// The unusable cluster is listed, but it is not a blocker: a usable one
|
||||
// exists, so the wizard proceeds without the warning.
|
||||
await expect(
|
||||
page.getByTestId("agent-network-no-cluster-callout"),
|
||||
).toHaveCount(0);
|
||||
|
||||
await fillProviderTab(page);
|
||||
|
||||
const bootstrap = page.waitForResponse(
|
||||
(resp) =>
|
||||
resp.url().includes("/agent-network/settings") &&
|
||||
resp.request().method() === "POST",
|
||||
{ timeout: 30_000 },
|
||||
);
|
||||
|
||||
await page
|
||||
.getByRole("button", { name: "Continue" })
|
||||
.click({ force: true });
|
||||
await page
|
||||
.getByRole("button", { name: "Connect Provider" })
|
||||
.last()
|
||||
.click({ force: true });
|
||||
|
||||
const payload = (await bootstrap).request().postDataJSON();
|
||||
expect(payload.proxy_address).toBe(PRIVATE_CLUSTER);
|
||||
} finally {
|
||||
await close();
|
||||
}
|
||||
});
|
||||
|
||||
test("blocks setup when no listed cluster has private capabilities", async ({
|
||||
browser,
|
||||
}) => {
|
||||
const { page, close } = await openWizard(browser, [
|
||||
freeDomain(CENTRAL_CLUSTER, false),
|
||||
]);
|
||||
try {
|
||||
await page
|
||||
.getByRole("button", { name: "Connect Provider" })
|
||||
.first()
|
||||
.click({ force: true });
|
||||
|
||||
const callout = page.getByTestId("agent-network-no-cluster-callout");
|
||||
await expect(callout).toBeVisible({ timeout: 10_000 });
|
||||
await expect(callout).toContainText("private capabilities");
|
||||
// The fix lives in the agent network's own Clusters section, not the
|
||||
// generic Reverse Proxy page, so that is where the callout sends users.
|
||||
await expect(callout.getByRole("link")).toHaveAttribute(
|
||||
"href",
|
||||
"/agent-network/configuration?tab=clusters",
|
||||
);
|
||||
|
||||
// With nothing to pin to there is no bootstrap to make, so the wizard
|
||||
// cannot advance — rather than sending a request management refuses.
|
||||
await fillProviderTab(page);
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Continue" }),
|
||||
).toBeDisabled();
|
||||
} finally {
|
||||
await close();
|
||||
}
|
||||
});
|
||||
});
|
||||
Generated
+397
-518
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -75,7 +75,7 @@
|
||||
"js-cookie": "^3.0.7",
|
||||
"lodash": "4.18.1",
|
||||
"lucide-react": "^0.566.0",
|
||||
"next": "16.3.4",
|
||||
"next": "16.3.0",
|
||||
"punycode": "^2.3.1",
|
||||
"react": "^19.2.4",
|
||||
"react-chartjs-2": "^5.3.0",
|
||||
|
||||
@@ -60,7 +60,7 @@ export default function Integrations() {
|
||||
(!isNetBirdCloud() && (permission?.settings?.read ?? false))
|
||||
}
|
||||
>
|
||||
<div className={"w-full"}>
|
||||
<div className={"border-l border-nb-gray-930 w-full"}>
|
||||
<IdentityProviderTab />
|
||||
<SSOTab />
|
||||
<EventStreamingTab />
|
||||
|
||||
@@ -87,7 +87,7 @@ export default function AgentNetworkConfigurationPage() {
|
||||
<GroupsProvider>
|
||||
<PeersProvider>
|
||||
<AIProvidersProvider>
|
||||
<div className={"w-full"}>
|
||||
<div className={"border-l border-nb-gray-930 w-full"}>
|
||||
<Tabs.Content
|
||||
value={TAB_BUDGET_SETTINGS}
|
||||
className={"w-full"}
|
||||
|
||||
@@ -15,11 +15,6 @@ import React, { useState } from "react";
|
||||
import { useSWRConfig } from "swr";
|
||||
import GroupsProvider from "@/contexts/GroupsProvider";
|
||||
import PeersProvider from "@/contexts/PeersProvider";
|
||||
import { useTheme } from "@/contexts/ThemeProvider";
|
||||
import {
|
||||
canvasBackground,
|
||||
canvasDotColor,
|
||||
} from "@/modules/control-center/utils/canvas-theme";
|
||||
import PoliciesProvider from "@/contexts/PoliciesProvider";
|
||||
import { Network } from "@/interfaces/Network";
|
||||
import PageContainer from "@/layouts/PageContainer";
|
||||
@@ -110,8 +105,6 @@ const PRO_OPTIONS = { hideAttribution: true };
|
||||
const DEFAULT_VIEWPORT = { x: 0, y: 0, zoom: EMPTY_STATE_ZOOM };
|
||||
|
||||
function ControlCenterCanvas() {
|
||||
const { resolvedTheme } = useTheme();
|
||||
const isLight = resolvedTheme === "light";
|
||||
const canvas = useCanvasState();
|
||||
const ui = useControlCenterUI();
|
||||
const draft = useDraft();
|
||||
@@ -290,7 +283,7 @@ function ControlCenterCanvas() {
|
||||
onInit={stableOnInit}
|
||||
maxZoom={DEFAULT_MAX_ZOOM}
|
||||
minZoom={DEFAULT_MIN_ZOOM}
|
||||
colorMode={isLight ? "light" : "dark"}
|
||||
colorMode={"dark"}
|
||||
panOnDrag={canInteract}
|
||||
panOnScroll={draft.isSelectMode && !emptyState}
|
||||
zoomOnScroll={canInteract}
|
||||
@@ -304,11 +297,7 @@ function ControlCenterCanvas() {
|
||||
selectionOnDrag={draft.isSelectMode && !emptyState}
|
||||
selectionMode={SelectionMode.Partial}
|
||||
>
|
||||
<Background
|
||||
bgColor={canvasBackground(resolvedTheme)}
|
||||
gap={20}
|
||||
color={canvasDotColor(resolvedTheme)}
|
||||
/>
|
||||
<Background bgColor={"#181a1d"} gap={20} color={"#717171"} />
|
||||
<CanvasContextMenu onOpenChange={setContextMenuOpen} />
|
||||
<NodeContextMenu
|
||||
position={nodeContextMenuPos}
|
||||
|
||||
@@ -115,7 +115,7 @@ const GroupDetailsName = () => {
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
"flex h-8 w-8 items-center justify-center gap-2 text-nb-gray-300 hover:text-nb-gray-100 transition-all hover:bg-nb-gray-800/60 rounded-md cursor-pointer",
|
||||
"flex h-8 w-8 items-center justify-center gap-2 dark:text-neutral-300 text-neutral-500 hover:text-neutral-100 transition-all hover:bg-nb-gray-800/60 rounded-md cursor-pointer",
|
||||
!isAllowedToRename &&
|
||||
"opacity-40 cursor-not-allowed pointer-events-none",
|
||||
)}
|
||||
|
||||
@@ -257,7 +257,7 @@ const PeerHeader = () => {
|
||||
<ModalTrigger>
|
||||
<div
|
||||
className={
|
||||
"flex h-8 w-8 items-center justify-center gap-2 text-nb-gray-400 hover:text-nb-gray-100 transition-all hover:bg-nb-gray-800/60 rounded-md cursor-pointer"
|
||||
"flex h-8 w-8 items-center justify-center gap-2 dark:text-neutral-300 text-neutral-500 hover:text-neutral-100 transition-all hover:bg-nb-gray-800/60 rounded-md cursor-pointer"
|
||||
}
|
||||
>
|
||||
<PencilIcon size={16} />
|
||||
@@ -741,7 +741,7 @@ function EditableValue({
|
||||
<span>{value}</span>
|
||||
{canEdit && (
|
||||
<button
|
||||
className="flex w-7 h-7 items-center justify-center gap-2 text-nb-gray-400 hover:text-nb-gray-100 transition-all hover:bg-nb-gray-800/60 rounded-md cursor-pointer"
|
||||
className="flex w-7 h-7 items-center justify-center gap-2 text-nb-gray-400 hover:text-neutral-100 transition-all hover:bg-nb-gray-800/60 rounded-md cursor-pointer"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onEdit();
|
||||
|
||||
@@ -61,7 +61,10 @@ export default function NetBirdSettings() {
|
||||
<VerticalTabs.List>
|
||||
{permission.settings.read && (
|
||||
<>
|
||||
<VerticalTabs.Trigger value="authentication" data-testid="settings-tab-authentication">
|
||||
<VerticalTabs.Trigger
|
||||
value="authentication"
|
||||
data-testid="settings-tab-authentication"
|
||||
>
|
||||
<ShieldIcon size={14} />
|
||||
Authentication
|
||||
</VerticalTabs.Trigger>
|
||||
@@ -78,19 +81,31 @@ export default function NetBirdSettings() {
|
||||
Identity Providers
|
||||
</VerticalTabs.Trigger>
|
||||
)}
|
||||
<VerticalTabs.Trigger value="groups" data-testid="settings-tab-groups">
|
||||
<VerticalTabs.Trigger
|
||||
value="groups"
|
||||
data-testid="settings-tab-groups"
|
||||
>
|
||||
<FolderGit2Icon size={14} />
|
||||
Groups
|
||||
</VerticalTabs.Trigger>
|
||||
<VerticalTabs.Trigger value="permissions" data-testid="settings-tab-permissions">
|
||||
<VerticalTabs.Trigger
|
||||
value="permissions"
|
||||
data-testid="settings-tab-permissions"
|
||||
>
|
||||
<LockIcon size={14} />
|
||||
Permissions
|
||||
</VerticalTabs.Trigger>
|
||||
<VerticalTabs.Trigger value="networks" data-testid="settings-tab-networks">
|
||||
<VerticalTabs.Trigger
|
||||
value="networks"
|
||||
data-testid="settings-tab-networks"
|
||||
>
|
||||
<NetworkIcon size={14} />
|
||||
Networks
|
||||
</VerticalTabs.Trigger>
|
||||
<VerticalTabs.Trigger value="clients" data-testid="settings-tab-clients">
|
||||
<VerticalTabs.Trigger
|
||||
value="clients"
|
||||
data-testid="settings-tab-clients"
|
||||
>
|
||||
<MonitorSmartphoneIcon size={14} />
|
||||
Clients
|
||||
</VerticalTabs.Trigger>
|
||||
@@ -107,7 +122,7 @@ export default function NetBirdSettings() {
|
||||
page={"Settings"}
|
||||
hasAccess={permission?.billing?.read || permission?.settings?.read}
|
||||
>
|
||||
<div className={"w-full"}>
|
||||
<div className={"border-l border-nb-gray-930 w-full"}>
|
||||
{account && <AuthenticationTab account={account} />}
|
||||
{permission.setup_keys.read && <SetupKeysTab />}
|
||||
{account?.settings?.embedded_idp_enabled &&
|
||||
|
||||
@@ -183,7 +183,7 @@ function UserOverview({ user, initialGroups }: Readonly<Props>) {
|
||||
<div className={"flex items-center gap-3"}>
|
||||
<div
|
||||
className={
|
||||
"w-10 h-10 rounded-full relative flex items-center justify-center text-nb-gray-100 uppercase text-md font-medium bg-nb-gray-900"
|
||||
"w-10 h-10 rounded-full relative flex items-center justify-center text-white uppercase text-md font-medium bg-nb-gray-900"
|
||||
}
|
||||
style={
|
||||
isServiceUser
|
||||
|
||||
+4
-67
@@ -5,69 +5,6 @@
|
||||
:root {
|
||||
--toasts-before: 0;
|
||||
--lift: 1;
|
||||
|
||||
/* nb-gray INVERTED ramp (light mode) — space-separated RGB channels.
|
||||
High stops are surfaces (near-white), low stops are text (near-black).
|
||||
DEFAULT (the app background) sits slightly below white so white
|
||||
inputs, buttons and cards stand in front of it.
|
||||
The ramp is pure neutral (R = G = B) and matches the desktop client's
|
||||
light ramp (netbirdio/netbird#7344) so both UIs share one palette. */
|
||||
--nb-gray-DEFAULT: 243 243 243;
|
||||
--nb-gray-50: 26 26 26;
|
||||
--nb-gray-100: 33 33 33;
|
||||
--nb-gray-200: 50 50 50;
|
||||
--nb-gray-250: 58 58 58;
|
||||
--nb-gray-300: 77 77 77;
|
||||
--nb-gray-350: 92 92 92;
|
||||
--nb-gray-400: 108 108 108;
|
||||
--nb-gray-500: 135 135 135;
|
||||
--nb-gray-600: 154 154 154;
|
||||
--nb-gray-700: 209 209 209;
|
||||
--nb-gray-800: 226 226 226;
|
||||
--nb-gray-850: 234 234 234;
|
||||
--nb-gray-900: 238 238 238;
|
||||
--nb-gray-910: 240 240 240;
|
||||
--nb-gray-920: 243 243 243;
|
||||
--nb-gray-925: 245 245 245;
|
||||
--nb-gray-930: 246 246 246;
|
||||
--nb-gray-935: 248 248 248;
|
||||
--nb-gray-940: 250 250 250;
|
||||
--nb-gray-950: 252 252 252;
|
||||
--nb-gray-960: 255 255 255;
|
||||
|
||||
/* Loading-skeleton colours, consumed by ThemeProvider's SkeletonTheme. */
|
||||
--skeleton-base: 238 238 238;
|
||||
--skeleton-highlight: 247 247 247;
|
||||
}
|
||||
|
||||
.dark {
|
||||
/* nb-gray ORIGINAL ramp (dark mode) */
|
||||
--nb-gray-DEFAULT: 24 26 29;
|
||||
--nb-gray-50: 244 246 247;
|
||||
--nb-gray-100: 228 231 233;
|
||||
--nb-gray-200: 203 210 214;
|
||||
--nb-gray-250: 183 192 198;
|
||||
--nb-gray-300: 163 173 181;
|
||||
--nb-gray-350: 143 156 168;
|
||||
--nb-gray-400: 124 137 148;
|
||||
--nb-gray-500: 97 110 121;
|
||||
--nb-gray-600: 83 93 103;
|
||||
--nb-gray-700: 71 78 87;
|
||||
--nb-gray-800: 63 68 75;
|
||||
--nb-gray-850: 54 59 64;
|
||||
--nb-gray-900: 46 50 56;
|
||||
--nb-gray-910: 43 47 51;
|
||||
--nb-gray-920: 37 40 45;
|
||||
--nb-gray-925: 30 33 35;
|
||||
--nb-gray-930: 37 40 44;
|
||||
--nb-gray-935: 31 33 36;
|
||||
--nb-gray-940: 28 30 33;
|
||||
--nb-gray-950: 24 26 29;
|
||||
--nb-gray-960: 22 24 27;
|
||||
|
||||
/* Dark skeletons keep their existing nb-gray-920 / nb-gray-850 values. */
|
||||
--skeleton-base: 37 40 45;
|
||||
--skeleton-highlight: 54 59 64;
|
||||
}
|
||||
|
||||
html{
|
||||
@@ -75,13 +12,13 @@ html{
|
||||
}
|
||||
|
||||
h1 {
|
||||
@apply text-2xl font-medium text-nb-gray-100 my-1;
|
||||
@apply text-2xl font-medium text-gray-700 dark:text-nb-gray-100 my-1;
|
||||
}
|
||||
h2 {
|
||||
@apply text-xl font-medium text-nb-gray-100 my-1;
|
||||
@apply text-xl font-medium text-gray-700 dark:text-nb-gray-100 my-1;
|
||||
}
|
||||
p {
|
||||
@apply font-light tracking-wide text-nb-gray-200 text-sm;
|
||||
@apply font-light tracking-wide text-gray-700 dark:text-zinc-50 text-sm;
|
||||
}
|
||||
|
||||
.p-default {
|
||||
@@ -158,7 +95,7 @@ p {
|
||||
}
|
||||
|
||||
.timescape input:focus {
|
||||
@apply bg-nb-gray-700 text-nb-gray-50 rounded py-1 px-0.5 border-0 outline-0;
|
||||
@apply bg-nb-gray-700 text-white rounded py-1 px-0.5 border-0 outline-0;
|
||||
}
|
||||
|
||||
.timescape .separator {
|
||||
|
||||
@@ -111,7 +111,7 @@ function InviteAcceptContent() {
|
||||
<Clock className="w-8 h-8 text-yellow-500" />
|
||||
</div>
|
||||
</div>
|
||||
<h1 className="text-2xl font-semibold dark:text-white text-nb-gray-900 mb-2">
|
||||
<h1 className="text-2xl font-semibold text-white mb-2">
|
||||
Too Many Requests
|
||||
</h1>
|
||||
<Paragraph className="text-nb-gray-400 text-base">
|
||||
@@ -138,7 +138,7 @@ function InviteAcceptContent() {
|
||||
<AlertCircle className="w-8 h-8 text-red-500" />
|
||||
</div>
|
||||
</div>
|
||||
<h1 className="text-2xl font-semibold dark:text-white text-nb-gray-900 mb-2">
|
||||
<h1 className="text-2xl font-semibold text-white mb-2">
|
||||
Invalid Invite
|
||||
</h1>
|
||||
<Paragraph className="text-nb-gray-400 text-base">
|
||||
@@ -166,7 +166,7 @@ function InviteAcceptContent() {
|
||||
<CheckCircle2 className="w-8 h-8 text-green-500" />
|
||||
</div>
|
||||
</div>
|
||||
<h1 className="text-2xl font-semibold dark:text-white text-nb-gray-900 mb-2">
|
||||
<h1 className="text-2xl font-semibold text-white mb-2">
|
||||
Account Created!
|
||||
</h1>
|
||||
<Paragraph className="text-nb-gray-400">
|
||||
@@ -194,7 +194,7 @@ function InviteAcceptContent() {
|
||||
<AlertCircle className="w-8 h-8 text-yellow-500" />
|
||||
</div>
|
||||
</div>
|
||||
<h1 className="text-2xl font-semibold dark:text-white text-nb-gray-900 mb-2">
|
||||
<h1 className="text-2xl font-semibold text-white mb-2">
|
||||
Invite Expired
|
||||
</h1>
|
||||
<Paragraph className="text-nb-gray-400">
|
||||
@@ -221,7 +221,7 @@ function InviteAcceptContent() {
|
||||
</div>
|
||||
|
||||
<div className="text-center mb-8">
|
||||
<h1 className="text-2xl font-semibold dark:text-white text-nb-gray-900 mb-2">
|
||||
<h1 className="text-2xl font-semibold text-white mb-2">
|
||||
Welcome to NetBird
|
||||
</h1>
|
||||
<p className="dark:text-nb-gray-400 text-nb-gray-500 text-base">
|
||||
@@ -235,7 +235,7 @@ function InviteAcceptContent() {
|
||||
<User2 className="w-5 h-5 text-nb-gray-400" />
|
||||
</div>
|
||||
<div>
|
||||
<div className="dark:text-white text-nb-gray-900 font-medium">{inviteInfo.name}</div>
|
||||
<div className="text-white font-medium">{inviteInfo.name}</div>
|
||||
<div className="text-nb-gray-400 text-sm flex items-center gap-1">
|
||||
<Mail className="w-3 h-3" />
|
||||
{inviteInfo.email}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
<svg width="133" height="23" viewBox="0 0 133 23" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_0_3)">
|
||||
<path d="M46.9438 7.5013C48.1229 8.64688 48.7082 10.3025 48.7082 12.4683V21.6663H46.1411V12.8362C46.1411 11.2809 45.7481 10.0851 44.9704 9.26566C44.1928 8.43783 43.1308 8.0281 41.7846 8.0281C40.4383 8.0281 39.3345 8.45455 38.5234 9.30747C37.7123 10.1604 37.3109 11.4063 37.3109 13.0369V21.6663H34.7188V6.06305H37.3109V8.28732C37.821 7.49294 38.5234 6.87416 39.4014 6.43934C40.2878 6.00452 41.2578 5.78711 42.3197 5.78711C44.2179 5.78711 45.7565 6.36408 46.9355 7.50966L46.9438 7.5013Z" fill="#1f2124"/>
|
||||
<path d="M67.1048 14.8344H54.6288C54.7208 16.373 55.2476 17.5771 56.2092 18.4384C57.1708 19.2997 58.3331 19.7345 59.6961 19.7345C60.8166 19.7345 61.7531 19.4753 62.4973 18.9485C63.2499 18.4301 63.7767 17.7277 64.0777 16.858H66.8706C66.4525 18.3548 65.6163 19.5756 64.3621 20.5205C63.1078 21.4571 61.5525 21.9337 59.6878 21.9337C58.2077 21.9337 56.8865 21.5992 55.7159 20.9386C54.5452 20.278 53.6337 19.3331 52.9648 18.1039C52.2958 16.8831 51.9697 15.4616 51.9697 13.8477C51.9697 12.2339 52.2958 10.8207 52.9397 9.60825C53.5836 8.39578 54.495 7.45924 55.6573 6.80702C56.828 6.15479 58.1659 5.82031 59.6878 5.82031C61.2096 5.82031 62.4806 6.14643 63.6178 6.79029C64.7551 7.43416 65.6331 8.32052 66.2518 9.44938C66.8706 10.5782 67.18 11.8576 67.18 13.2791C67.18 13.7725 67.1549 14.2909 67.0964 14.8428L67.1048 14.8344ZM63.8603 10.1769C63.4255 9.4661 62.8318 8.92258 62.0793 8.55465C61.3267 8.18673 60.4989 8.00277 59.5874 8.00277C58.2746 8.00277 57.1625 8.42086 56.2427 9.25705C55.3228 10.0932 54.796 11.2472 54.6623 12.7356H64.5126C64.5126 11.7489 64.2952 10.896 63.8603 10.1852V10.1769Z" fill="#1f2124"/>
|
||||
<path d="M73.7695 8.20355V17.4016C73.7695 18.1626 73.9284 18.6977 74.2545 19.0071C74.5806 19.3165 75.1409 19.4754 75.9352 19.4754H77.8418V21.6662H75.5088C74.0622 21.6662 72.9835 21.3317 72.2644 20.6711C71.5452 20.0105 71.1857 18.9151 71.1857 17.3933V8.19519H69.1621V6.0629H71.1857V2.13281H73.7779V6.0629H77.8501V8.19519H73.7779L73.7695 8.20355Z" fill="#1f2124"/>
|
||||
<path d="M85.9022 6.68902C86.9307 6.10369 88.093 5.80266 89.4058 5.80266C90.8106 5.80266 92.0732 6.13714 93.1937 6.79773C94.3142 7.46668 95.2006 8.39485 95.8444 9.59896C96.4883 10.8031 96.8144 12.2079 96.8144 13.7966C96.8144 15.3854 96.4883 16.7818 95.8444 18.011C95.2006 19.2486 94.3142 20.2018 93.1854 20.8875C92.0565 21.5732 90.7939 21.916 89.4141 21.916C88.0344 21.916 86.8805 21.6234 85.8687 21.0297C84.8569 20.4443 84.0876 19.6918 83.5775 18.7803V21.6568H80.9854V0.601562H83.5775V8.97182C84.1127 8.04365 84.8904 7.28272 85.9105 6.69738L85.9022 6.68902ZM93.4529 10.7362C92.9763 9.86654 92.3408 9.19759 91.5297 8.74605C90.7186 8.29451 89.8322 8.06037 88.8706 8.06037C87.909 8.06037 87.0394 8.29451 86.2366 8.75441C85.4255 9.22268 84.7817 9.89163 84.2967 10.778C83.8117 11.6643 83.5692 12.6845 83.5692 13.8384C83.5692 14.9924 83.8117 16.046 84.2967 16.9323C84.7817 17.8187 85.4255 18.4877 86.2366 18.9559C87.0394 19.4242 87.9174 19.65 88.8706 19.65C89.8239 19.65 90.727 19.4158 91.5297 18.9559C92.3324 18.4877 92.9763 17.8187 93.4529 16.9323C93.9296 16.046 94.1637 15.0091 94.1637 13.8134C94.1637 12.6176 93.9296 11.6142 93.4529 10.7362Z" fill="#1f2124"/>
|
||||
<path d="M100.318 3.01864C99.9749 2.67581 99.8076 2.25771 99.8076 1.76436C99.8076 1.27101 99.9749 0.852913 100.318 0.510076C100.661 0.167238 101.079 0 101.572 0C102.065 0 102.45 0.167238 102.784 0.510076C103.119 0.852913 103.286 1.27101 103.286 1.76436C103.286 2.25771 103.119 2.67581 102.784 3.01864C102.45 3.36148 102.049 3.52872 101.572 3.52872C101.095 3.52872 100.661 3.36148 100.318 3.01864ZM102.826 6.06237V21.6657H100.234V6.06237H102.826Z" fill="#1f2124"/>
|
||||
<path d="M111.773 6.52155C112.617 6.0282 113.646 5.77734 114.867 5.77734V8.45315H114.181C111.28 8.45315 109.825 10.0252 109.825 13.1776V21.6649H107.232V6.06165H109.825V8.5953C110.276 7.70058 110.928 7.00654 111.773 6.51319V6.52155Z" fill="#1f2124"/>
|
||||
<path d="M117.861 9.60732C118.505 8.40321 119.391 7.46668 120.52 6.80609C121.649 6.1455 122.92 5.81102 124.325 5.81102C125.537 5.81102 126.666 6.09533 127.711 6.64721C128.757 7.20746 129.551 7.94331 130.103 8.85475V0.601562H132.72V21.6735H130.103V18.7385C129.593 19.6667 128.832 20.436 127.828 21.0297C126.825 21.6317 125.646 21.9244 124.3 21.9244C122.953 21.9244 121.657 21.5816 120.528 20.8959C119.4 20.2102 118.513 19.257 117.869 18.0194C117.226 16.7818 116.899 15.377 116.899 13.805C116.899 12.233 117.226 10.8114 117.869 9.60732H117.861ZM129.392 10.7613C128.915 9.89163 128.28 9.22268 127.469 8.75441C126.658 8.28614 125.771 8.06037 124.81 8.06037C123.848 8.06037 122.962 8.28614 122.159 8.74605C121.356 9.20595 120.729 9.86654 120.253 10.7362C119.776 11.6058 119.542 12.6343 119.542 13.8134C119.542 14.9924 119.776 16.046 120.253 16.9323C120.729 17.8187 121.365 18.4877 122.159 18.9559C122.953 19.4242 123.84 19.65 124.81 19.65C125.78 19.65 126.666 19.4158 127.469 18.9559C128.272 18.4877 128.915 17.8187 129.392 16.9323C129.869 16.046 130.103 15.0175 130.103 13.8384C130.103 12.6594 129.869 11.6393 129.392 10.7613Z" fill="#1f2124"/>
|
||||
<path d="M21.4651 0.568359C17.8193 0.902835 16.0047 3.00167 15.3191 4.06363L4.66602 22.5183H17.5182L30.1949 0.568359H21.4651Z" fill="#F68330"/>
|
||||
<path d="M17.5265 22.5187L0 3.9302C0 3.9302 19.8177 -1.39633 21.7493 15.2188L17.5265 22.5187Z" fill="#F68330"/>
|
||||
<path d="M14.9255 4.75055L9.54883 14.0657L17.5177 22.5196L21.7405 15.2029C21.0715 9.49174 18.287 6.37276 14.9255 4.74219" fill="#F35E32"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_0_3">
|
||||
<rect width="132.72" height="22.5186" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 5.5 KiB |
@@ -1,7 +1,7 @@
|
||||
import { useOidcAccessToken, useOidcIdToken } from "@axa-fr/react-oidc";
|
||||
import loadConfig from "@utils/config";
|
||||
import { useMemo } from "react";
|
||||
import { useJwt } from "react-jwt";
|
||||
import { decodeToken } from "react-jwt";
|
||||
|
||||
const config = loadConfig();
|
||||
export const useDomainCategory = () => {
|
||||
@@ -9,10 +9,12 @@ export const useDomainCategory = () => {
|
||||
const { idToken } = useOidcIdToken();
|
||||
const { accessToken } = useOidcAccessToken();
|
||||
const token = tokenSource.toLowerCase() == "idtoken" ? idToken : accessToken;
|
||||
const { decodedToken } = useJwt<Record<any, any>>(token);
|
||||
|
||||
const domainCategory = useMemo(() => {
|
||||
try {
|
||||
const decodedToken = token
|
||||
? decodeToken<Record<any, any>>(token)
|
||||
: undefined;
|
||||
const key = decodedToken
|
||||
? Object.keys(decodedToken)
|
||||
.filter((key) => key.includes("wt_account_domain_category"))
|
||||
@@ -22,7 +24,7 @@ export const useDomainCategory = () => {
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
}, [decodedToken]);
|
||||
}, [token]);
|
||||
|
||||
const isPrivate = useMemo(() => {
|
||||
return domainCategory === "private";
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
import Breadcrumbs from "@components/Breadcrumbs";
|
||||
import Card from "@components/Card";
|
||||
import InlineLink from "@components/InlineLink";
|
||||
import Paragraph from "@components/Paragraph";
|
||||
import { SkeletonNotificationSettings } from "@components/skeletons/SkeletonNotificationSettings";
|
||||
import { SmallBadge } from "@components/ui/SmallBadge";
|
||||
import { VerticalTabs } from "@components/VerticalTabs";
|
||||
import * as Tabs from "@radix-ui/react-tabs";
|
||||
import { ExternalLinkIcon, MessageSquareDot } from "lucide-react";
|
||||
import React from "react";
|
||||
import SettingsIcon from "@/assets/icons/SettingsIcon";
|
||||
import { usePermissions } from "@/contexts/PermissionsProvider";
|
||||
import { useIsLicensed } from "@/hooks/useIsLicensed";
|
||||
import { VerticalTabs } from "@components/VerticalTabs";
|
||||
import InlineLink from "@components/InlineLink";
|
||||
import Card from "@components/Card";
|
||||
import { NotificationEmailChannel } from "@/cloud/notifications/channels/NotificationEmailChannel";
|
||||
import { NotificationSlackChannel } from "@/cloud/notifications/channels/NotificationSlackChannel";
|
||||
import { NotificationWebhookChannel } from "@/cloud/notifications/channels/NotificationWebhookChannel";
|
||||
import useUrlTab from "@/hooks/useUrlTab";
|
||||
import Paragraph from "@components/Paragraph";
|
||||
import { NotificationChannelListItem } from "@/cloud/notifications/NotificationChannelListItem";
|
||||
import NotificationProvider, {
|
||||
useNotifications,
|
||||
} from "@/cloud/notifications/NotificationProvider";
|
||||
import { NotificationChannelListItem } from "@/cloud/notifications/NotificationChannelListItem";
|
||||
import { usePermissions } from "@/contexts/PermissionsProvider";
|
||||
import { useIsLicensed } from "@/hooks/useIsLicensed";
|
||||
import useUrlTab from "@/hooks/useUrlTab";
|
||||
import {
|
||||
NOTIFICATION_CHANNELS_DOCS_LINK,
|
||||
NotificationChannelType,
|
||||
} from "@/interfaces/NotificationChannel";
|
||||
import { SkeletonNotificationSettings } from "@components/skeletons/SkeletonNotificationSettings";
|
||||
import { NotificationSlackChannel } from "@/cloud/notifications/channels/NotificationSlackChannel";
|
||||
import { SmallBadge } from "@components/ui/SmallBadge";
|
||||
|
||||
const NotificationsOverview = ({
|
||||
onSelectChannel,
|
||||
@@ -52,23 +52,18 @@ const NotificationsOverview = ({
|
||||
active
|
||||
/>
|
||||
</Breadcrumbs>
|
||||
<div className={"flex items-start justify-between"}>
|
||||
<div className={"flex items-start justify-between -mt-1"}>
|
||||
<div>
|
||||
<h1>Notifications</h1>
|
||||
<Paragraph>
|
||||
Choose how to be notified when important events occur in your
|
||||
account.
|
||||
</Paragraph>
|
||||
<Paragraph>
|
||||
Learn more about{" "}
|
||||
<Paragraph className={"block"}>
|
||||
Get notified when important events happen.{" "}
|
||||
<InlineLink
|
||||
href={NOTIFICATION_CHANNELS_DOCS_LINK}
|
||||
target={"_blank"}
|
||||
>
|
||||
Notification Channels
|
||||
Learn more
|
||||
<ExternalLinkIcon size={12} />
|
||||
</InlineLink>
|
||||
in our documentation.
|
||||
</Paragraph>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
import Button from "@components/Button";
|
||||
import { Input } from "@components/Input";
|
||||
import {
|
||||
Modal,
|
||||
ModalClose,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
} from "@components/modal/Modal";
|
||||
import ModalHeader from "@components/modal/ModalHeader";
|
||||
import { notify } from "@components/Notification";
|
||||
import { validator } from "@utils/helpers";
|
||||
import { PlusCircle } from "lucide-react";
|
||||
import * as React from "react";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useSignInDomains } from "@/cloud/sign-in-domains/useSignInDomains";
|
||||
import { DomainValidationStatus, SignInDomain } from "@/interfaces/Account";
|
||||
import { DomainVerificationModal } from "@/modules/integrations/sso/DomainVerificationModal";
|
||||
|
||||
type Props = {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
};
|
||||
|
||||
export const AddSignInDomainModal = ({ open, onOpenChange }: Props) => {
|
||||
const { addDomain, verifyDomain, mutate } = useSignInDomains();
|
||||
const [name, setName] = useState("");
|
||||
const [verifyModal, setVerifyModal] = useState(false);
|
||||
const [addedDomain, setAddedDomain] = useState<SignInDomain>();
|
||||
|
||||
const validationError = useMemo(() => {
|
||||
const domain = name.trim();
|
||||
if (domain === "") return "";
|
||||
const valid = validator.isValidDomain(domain, {
|
||||
allowWildcard: false,
|
||||
allowOnlyTld: false,
|
||||
preventLeadingAndTrailingDots: true,
|
||||
});
|
||||
if (!valid) return "Please enter a valid domain, e.g. company.com";
|
||||
return "";
|
||||
}, [name]);
|
||||
|
||||
const setOpen = (next: boolean) => {
|
||||
if (!next) setName("");
|
||||
onOpenChange(next);
|
||||
};
|
||||
|
||||
const submit = () => {
|
||||
const domain = name.trim();
|
||||
if (!domain || validationError) return;
|
||||
|
||||
setOpen(false);
|
||||
|
||||
notify({
|
||||
title: "Sign-in Domains",
|
||||
description: `${domain} has been added`,
|
||||
promise: addDomain(domain).then((added) => {
|
||||
if (
|
||||
added &&
|
||||
added.validation_status !== DomainValidationStatus.VERIFIED
|
||||
) {
|
||||
setAddedDomain(added);
|
||||
setVerifyModal(true);
|
||||
}
|
||||
mutate().catch(() => {});
|
||||
return added;
|
||||
}),
|
||||
loadingMessage: "Adding domain...",
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{addedDomain && (
|
||||
<DomainVerificationModal
|
||||
open={verifyModal}
|
||||
onOpenChange={setVerifyModal}
|
||||
domain={addedDomain.name}
|
||||
token={addedDomain.validation_token}
|
||||
onVerify={() =>
|
||||
verifyDomain(addedDomain.id).then((res) => {
|
||||
mutate().catch(() => {});
|
||||
return res;
|
||||
})
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
<Modal open={open} onOpenChange={setOpen}>
|
||||
<ModalContent maxWidthClass={"max-w-md"}>
|
||||
<ModalHeader
|
||||
className={"pb-4 px-8"}
|
||||
title={"Add Sign-in Domain"}
|
||||
description={"Users on this domain are matched to your account."}
|
||||
/>
|
||||
|
||||
<form
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
submit();
|
||||
}}
|
||||
>
|
||||
<div className={"p-default flex flex-col gap-4"}>
|
||||
<div>
|
||||
<Input
|
||||
autoFocus
|
||||
data-testid={"add-domain-input"}
|
||||
placeholder={"e.g. company.com"}
|
||||
value={name}
|
||||
error={validationError}
|
||||
onChange={(event) => setName(event.target.value)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ModalFooter className={"items-center"} separator={false}>
|
||||
<div className={"flex gap-3 w-full justify-end"}>
|
||||
<ModalClose asChild={true}>
|
||||
<Button variant={"secondary"} className={"w-full"}>
|
||||
Cancel
|
||||
</Button>
|
||||
</ModalClose>
|
||||
|
||||
<Button
|
||||
variant={"primary"}
|
||||
className={"w-full"}
|
||||
type={"submit"}
|
||||
disabled={!name.trim() || !!validationError}
|
||||
data-testid={"add-domain-submit"}
|
||||
>
|
||||
<PlusCircle size={16} />
|
||||
Add
|
||||
</Button>
|
||||
</div>
|
||||
</ModalFooter>
|
||||
</form>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,72 @@
|
||||
import Button from "@components/Button";
|
||||
import HelpText from "@components/HelpText";
|
||||
import InlineLink from "@components/InlineLink";
|
||||
import { Label } from "@components/Label";
|
||||
import { cn } from "@utils/helpers";
|
||||
import { isNetBirdCloud } from "@utils/netbird";
|
||||
import { ExternalLinkIcon, PlusCircle } from "lucide-react";
|
||||
import * as React from "react";
|
||||
import { useState } from "react";
|
||||
import { useDomainCategory } from "@/cloud/cloud-hooks/useDomainCategory";
|
||||
import { AddSignInDomainModal } from "@/cloud/sign-in-domains/AddSignInDomainModal";
|
||||
import SignInDomainsTable from "@/cloud/sign-in-domains/table/SignInDomainsTable";
|
||||
import { useSignInDomains } from "@/cloud/sign-in-domains/useSignInDomains";
|
||||
import { usePermissions } from "@/contexts/PermissionsProvider";
|
||||
|
||||
const POLL_INTERVAL_MS = 15_000;
|
||||
|
||||
const SIGN_IN_DOMAINS_DOCS_LINK =
|
||||
"https://docs.netbird.io/manage/team/sign-in-domains";
|
||||
|
||||
export const useCanViewSignInDomains = () => {
|
||||
const { permission } = usePermissions();
|
||||
const { isPrivate } = useDomainCategory();
|
||||
return Boolean(permission?.settings?.read) && isNetBirdCloud() && isPrivate;
|
||||
};
|
||||
|
||||
export const SignInDomainsSettings = () => {
|
||||
const { permission } = usePermissions();
|
||||
const { domains, isLoading, isUnavailable } =
|
||||
useSignInDomains(POLL_INTERVAL_MS);
|
||||
const [addModal, setAddModal] = useState(false);
|
||||
|
||||
const showSkeleton = isLoading && !isUnavailable;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
isLoading && "animate-pulse pointer-events-none opacity-90",
|
||||
isUnavailable && "pointer-events-none opacity-70",
|
||||
)}
|
||||
data-testid={"sign-in-domains"}
|
||||
>
|
||||
<div className={"flex items-end justify-between gap-4 mb-4"}>
|
||||
<div className={"min-w-0"}>
|
||||
<Label>Sign-in Domains</Label>
|
||||
<HelpText className={"!mb-0"}>
|
||||
Users from these domains can join your account.{" "}
|
||||
<InlineLink href={SIGN_IN_DOMAINS_DOCS_LINK} target={"_blank"}>
|
||||
Learn more
|
||||
<ExternalLinkIcon size={12} />
|
||||
</InlineLink>
|
||||
</HelpText>
|
||||
</div>
|
||||
<Button
|
||||
variant={"primary"}
|
||||
size={"xs"}
|
||||
className={"shrink-0"}
|
||||
disabled={!permission?.settings?.update || isUnavailable}
|
||||
onClick={() => setAddModal(true)}
|
||||
data-testid={"add-domain"}
|
||||
>
|
||||
<PlusCircle size={16} />
|
||||
Add
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<SignInDomainsTable domains={domains} isLoading={showSkeleton} />
|
||||
|
||||
<AddSignInDomainModal open={addModal} onOpenChange={setAddModal} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,121 @@
|
||||
import Button from "@components/Button";
|
||||
import FullTooltip from "@components/FullTooltip";
|
||||
import { notify } from "@components/Notification";
|
||||
import { cn } from "@utils/helpers";
|
||||
import { TrashIcon } from "lucide-react";
|
||||
import * as React from "react";
|
||||
import { useState } from "react";
|
||||
import { useSignInDomains } from "@/cloud/sign-in-domains/useSignInDomains";
|
||||
import { useDialog } from "@/contexts/DialogProvider";
|
||||
import { usePermissions } from "@/contexts/PermissionsProvider";
|
||||
import { DomainValidationStatus, SignInDomain } from "@/interfaces/Account";
|
||||
import { DomainVerificationModal } from "@/modules/integrations/sso/DomainVerificationModal";
|
||||
|
||||
type Props = {
|
||||
domain: SignInDomain;
|
||||
};
|
||||
|
||||
export default function DomainActionCell({ domain }: Readonly<Props>) {
|
||||
const { permission } = usePermissions();
|
||||
const { verifyDomain, deleteDomain, mutate } = useSignInDomains();
|
||||
const { confirm } = useDialog();
|
||||
const [modal, setModal] = useState(false);
|
||||
|
||||
const isVerified =
|
||||
domain.validation_status === DomainValidationStatus.VERIFIED;
|
||||
const connections = domain.connections ?? [];
|
||||
|
||||
const removeBlockedReason: React.ReactNode = domain.is_primary ? (
|
||||
<>
|
||||
This is the primary domain of your account
|
||||
<br />
|
||||
and cannot be removed.
|
||||
</>
|
||||
) : connections.length > 0 ? (
|
||||
<>
|
||||
This domain is used by an SSO integration.
|
||||
<br />
|
||||
Remove it there before deleting it.
|
||||
</>
|
||||
) : undefined;
|
||||
|
||||
const deleteDomainHandler = async () => {
|
||||
const choice = await confirm({
|
||||
title: `Remove ${domain.name}?`,
|
||||
description:
|
||||
"Users with an email address on this domain will no longer be matched to your account.",
|
||||
confirmText: "Remove",
|
||||
cancelText: "Cancel",
|
||||
type: "danger",
|
||||
maxWidthClass: "max-w-md",
|
||||
});
|
||||
if (!choice) return;
|
||||
notify({
|
||||
title: "Sign-in Domains",
|
||||
description: `${domain.name} has been removed`,
|
||||
promise: deleteDomain(domain.id).then((res) => {
|
||||
mutate().catch(() => {});
|
||||
return res;
|
||||
}),
|
||||
loadingMessage: "Removing domain...",
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className={
|
||||
"relative top-[2px] flex gap-2 items-center justify-end ml-auto min-h-[34px]"
|
||||
}
|
||||
>
|
||||
<DomainVerificationModal
|
||||
open={modal}
|
||||
onOpenChange={setModal}
|
||||
domain={domain.name}
|
||||
token={domain.validation_token}
|
||||
onVerify={() =>
|
||||
verifyDomain(domain.id).then((res) => {
|
||||
mutate().catch(() => {});
|
||||
return res;
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
||||
{!isVerified && (
|
||||
<Button
|
||||
variant={"secondary"}
|
||||
size={"xs"}
|
||||
className={"!px-3"}
|
||||
disabled={!permission.settings.update}
|
||||
onClick={() => setModal(true)}
|
||||
data-testid={"verify-domain"}
|
||||
>
|
||||
Verify
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<FullTooltip
|
||||
content={
|
||||
<div className={"text-xs max-w-xs"}>
|
||||
{removeBlockedReason ?? "Remove domain"}
|
||||
</div>
|
||||
}
|
||||
interactive={false}
|
||||
>
|
||||
<Button
|
||||
variant={"danger-outline"}
|
||||
size={"xs"}
|
||||
className={cn(
|
||||
"!p-0 !h-[34px] !w-[34px]",
|
||||
removeBlockedReason && "pointer-events-none",
|
||||
)}
|
||||
disabled={!!removeBlockedReason || !permission.settings.update}
|
||||
onClick={deleteDomainHandler}
|
||||
aria-label={"Remove domain"}
|
||||
data-testid={"remove-domain"}
|
||||
>
|
||||
<TrashIcon size={14} />
|
||||
</Button>
|
||||
</FullTooltip>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loaded 20 of 199 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user