Update frontend to fit backend
This commit is contained in:
@@ -13,13 +13,13 @@ export default function Account() {
|
||||
const invoicesLoading = useMinLoading(() => invoices.loading)
|
||||
|
||||
const hasBillingChanges = createMemo(() => {
|
||||
const current = tenant()?.tenant_nwc_url?.trim() ?? ""
|
||||
const current = tenant()?.nwc_url?.trim() ?? ""
|
||||
const next = nwcUrl().trim()
|
||||
return current !== next
|
||||
})
|
||||
|
||||
createEffect(() => {
|
||||
setNwcUrl(tenant()?.tenant_nwc_url ?? "")
|
||||
setNwcUrl(tenant()?.nwc_url ?? "")
|
||||
})
|
||||
|
||||
async function saveBilling() {
|
||||
@@ -47,7 +47,7 @@ export default function Account() {
|
||||
<Show when={tenant()}>
|
||||
{(t) => (
|
||||
<span class="rounded-full border border-gray-300 bg-gray-100 px-2.5 py-1 text-xs font-medium uppercase tracking-wide text-gray-700">
|
||||
{t().status}
|
||||
tenant
|
||||
</span>
|
||||
)}
|
||||
</Show>
|
||||
@@ -93,11 +93,11 @@ export default function Account() {
|
||||
{(invoice) => (
|
||||
<li class="rounded-lg border border-gray-200 p-3 text-sm text-gray-700">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<span class="font-medium">{invoice.amount.toLocaleString()} sats</span>
|
||||
<span class="font-medium">—</span>
|
||||
<span class="uppercase text-xs tracking-wide text-gray-500">{invoice.status}</span>
|
||||
</div>
|
||||
<p class="text-xs text-gray-500 mt-1">{new Date(invoice.created_at).toLocaleString()}</p>
|
||||
<p class="text-xs mt-2 break-all">{invoice.invoice}</p>
|
||||
<p class="text-xs text-gray-500 mt-1">{new Date(invoice.created_at * 1000).toLocaleString()}</p>
|
||||
<p class="text-xs mt-2 break-all">{invoice.bolt11}</p>
|
||||
</li>
|
||||
)}
|
||||
</For>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useParams } from "@solidjs/router"
|
||||
import { createResource, createSignal, Show } from "solid-js"
|
||||
import { adminDeactivateRelay, adminGetRelay, adminUpdateRelay, type RelayConfig } from "../../lib/api"
|
||||
import { adminDeactivateRelay, adminGetRelay, adminUpdateRelay, type Relay } from "../../lib/api"
|
||||
import BackLink from "../../components/BackLink"
|
||||
import PageContainer from "../../components/PageContainer"
|
||||
import RelayDetailCard from "../../components/RelayDetailCard"
|
||||
@@ -29,118 +29,100 @@ export default function AdminRelayDetail() {
|
||||
}
|
||||
}
|
||||
|
||||
function withDefaults(config?: RelayConfig): RelayConfig {
|
||||
return {
|
||||
policy: {
|
||||
public_join: config?.policy.public_join ?? false,
|
||||
strip_signatures: config?.policy.strip_signatures ?? false,
|
||||
},
|
||||
groups: {
|
||||
enabled: config?.groups.enabled ?? true,
|
||||
auto_join: config?.groups.auto_join ?? true,
|
||||
},
|
||||
management: {
|
||||
enabled: config?.management.enabled ?? true,
|
||||
},
|
||||
blossom: {
|
||||
enabled: config?.blossom.enabled ?? (relay()?.plan !== "free"),
|
||||
},
|
||||
livekit: {
|
||||
enabled: config?.livekit.enabled ?? (relay()?.plan !== "free"),
|
||||
},
|
||||
push: {
|
||||
enabled: config?.push.enabled ?? true,
|
||||
},
|
||||
}
|
||||
function toBool(value: number | undefined, fallback: boolean): boolean {
|
||||
if (value === 0) return false
|
||||
if (value === 1) return true
|
||||
return fallback
|
||||
}
|
||||
|
||||
async function updateFlags(nextConfig: RelayConfig, previousConfig: RelayConfig) {
|
||||
function toInt(value: boolean): number {
|
||||
return value ? 1 : 0
|
||||
}
|
||||
|
||||
async function updateRelay(next: Relay, previous: Relay) {
|
||||
const current = relay()
|
||||
if (!current) return
|
||||
|
||||
setError("")
|
||||
const optimisticRelay = {
|
||||
...current,
|
||||
config: nextConfig,
|
||||
}
|
||||
mutate(optimisticRelay)
|
||||
mutate(next)
|
||||
|
||||
try {
|
||||
await adminUpdateRelay(relayId(), {
|
||||
name: current.name,
|
||||
subdomain: current.subdomain,
|
||||
icon: current.icon,
|
||||
description: current.description,
|
||||
config: nextConfig,
|
||||
})
|
||||
await adminUpdateRelay(relayId(), next)
|
||||
await refetch()
|
||||
} catch (e) {
|
||||
mutate({ ...current, config: previousConfig })
|
||||
mutate(previous)
|
||||
setError(e instanceof Error ? e.message : "Failed to update relay settings")
|
||||
}
|
||||
}
|
||||
|
||||
function togglePublicJoin() {
|
||||
const config = withDefaults(relay()?.config)
|
||||
const nextConfig = {
|
||||
...config,
|
||||
policy: { ...config.policy, public_join: !config.policy.public_join },
|
||||
const current = relay()
|
||||
if (!current) return
|
||||
const next = {
|
||||
...current,
|
||||
policy_public_join: toInt(!toBool(current.policy_public_join, false)),
|
||||
}
|
||||
void updateFlags(nextConfig, config)
|
||||
void updateRelay(next, current)
|
||||
}
|
||||
|
||||
function toggleStripSignatures() {
|
||||
const config = withDefaults(relay()?.config)
|
||||
const nextConfig = {
|
||||
...config,
|
||||
policy: { ...config.policy, strip_signatures: !config.policy.strip_signatures },
|
||||
const current = relay()
|
||||
if (!current) return
|
||||
const next = {
|
||||
...current,
|
||||
policy_strip_signatures: toInt(!toBool(current.policy_strip_signatures, false)),
|
||||
}
|
||||
void updateFlags(nextConfig, config)
|
||||
void updateRelay(next, current)
|
||||
}
|
||||
|
||||
function toggleGroups() {
|
||||
const config = withDefaults(relay()?.config)
|
||||
const nextConfig = {
|
||||
...config,
|
||||
groups: { ...config.groups, enabled: !config.groups.enabled },
|
||||
const current = relay()
|
||||
if (!current) return
|
||||
const next = {
|
||||
...current,
|
||||
groups_enabled: toInt(!toBool(current.groups_enabled, true)),
|
||||
}
|
||||
void updateFlags(nextConfig, config)
|
||||
void updateRelay(next, current)
|
||||
}
|
||||
|
||||
function toggleManagement() {
|
||||
const config = withDefaults(relay()?.config)
|
||||
const nextConfig = {
|
||||
...config,
|
||||
management: { enabled: !config.management.enabled },
|
||||
const current = relay()
|
||||
if (!current) return
|
||||
const next = {
|
||||
...current,
|
||||
management_enabled: toInt(!toBool(current.management_enabled, true)),
|
||||
}
|
||||
void updateFlags(nextConfig, config)
|
||||
void updateRelay(next, current)
|
||||
}
|
||||
|
||||
function toggleMediaStorage() {
|
||||
const config = withDefaults(relay()?.config)
|
||||
const nextConfig = {
|
||||
...config,
|
||||
blossom: { enabled: !config.blossom.enabled },
|
||||
const current = relay()
|
||||
if (!current) return
|
||||
const next = {
|
||||
...current,
|
||||
blossom_enabled: toInt(!toBool(current.blossom_enabled, current.plan !== "free")),
|
||||
}
|
||||
void updateFlags(nextConfig, config)
|
||||
void updateRelay(next, current)
|
||||
}
|
||||
|
||||
function togglePushNotifications() {
|
||||
const config = withDefaults(relay()?.config)
|
||||
const nextConfig = {
|
||||
...config,
|
||||
push: { enabled: !config.push.enabled },
|
||||
const current = relay()
|
||||
if (!current) return
|
||||
const next = {
|
||||
...current,
|
||||
push_enabled: toInt(!toBool(current.push_enabled, true)),
|
||||
}
|
||||
void updateFlags(nextConfig, config)
|
||||
void updateRelay(next, current)
|
||||
}
|
||||
|
||||
function toggleLivekitSupport() {
|
||||
const config = withDefaults(relay()?.config)
|
||||
const nextConfig = {
|
||||
...config,
|
||||
livekit: { enabled: !config.livekit.enabled },
|
||||
const current = relay()
|
||||
if (!current) return
|
||||
const next = {
|
||||
...current,
|
||||
livekit_enabled: toInt(!toBool(current.livekit_enabled, current.plan !== "free")),
|
||||
}
|
||||
void updateFlags(nextConfig, config)
|
||||
void updateRelay(next, current)
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useNavigate, useParams } from "@solidjs/router"
|
||||
import { Show, createEffect, createResource, createSignal } from "solid-js"
|
||||
import { adminGetRelay, adminUpdateRelay, type RelayConfig } from "../../lib/api"
|
||||
import { adminGetRelay, adminUpdateRelay } from "../../lib/api"
|
||||
import RelayForm from "../../components/RelayForm"
|
||||
import { slugify } from "../../lib/slugify"
|
||||
import BackLink from "../../components/BackLink"
|
||||
@@ -8,15 +8,6 @@ import PageContainer from "../../components/PageContainer"
|
||||
import ResourceState from "../../components/ResourceState"
|
||||
import useMinLoading from "../../components/useMinLoading"
|
||||
|
||||
const DEFAULT_CONFIG: RelayConfig = {
|
||||
policy: { public_join: false, strip_signatures: false },
|
||||
groups: { enabled: false, auto_join: false },
|
||||
management: { enabled: false },
|
||||
blossom: { enabled: false },
|
||||
livekit: { enabled: false },
|
||||
push: { enabled: false },
|
||||
}
|
||||
|
||||
export default function AdminRelayEdit() {
|
||||
const navigate = useNavigate()
|
||||
const params = useParams()
|
||||
@@ -34,10 +25,10 @@ export default function AdminRelayEdit() {
|
||||
createEffect(() => {
|
||||
const data = relay()
|
||||
if (!data) return
|
||||
setName(data.name)
|
||||
setName(data.info_name)
|
||||
setSubdomain(data.subdomain)
|
||||
setIcon(data.icon)
|
||||
setDescription(data.description)
|
||||
setIcon(data.info_icon)
|
||||
setDescription(data.info_description)
|
||||
})
|
||||
|
||||
async function handleSubmit(e: Event) {
|
||||
@@ -46,11 +37,10 @@ export default function AdminRelayEdit() {
|
||||
setSubmitting(true)
|
||||
try {
|
||||
await adminUpdateRelay(relayId(), {
|
||||
name: name().trim(),
|
||||
subdomain: slugify(subdomain()),
|
||||
icon: icon().trim(),
|
||||
description: description().trim(),
|
||||
config: relay()?.config ?? DEFAULT_CONFIG,
|
||||
info_name: name().trim(),
|
||||
info_icon: icon().trim(),
|
||||
info_description: description().trim(),
|
||||
})
|
||||
navigate(`/admin/relays/${relayId()}`)
|
||||
} catch (e) {
|
||||
|
||||
@@ -18,7 +18,7 @@ export default function AdminRelayList() {
|
||||
if (!q) return list
|
||||
|
||||
return new Fuse(list, {
|
||||
keys: ["name", "subdomain", "tenant"],
|
||||
keys: ["info_name", "subdomain", "tenant"],
|
||||
threshold: 0.35,
|
||||
ignoreLocation: true,
|
||||
}).search(q).map((result) => result.item)
|
||||
@@ -60,7 +60,7 @@ export default function AdminRelayList() {
|
||||
<A href={`/admin/relays/${relay.id}`} class="block border border-gray-200 rounded-lg p-4 bg-white hover:border-gray-300">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div>
|
||||
<p class="font-medium text-gray-900">{relay.name}</p>
|
||||
<p class="font-medium text-gray-900">{relay.info_name || relay.subdomain}</p>
|
||||
<p class="text-xs text-gray-500">{relay.subdomain}.spaces.coracle.social</p>
|
||||
<p class="text-xs text-gray-500 break-all mt-1">Tenant: {relay.tenant}</p>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useParams, A } from "@solidjs/router"
|
||||
import { createResource, createSignal, For, Show } from "solid-js"
|
||||
import { adminGetTenant, adminUpdateTenantStatus } from "../../lib/api"
|
||||
import { createResource, For, Show } from "solid-js"
|
||||
import { adminGetTenant } from "../../lib/api"
|
||||
import BackLink from "../../components/BackLink"
|
||||
import PageContainer from "../../components/PageContainer"
|
||||
import ResourceState from "../../components/ResourceState"
|
||||
@@ -9,25 +9,9 @@ import useMinLoading from "../../components/useMinLoading"
|
||||
export default function AdminTenantDetail() {
|
||||
const params = useParams()
|
||||
const tenantId = () => params.id ?? ""
|
||||
const [detail, { refetch }] = createResource(tenantId, adminGetTenant)
|
||||
const [busy, setBusy] = createSignal(false)
|
||||
const [error, setError] = createSignal("")
|
||||
const [detail] = createResource(tenantId, adminGetTenant)
|
||||
const loading = useMinLoading(() => detail.loading)
|
||||
|
||||
async function setStatus(status: string) {
|
||||
if (busy()) return
|
||||
setBusy(true)
|
||||
setError("")
|
||||
try {
|
||||
await adminUpdateTenantStatus(tenantId(), status)
|
||||
await refetch()
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : "Failed to update tenant")
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<PageContainer>
|
||||
<BackLink href="/admin/tenants" label="Tenants" />
|
||||
@@ -49,24 +33,8 @@ export default function AdminTenantDetail() {
|
||||
{(d) => (
|
||||
<div class="space-y-3">
|
||||
<p class="text-sm text-gray-700">
|
||||
Current: <span class="font-medium uppercase tracking-wide">{d().tenant.status}</span>
|
||||
Current: <span class="font-medium uppercase tracking-wide">tenant</span>
|
||||
</p>
|
||||
<div class="flex gap-2">
|
||||
<button
|
||||
class="py-2 px-4 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 disabled:opacity-50"
|
||||
onClick={() => void setStatus("active")}
|
||||
disabled={busy()}
|
||||
>
|
||||
Activate
|
||||
</button>
|
||||
<button
|
||||
class="py-2 px-4 border border-red-300 text-red-600 rounded-lg hover:bg-red-50 disabled:opacity-50"
|
||||
onClick={() => void setStatus("deactivated")}
|
||||
disabled={busy()}
|
||||
>
|
||||
Deactivate
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</Show>
|
||||
@@ -82,7 +50,7 @@ export default function AdminTenantDetail() {
|
||||
<A href={`/admin/relays/${relay.id}`} class="block rounded-lg border border-gray-200 p-3 hover:border-gray-300">
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<div>
|
||||
<p class="font-medium text-gray-900">{relay.name}</p>
|
||||
<p class="font-medium text-gray-900">{relay.info_name || relay.subdomain}</p>
|
||||
<p class="text-xs text-gray-500">{relay.subdomain}.spaces.coracle.social</p>
|
||||
</div>
|
||||
<span class="text-xs uppercase tracking-wide text-gray-500">{relay.status}</span>
|
||||
@@ -94,9 +62,6 @@ export default function AdminTenantDetail() {
|
||||
</ul>
|
||||
</Show>
|
||||
</section>
|
||||
<Show when={error()}>
|
||||
<p class="text-sm text-red-600">{error()}</p>
|
||||
</Show>
|
||||
</div>
|
||||
</Show>
|
||||
</PageContainer>
|
||||
|
||||
@@ -115,7 +115,7 @@ export default function AdminTenantList() {
|
||||
<p class="mt-1 text-xs text-gray-500 break-all">{tenant.pubkey}</p>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-xs uppercase tracking-wide text-gray-500">{tenant.status}</p>
|
||||
<p class="text-xs uppercase tracking-wide text-gray-500">tenant</p>
|
||||
</div>
|
||||
</A>
|
||||
</li>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useParams } from "@solidjs/router"
|
||||
import { createMemo, createResource, createSignal, Show } from "solid-js"
|
||||
import { deactivateTenantRelay, getRelayMemberCount, getTenantRelay, updateTenantRelay, updateTenantRelayPlan, type RelayConfig } from "../../lib/api"
|
||||
import { deactivateTenantRelay, getRelayMemberCount, getTenantRelay, updateTenantRelay, updateTenantRelayPlan, type Relay } from "../../lib/api"
|
||||
import type { RelayPlanId } from "../../lib/relayPlans"
|
||||
import BackLink from "../../components/BackLink"
|
||||
import PageContainer from "../../components/PageContainer"
|
||||
@@ -35,114 +35,100 @@ export default function RelayDetail() {
|
||||
}
|
||||
}
|
||||
|
||||
function withDefaults(config?: RelayConfig): RelayConfig {
|
||||
return {
|
||||
policy: {
|
||||
public_join: config?.policy.public_join ?? false,
|
||||
strip_signatures: config?.policy.strip_signatures ?? false,
|
||||
},
|
||||
groups: {
|
||||
enabled: config?.groups.enabled ?? true,
|
||||
auto_join: config?.groups.auto_join ?? true,
|
||||
},
|
||||
management: {
|
||||
enabled: config?.management.enabled ?? true,
|
||||
},
|
||||
blossom: {
|
||||
enabled: config?.blossom.enabled ?? (relay()?.plan !== "free"),
|
||||
},
|
||||
livekit: {
|
||||
enabled: config?.livekit.enabled ?? (relay()?.plan !== "free"),
|
||||
},
|
||||
push: {
|
||||
enabled: config?.push.enabled ?? true,
|
||||
},
|
||||
}
|
||||
function toBool(value: number | undefined, fallback: boolean): boolean {
|
||||
if (value === 0) return false
|
||||
if (value === 1) return true
|
||||
return fallback
|
||||
}
|
||||
|
||||
async function updateFlags(nextConfig: RelayConfig, previousConfig: RelayConfig) {
|
||||
function toInt(value: boolean): number {
|
||||
return value ? 1 : 0
|
||||
}
|
||||
|
||||
async function updateRelay(next: Relay, previous: Relay) {
|
||||
const current = relay()
|
||||
if (!current) return
|
||||
|
||||
setError("")
|
||||
mutate({ ...current, config: nextConfig })
|
||||
mutate(next)
|
||||
|
||||
try {
|
||||
await updateTenantRelay(relayId(), {
|
||||
name: current.name,
|
||||
subdomain: current.subdomain,
|
||||
icon: current.icon,
|
||||
description: current.description,
|
||||
config: nextConfig,
|
||||
})
|
||||
await updateTenantRelay(relayId(), next)
|
||||
await refetch()
|
||||
} catch (e) {
|
||||
mutate({ ...current, config: previousConfig })
|
||||
mutate(previous)
|
||||
setError(e instanceof Error ? e.message : "Failed to update relay settings")
|
||||
}
|
||||
}
|
||||
|
||||
function togglePublicJoin() {
|
||||
const config = withDefaults(relay()?.config)
|
||||
const nextConfig = {
|
||||
...config,
|
||||
policy: { ...config.policy, public_join: !config.policy.public_join },
|
||||
const current = relay()
|
||||
if (!current) return
|
||||
const next = {
|
||||
...current,
|
||||
policy_public_join: toInt(!toBool(current.policy_public_join, false)),
|
||||
}
|
||||
void updateFlags(nextConfig, config)
|
||||
void updateRelay(next, current)
|
||||
}
|
||||
|
||||
function toggleStripSignatures() {
|
||||
const config = withDefaults(relay()?.config)
|
||||
const nextConfig = {
|
||||
...config,
|
||||
policy: { ...config.policy, strip_signatures: !config.policy.strip_signatures },
|
||||
const current = relay()
|
||||
if (!current) return
|
||||
const next = {
|
||||
...current,
|
||||
policy_strip_signatures: toInt(!toBool(current.policy_strip_signatures, false)),
|
||||
}
|
||||
void updateFlags(nextConfig, config)
|
||||
void updateRelay(next, current)
|
||||
}
|
||||
|
||||
function toggleGroups() {
|
||||
const config = withDefaults(relay()?.config)
|
||||
const nextConfig = {
|
||||
...config,
|
||||
groups: { ...config.groups, enabled: !config.groups.enabled },
|
||||
const current = relay()
|
||||
if (!current) return
|
||||
const next = {
|
||||
...current,
|
||||
groups_enabled: toInt(!toBool(current.groups_enabled, true)),
|
||||
}
|
||||
void updateFlags(nextConfig, config)
|
||||
void updateRelay(next, current)
|
||||
}
|
||||
|
||||
function toggleManagement() {
|
||||
const config = withDefaults(relay()?.config)
|
||||
const nextConfig = {
|
||||
...config,
|
||||
management: { enabled: !config.management.enabled },
|
||||
const current = relay()
|
||||
if (!current) return
|
||||
const next = {
|
||||
...current,
|
||||
management_enabled: toInt(!toBool(current.management_enabled, true)),
|
||||
}
|
||||
void updateFlags(nextConfig, config)
|
||||
void updateRelay(next, current)
|
||||
}
|
||||
|
||||
function toggleMediaStorage() {
|
||||
const config = withDefaults(relay()?.config)
|
||||
const nextConfig = {
|
||||
...config,
|
||||
blossom: { enabled: !config.blossom.enabled },
|
||||
const current = relay()
|
||||
if (!current) return
|
||||
const next = {
|
||||
...current,
|
||||
blossom_enabled: toInt(!toBool(current.blossom_enabled, current.plan !== "free")),
|
||||
}
|
||||
void updateFlags(nextConfig, config)
|
||||
void updateRelay(next, current)
|
||||
}
|
||||
|
||||
function togglePushNotifications() {
|
||||
const config = withDefaults(relay()?.config)
|
||||
const nextConfig = {
|
||||
...config,
|
||||
push: { enabled: !config.push.enabled },
|
||||
const current = relay()
|
||||
if (!current) return
|
||||
const next = {
|
||||
...current,
|
||||
push_enabled: toInt(!toBool(current.push_enabled, true)),
|
||||
}
|
||||
void updateFlags(nextConfig, config)
|
||||
void updateRelay(next, current)
|
||||
}
|
||||
|
||||
function toggleLivekitSupport() {
|
||||
const config = withDefaults(relay()?.config)
|
||||
const nextConfig = {
|
||||
...config,
|
||||
livekit: { enabled: !config.livekit.enabled },
|
||||
const current = relay()
|
||||
if (!current) return
|
||||
const next = {
|
||||
...current,
|
||||
livekit_enabled: toInt(!toBool(current.livekit_enabled, current.plan !== "free")),
|
||||
}
|
||||
void updateFlags(nextConfig, config)
|
||||
void updateRelay(next, current)
|
||||
}
|
||||
|
||||
async function handleUpdatePlan(plan: RelayPlanId) {
|
||||
@@ -152,13 +138,14 @@ export default function RelayDetail() {
|
||||
const previous = current
|
||||
setError("")
|
||||
|
||||
const nextConfig = withDefaults(current.config)
|
||||
const next = { ...current }
|
||||
if (plan === "free") {
|
||||
nextConfig.blossom = { enabled: false }
|
||||
nextConfig.livekit = { enabled: false }
|
||||
next.blossom_enabled = 0
|
||||
next.livekit_enabled = 0
|
||||
}
|
||||
|
||||
mutate({ ...current, plan, config: nextConfig })
|
||||
next.plan = plan
|
||||
mutate(next)
|
||||
|
||||
try {
|
||||
await updateTenantRelayPlan(relayId(), plan)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useNavigate, useParams } from "@solidjs/router"
|
||||
import { Show, createEffect, createResource, createSignal } from "solid-js"
|
||||
import { getTenantRelay, updateTenantRelay, type RelayConfig } from "../../lib/api"
|
||||
import { getTenantRelay, updateTenantRelay } from "../../lib/api"
|
||||
import RelayForm from "../../components/RelayForm"
|
||||
import { slugify } from "../../lib/slugify"
|
||||
import BackLink from "../../components/BackLink"
|
||||
@@ -8,15 +8,6 @@ import PageContainer from "../../components/PageContainer"
|
||||
import ResourceState from "../../components/ResourceState"
|
||||
import useMinLoading from "../../components/useMinLoading"
|
||||
|
||||
const DEFAULT_CONFIG: RelayConfig = {
|
||||
policy: { public_join: false, strip_signatures: false },
|
||||
groups: { enabled: false, auto_join: false },
|
||||
management: { enabled: false },
|
||||
blossom: { enabled: false },
|
||||
livekit: { enabled: false },
|
||||
push: { enabled: false },
|
||||
}
|
||||
|
||||
export default function RelayEdit() {
|
||||
const navigate = useNavigate()
|
||||
const params = useParams()
|
||||
@@ -34,10 +25,10 @@ export default function RelayEdit() {
|
||||
createEffect(() => {
|
||||
const data = relay()
|
||||
if (!data) return
|
||||
setName(data.name)
|
||||
setName(data.info_name)
|
||||
setSubdomain(data.subdomain)
|
||||
setIcon(data.icon)
|
||||
setDescription(data.description)
|
||||
setIcon(data.info_icon)
|
||||
setDescription(data.info_description)
|
||||
})
|
||||
|
||||
async function handleSubmit(e: Event) {
|
||||
@@ -46,11 +37,10 @@ export default function RelayEdit() {
|
||||
setSubmitting(true)
|
||||
try {
|
||||
await updateTenantRelay(relayId(), {
|
||||
name: name().trim(),
|
||||
subdomain: slugify(subdomain()),
|
||||
icon: icon().trim(),
|
||||
description: description().trim(),
|
||||
config: relay()?.config ?? DEFAULT_CONFIG,
|
||||
info_name: name().trim(),
|
||||
info_icon: icon().trim(),
|
||||
info_description: description().trim(),
|
||||
})
|
||||
navigate(`/relays/${relayId()}`)
|
||||
} catch (e) {
|
||||
|
||||
@@ -17,7 +17,7 @@ export default function RelayList() {
|
||||
const q = query().trim()
|
||||
const searched = q
|
||||
? new Fuse(list, {
|
||||
keys: ["name", "subdomain"],
|
||||
keys: ["info_name", "subdomain"],
|
||||
threshold: 0.35,
|
||||
ignoreLocation: true,
|
||||
}).search(q).map((result) => result.item)
|
||||
@@ -90,7 +90,7 @@ export default function RelayList() {
|
||||
>
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<p class="font-medium text-gray-900">{relay.name}</p>
|
||||
<p class="font-medium text-gray-900">{relay.info_name || relay.subdomain}</p>
|
||||
<p class="text-sm text-gray-500">https://{relay.subdomain}.spaces.coracle.social</p>
|
||||
</div>
|
||||
<p class="text-xs uppercase tracking-wide text-gray-500">{relay.status}</p>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Show, createSignal } from "solid-js"
|
||||
import { useNavigate } from "@solidjs/router"
|
||||
import { createTenantRelay, type RelayConfig } from "../../lib/api"
|
||||
import { createTenantRelay } from "../../lib/api"
|
||||
import { slugify } from "../../lib/slugify"
|
||||
|
||||
const PLANS = [
|
||||
@@ -11,15 +11,6 @@ const PLANS = [
|
||||
|
||||
type PlanId = (typeof PLANS)[number]["id"]
|
||||
|
||||
const DEFAULT_CONFIG: RelayConfig = {
|
||||
policy: { public_join: false, strip_signatures: false },
|
||||
groups: { enabled: true, auto_join: true },
|
||||
management: { enabled: true },
|
||||
blossom: { enabled: false },
|
||||
livekit: { enabled: false },
|
||||
push: { enabled: true },
|
||||
}
|
||||
|
||||
export default function RelayNew() {
|
||||
const navigate = useNavigate()
|
||||
const [name, setName] = createSignal("")
|
||||
@@ -44,16 +35,18 @@ export default function RelayNew() {
|
||||
|
||||
try {
|
||||
const relay = await createTenantRelay({
|
||||
name: name().trim(),
|
||||
subdomain: slugify(subdomain()),
|
||||
icon: icon().trim(),
|
||||
description: description().trim(),
|
||||
plan: plan(),
|
||||
config: {
|
||||
...DEFAULT_CONFIG,
|
||||
blossom: { enabled: plan() !== "free" },
|
||||
livekit: { enabled: plan() !== "free" },
|
||||
},
|
||||
info_name: name().trim(),
|
||||
info_icon: icon().trim(),
|
||||
info_description: description().trim(),
|
||||
policy_public_join: 0,
|
||||
policy_strip_signatures: 0,
|
||||
groups_enabled: 1,
|
||||
management_enabled: 1,
|
||||
blossom_enabled: plan() === "free" ? 0 : 1,
|
||||
livekit_enabled: plan() === "free" ? 0 : 1,
|
||||
push_enabled: 1,
|
||||
})
|
||||
navigate(`/relays/${relay.id}`)
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user