Files
Docwell/Web-App/frontend/src/views/workspace/NewWorkspaceView.vue
T
tajniak81andClaude Opus 5.5 ba394b8fac Finish Phase 0: lint, codegen, contributor docs and the two remaining spikes
Repository basics:
- CONTRIBUTING.md and CODE_OF_CONDUCT.md (Contributor Covenant 2.1)
- SPDX AGPL-3.0-or-later headers on all hand-written sources, checked in CI
- golangci-lint (shared .golangci.yml), ESLint and Prettier, all run in CI

API codegen from api/openapi.yaml (npm run generate, drift fails CI):
- Go types via oapi-codegen in Server/internal/api
- a contract test that the router and the spec list the same routes
- Dart models via Phone-App/tool/generate_api.dart; the app uses them

Spike: shared Tiptap editor in a Flutter WebView (ADR-4)
- @docwell/editor-bridge builds the editor into one HTML page with a
  versioned JSON protocol; Phone-App hosts it with webview_flutter and a
  native toolbar. Integration test passes on an Android API 35 emulator.
- flutter_inappwebview dropped: its Android plugin fails on AGP 9.

Spike: Wails v3 desktop (ADR-11)
- system tray, docwell:// deep links (page and space only) with
  single-instance hand-off, and the built-in updater with a required
  ed25519 signing key. Verified on Windows.
- regenerated build assets register the scheme and drop template
  placeholders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 16:11:07 +01:00

67 lines
2.5 KiB
Vue

<!-- SPDX-License-Identifier: AGPL-3.0-or-later -->
<script setup lang="ts">
import type { Organization } from "@docwell/api-client";
import { DwButton, DwCallout } from "@docwell/ui";
import { computed, onMounted, ref } from "vue";
import { useRouter } from "vue-router";
import { useApi } from "../../api";
import FormField from "../../components/FormField.vue";
import PageShell from "../../components/PageShell.vue";
import { useFormErrors } from "../../composables/useFormErrors";
import { useAuthStore } from "../../stores/auth";
import { useWorkspacesStore } from "../../stores/workspaces";
const api = useApi();
const auth = useAuthStore();
const workspaces = useWorkspacesStore();
const router = useRouter();
const errors = useFormErrors();
const name = ref("");
const organization = ref("");
const orgs = ref<Organization[]>([]);
const busy = ref(false);
// Org admins always create in their own organization; superadmins pick one.
const isSuperadmin = computed(() => auth.user?.role === "superadmin");
onMounted(async () => {
if (isSuperadmin.value) {
orgs.value = await api.orgs.list().catch(() => []);
organization.value = orgs.value[0]?.id ?? "";
}
});
async function submit() {
busy.value = true;
errors.reset();
try {
const ws = await api.workspaces.create(name.value, isSuperadmin.value ? organization.value : undefined);
await workspaces.load();
router.replace({ name: "workspace-settings", params: { id: ws.id } });
} catch (e) {
errors.show(e);
} finally {
busy.value = false;
}
}
</script>
<template>
<PageShell :title="$t('workspace.newTitle')" :subtitle="$t('workspace.newHint')">
<form class="space-y-4 dw-card" @submit.prevent="submit">
<FormField v-model="name" :label="$t('workspace.name')" required :error="errors.fields.value.name" />
<label v-if="isSuperadmin" class="flex flex-col gap-1.5">
<span class="text-ui-sm font-semibold">{{ $t("workspace.organization") }}</span>
<select v-model="organization" required class="dw-input w-full">
<option v-for="o in orgs" :key="o.id" :value="o.id">{{ o.name }}</option>
</select>
<span v-if="!orgs.length" class="text-ui-sm text-ink-muted">{{ $t("workspace.noOrgs") }}</span>
</label>
<DwCallout v-if="errors.message.value" tone="danger" size="ui">{{ errors.message.value }}</DwCallout>
<DwButton type="submit" variant="primary" :disabled="busy || !name.trim() || (isSuperadmin && !organization)">
{{ $t("workspace.create") }}
</DwButton>
</form>
</PageShell>
</template>