mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-21 09:44:21 +01:00
wip: zen
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { query, useParams, action, createAsync, redirect } from "@solidjs/router"
|
import { query, useParams, action, createAsync, redirect, useSubmission } from "@solidjs/router"
|
||||||
import { For, Show, createEffect, onCleanup } from "solid-js"
|
import { For, Show, createEffect, onCleanup } from "solid-js"
|
||||||
import { createStore } from "solid-js/store"
|
import { createStore } from "solid-js/store"
|
||||||
import { withActor } from "~/context/auth.withActor"
|
import { withActor } from "~/context/auth.withActor"
|
||||||
@@ -42,6 +42,7 @@ const createWorkspace = action(async (form: FormData) => {
|
|||||||
export function WorkspacePicker() {
|
export function WorkspacePicker() {
|
||||||
const params = useParams()
|
const params = useParams()
|
||||||
const workspaces = createAsync(() => getWorkspaces())
|
const workspaces = createAsync(() => getWorkspaces())
|
||||||
|
const submission = useSubmission(createWorkspace)
|
||||||
const [store, setStore] = createStore({
|
const [store, setStore] = createStore({
|
||||||
showForm: false,
|
showForm: false,
|
||||||
showDropdown: false,
|
showDropdown: false,
|
||||||
@@ -135,8 +136,8 @@ export function WorkspacePicker() {
|
|||||||
<button type="button" data-color="ghost" onClick={() => setStore("showForm", false)}>
|
<button type="button" data-color="ghost" onClick={() => setStore("showForm", false)}>
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
<button type="submit" data-color="primary">
|
<button type="submit" data-color="primary" disabled={submission.pending}>
|
||||||
Create
|
{submission.pending ? "Creating..." : "Create"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ export default function WorkspaceLayout(props: RouteSectionProps) {
|
|||||||
<A href={`/workspace/${params.id}/billing`} activeClass="active" data-nav-button>
|
<A href={`/workspace/${params.id}/billing`} activeClass="active" data-nav-button>
|
||||||
Billing
|
Billing
|
||||||
</A>
|
</A>
|
||||||
</Show>
|
|
||||||
<A href={`/workspace/${params.id}/settings`} activeClass="active" data-nav-button>
|
<A href={`/workspace/${params.id}/settings`} activeClass="active" data-nav-button>
|
||||||
Settings
|
Settings
|
||||||
</A>
|
</A>
|
||||||
|
</Show>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
<div data-component="workspace-content">{props.children}</div>
|
<div data-component="workspace-content">{props.children}</div>
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ export namespace Actor {
|
|||||||
|
|
||||||
export const assertAdmin = () => {
|
export const assertAdmin = () => {
|
||||||
if (userRole() === "admin") return
|
if (userRole() === "admin") return
|
||||||
throw new Error(`Expected admin user, got ${userRole()}`)
|
throw new Error(`Action not allowed. Ask your workspace admin to perform this action.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function workspace() {
|
export function workspace() {
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ export namespace Workspace {
|
|||||||
name: z.string().min(1).max(255),
|
name: z.string().min(1).max(255),
|
||||||
}),
|
}),
|
||||||
async ({ name }) => {
|
async ({ name }) => {
|
||||||
|
Actor.assertAdmin()
|
||||||
const workspaceID = Actor.workspace()
|
const workspaceID = Actor.workspace()
|
||||||
return await Database.use((tx) =>
|
return await Database.use((tx) =>
|
||||||
tx
|
tx
|
||||||
|
|||||||
Reference in New Issue
Block a user