refactor: remove organization slug

This commit is contained in:
2026-05-04 17:41:50 -04:00
parent 552f4f1f21
commit 58c1301054
14 changed files with 166 additions and 188 deletions

View File

@@ -247,14 +247,12 @@ public static class DevelopmentSeedExtensions
{ {
Id = OrganizationId, Id = OrganizationId,
Name = string.Empty, Name = string.Empty,
Slug = string.Empty,
CreatedAt = DateTimeOffset.UtcNow, CreatedAt = DateTimeOffset.UtcNow,
}; };
dbContext.Organizations.Add(organization); dbContext.Organizations.Add(organization);
} }
organization.Name = "Northstar Collective"; organization.Name = "Northstar Collective";
organization.Slug = "northstar-collective";
organization.OwnerUserId = managerUserId; organization.OwnerUserId = managerUserId;
await UpsertOrganizationMembershipAsync( await UpsertOrganizationMembershipAsync(

View File

@@ -1225,18 +1225,10 @@ namespace Socialize.Api.Migrations
b.Property<Guid>("OwnerUserId") b.Property<Guid>("OwnerUserId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<string>("Slug")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("OwnerUserId"); b.HasIndex("OwnerUserId");
b.HasIndex("Slug")
.IsUnique();
b.ToTable("Organizations", (string)null); b.ToTable("Organizations", (string)null);
}); });

View File

@@ -24,7 +24,6 @@ namespace Socialize.Api.Migrations
{ {
Id = table.Column<Guid>(type: "uuid", nullable: false), Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
Slug = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
OwnerUserId = table.Column<Guid>(type: "uuid", nullable: false), OwnerUserId = table.Column<Guid>(type: "uuid", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP") CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP")
}, },
@@ -56,8 +55,8 @@ namespace Socialize.Api.Migrations
migrationBuilder.Sql( migrationBuilder.Sql(
""" """
INSERT INTO "Organizations" ("Id", "Name", "Slug", "OwnerUserId", "CreatedAt") INSERT INTO "Organizations" ("Id", "Name", "OwnerUserId", "CreatedAt")
VALUES ('99999999-9999-9999-9999-999999999999', 'Northstar Collective', 'northstar-collective', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', CURRENT_TIMESTAMP); VALUES ('99999999-9999-9999-9999-999999999999', 'Northstar Collective', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', CURRENT_TIMESTAMP);
UPDATE "Workspaces" UPDATE "Workspaces"
SET "OrganizationId" = '99999999-9999-9999-9999-999999999999' SET "OrganizationId" = '99999999-9999-9999-9999-999999999999'
@@ -93,12 +92,6 @@ namespace Socialize.Api.Migrations
table: "Organizations", table: "Organizations",
column: "OwnerUserId"); column: "OwnerUserId");
migrationBuilder.CreateIndex(
name: "IX_Organizations_Slug",
table: "Organizations",
column: "Slug",
unique: true);
migrationBuilder.AddForeignKey( migrationBuilder.AddForeignKey(
name: "FK_Workspaces_Organizations_OrganizationId", name: "FK_Workspaces_Organizations_OrganizationId",
table: "Workspaces", table: "Workspaces",

View File

@@ -1222,18 +1222,10 @@ namespace Socialize.Api.Migrations
b.Property<Guid>("OwnerUserId") b.Property<Guid>("OwnerUserId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<string>("Slug")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("OwnerUserId"); b.HasIndex("OwnerUserId");
b.HasIndex("Slug")
.IsUnique();
b.ToTable("Organizations", (string)null); b.ToTable("Organizations", (string)null);
}); });

View File

@@ -4,7 +4,6 @@ public class Organization
{ {
public Guid Id { get; init; } public Guid Id { get; init; }
public required string Name { get; set; } public required string Name { get; set; }
public required string Slug { get; set; }
public Guid OwnerUserId { get; set; } public Guid OwnerUserId { get; set; }
public DateTimeOffset CreatedAt { get; init; } public DateTimeOffset CreatedAt { get; init; }
} }

View File

@@ -11,11 +11,9 @@ public static class OrganizationModelConfiguration
organization.ToTable("Organizations"); organization.ToTable("Organizations");
organization.HasKey(x => x.Id); organization.HasKey(x => x.Id);
organization.Property(x => x.Name).HasMaxLength(256).IsRequired(); organization.Property(x => x.Name).HasMaxLength(256).IsRequired();
organization.Property(x => x.Slug).HasMaxLength(128).IsRequired();
organization.Property(x => x.CreatedAt) organization.Property(x => x.CreatedAt)
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasDefaultValueSql("CURRENT_TIMESTAMP"); .HasDefaultValueSql("CURRENT_TIMESTAMP");
organization.HasIndex(x => x.Slug).IsUnique();
organization.HasIndex(x => x.OwnerUserId); organization.HasIndex(x => x.OwnerUserId);
}); });

View File

@@ -15,7 +15,6 @@ public record OrganizationMemberDto(
public record OrganizationDto( public record OrganizationDto(
Guid Id, Guid Id,
string Name, string Name,
string Slug,
Guid OwnerUserId, Guid OwnerUserId,
IReadOnlyCollection<string> CurrentUserPermissions, IReadOnlyCollection<string> CurrentUserPermissions,
IReadOnlyCollection<OrganizationMemberDto> Members, IReadOnlyCollection<OrganizationMemberDto> Members,
@@ -31,7 +30,6 @@ public record OrganizationDto(
return new OrganizationDto( return new OrganizationDto(
organization.Id, organization.Id,
organization.Name, organization.Name,
organization.Slug,
organization.OwnerUserId, organization.OwnerUserId,
currentUserPermissions, currentUserPermissions,
members ?? [], members ?? [],

View File

@@ -17,7 +17,7 @@ Existing local data does not need to be preserved.
## Scope ## Scope
- Add an `Organizations` backend module or follow the existing ownership pattern if organization code belongs with `Workspaces`. - Add an `Organizations` backend module or follow the existing ownership pattern if organization code belongs with `Workspaces`.
- Add an organization persistence model with `Id`, `Name`, `Slug`, `OwnerUserId`, and `CreatedAt`, matching local conventions. - Add an organization persistence model with `Id`, `Name`, `OwnerUserId`, and `CreatedAt`, matching local conventions.
- Require every workspace to belong to exactly one organization. - Require every workspace to belong to exactly one organization.
- Update workspace create/list/detail APIs to include organization ownership. - Update workspace create/list/detail APIs to include organization ownership.
- Add current-user organization read APIs: - Add current-user organization read APIs:
@@ -46,7 +46,6 @@ Existing local data does not need to be preserved.
- The first implementation may grant organization access through `Organization.OwnerUserId == currentUserId` and existing manager/administrator access. Full organization membership belongs to task 002. - The first implementation may grant organization access through `Organization.OwnerUserId == currentUserId` and existing manager/administrator access. Full organization membership belongs to task 002.
- `CreateWorkspaceRequest` should require `OrganizationId`; reject creation when the user cannot manage that organization. - `CreateWorkspaceRequest` should require `OrganizationId`; reject creation when the user cannot manage that organization.
- `WorkspaceDto` should include `OrganizationId`. - `WorkspaceDto` should include `OrganizationId`.
- Slugs should keep the existing lowercase kebab-case validation used for workspaces.
- Use tests for unauthorized organization detail access and workspace creation under an inaccessible organization. - Use tests for unauthorized organization detail access and workspace creation under an inaccessible organization.
## Likely Files ## Likely Files

View File

@@ -993,7 +993,6 @@ export interface components {
/** Format: guid */ /** Format: guid */
id?: string; id?: string;
name?: string; name?: string;
slug?: string;
/** Format: guid */ /** Format: guid */
ownerUserId?: string; ownerUserId?: string;
currentUserPermissions?: string[]; currentUserPermissions?: string[];

View File

@@ -1,5 +1,5 @@
<script setup> <script setup>
import { computed, onMounted, watch } from 'vue'; import { computed, onMounted, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { import {
@@ -20,6 +20,7 @@
const { t } = useI18n(); const { t } = useI18n();
const organizationStore = useOrganizationStore(); const organizationStore = useOrganizationStore();
const workspaceStore = useWorkspaceStore(); const workspaceStore = useWorkspaceStore();
const activeSectionKey = ref('profile');
const organizationId = computed(() => route.params.organizationId); const organizationId = computed(() => route.params.organizationId);
const organization = computed(() => const organization = computed(() =>
@@ -48,6 +49,11 @@
{ key: 'connections', icon: mdiLanConnect, visible: canViewConnections.value }, { key: 'connections', icon: mdiLanConnect, visible: canViewConnections.value },
{ key: 'workspaces', icon: mdiBriefcaseOutline, visible: canViewWorkspaces.value }, { key: 'workspaces', icon: mdiBriefcaseOutline, visible: canViewWorkspaces.value },
].filter(section => section.visible)); ].filter(section => section.visible));
const activeSection = computed(() =>
visibleSections.value.find(section => section.key === activeSectionKey.value) ??
visibleSections.value[0] ??
null
);
function hasPermission(permission) { function hasPermission(permission) {
return permissions.value.includes(permission); return permissions.value.includes(permission);
@@ -72,6 +78,15 @@
onMounted(loadOrganization); onMounted(loadOrganization);
watch(organizationId, loadOrganization); watch(organizationId, loadOrganization);
watch(
visibleSections,
sections => {
if (!sections.some(section => section.key === activeSectionKey.value)) {
activeSectionKey.value = sections[0]?.key ?? 'profile';
}
},
{ immediate: true }
);
</script> </script>
<template> <template>
@@ -82,10 +97,6 @@
<h1>{{ organization?.name ?? t('organizationSettings.title') }}</h1> <h1>{{ organization?.name ?? t('organizationSettings.title') }}</h1>
<p>{{ t('organizationSettings.description') }}</p> <p>{{ t('organizationSettings.description') }}</p>
</div> </div>
<div class="settings-summary">
<span>{{ t('organizationSettings.slugLabel') }}</span>
<strong>{{ organization?.slug ?? '-' }}</strong>
</div>
</div> </div>
<div <div
@@ -104,43 +115,63 @@
<div <div
v-else-if="organization" v-else-if="organization"
class="settings-grid" class="settings-page"
> >
<article <nav
class="settings-tabs"
aria-label="Organization settings sections"
>
<button
v-for="section in visibleSections" v-for="section in visibleSections"
:key="section.key" :key="section.key"
class="settings-section" class="settings-tab"
:class="{ 'settings-tab-active': section.key === activeSectionKey }"
type="button"
@click="activeSectionKey = section.key"
> >
<div class="section-heading">
<span class="section-icon">
<v-icon :icon="section.icon" /> <v-icon :icon="section.icon" />
</span> <span>{{ t(`organizationSettings.sections.${section.key}.title`) }}</span>
<div> </button>
<h2>{{ t(`organizationSettings.sections.${section.key}.title`) }}</h2> </nav>
<p>{{ t(`organizationSettings.sections.${section.key}.description`) }}</p>
</div>
</div>
<div <div
v-if="section.key === 'profile'" v-if="activeSection"
class="settings-content"
>
<div class="section-heading">
<h2>{{ t(`organizationSettings.sections.${activeSection.key}.title`) }}</h2>
<p>{{ t(`organizationSettings.sections.${activeSection.key}.description`) }}</p>
</div>
<article class="content-card">
<div
v-if="activeSection.key === 'profile'"
class="detail-list" class="detail-list"
> >
<div> <div>
<span>{{ t('organizationSettings.fields.name') }}</span> <span>{{ t('organizationSettings.fields.name') }}</span>
<strong>{{ organization.name }}</strong> <strong>{{ organization.name }}</strong>
</div> </div>
<div>
<span>{{ t('organizationSettings.fields.slug') }}</span>
<strong>{{ organization.slug }}</strong>
</div>
<div> <div>
<span>{{ t('organizationSettings.fields.createdAt') }}</span> <span>{{ t('organizationSettings.fields.createdAt') }}</span>
<strong>{{ new Date(organization.createdAt).toLocaleDateString() }}</strong> <strong>{{ new Date(organization.createdAt).toLocaleDateString() }}</strong>
</div> </div>
<div class="permissions-panel">
<span>{{ t('organizationSettings.permissions.title') }}</span>
<div class="permission-grid">
<span
v-for="permission in Object.values(organizationPermissions)"
:key="permission"
:class="{ enabled: hasPermission(permission) }"
>
{{ t(`organizationSettings.permissions.items.${permission}`) }}
</span>
</div>
</div>
</div> </div>
<div <div
v-else-if="section.key === 'members'" v-else-if="activeSection.key === 'members'"
class="table-list" class="table-list"
> >
<div <div
@@ -163,7 +194,7 @@
</div> </div>
<div <div
v-else-if="section.key === 'billing'" v-else-if="activeSection.key === 'billing'"
class="placeholder-panel" class="placeholder-panel"
> >
<strong>{{ t('organizationSettings.sections.billing.placeholderTitle') }}</strong> <strong>{{ t('organizationSettings.sections.billing.placeholderTitle') }}</strong>
@@ -171,7 +202,7 @@
</div> </div>
<div <div
v-else-if="section.key === 'connections'" v-else-if="activeSection.key === 'connections'"
class="placeholder-panel" class="placeholder-panel"
> >
<strong>{{ t('organizationSettings.sections.connections.placeholderTitle') }}</strong> <strong>{{ t('organizationSettings.sections.connections.placeholderTitle') }}</strong>
@@ -179,7 +210,7 @@
</div> </div>
<div <div
v-else-if="section.key === 'workspaces'" v-else-if="activeSection.key === 'workspaces'"
class="table-list" class="table-list"
> >
<button <button
@@ -203,28 +234,8 @@
</div> </div>
</div> </div>
</article> </article>
<article class="settings-section permissions-section">
<div class="section-heading">
<span class="section-icon">
<v-icon :icon="mdiCogOutline" />
</span>
<div>
<h2>{{ t('organizationSettings.permissions.title') }}</h2>
<p>{{ t('organizationSettings.permissions.description') }}</p>
</div> </div>
</div> </div>
<div class="permission-grid">
<span
v-for="permission in Object.values(organizationPermissions)"
:key="permission"
:class="{ enabled: hasPermission(permission) }"
>
{{ t(`organizationSettings.permissions.items.${permission}`) }}
</span>
</div>
</article>
</div>
</section> </section>
</template> </template>
@@ -233,12 +244,6 @@
@apply mx-auto flex w-full max-w-6xl flex-col gap-6 px-5 py-8 md:px-8; @apply mx-auto flex w-full max-w-6xl flex-col gap-6 px-5 py-8 md:px-8;
} }
.settings-hero {
@apply grid gap-4 rounded-[1.25rem] border p-6 md:grid-cols-[minmax(0,1fr)_auto] md:items-end md:p-8;
background: rgba(255, 255, 255, 0.94);
border-color: rgba(23, 32, 51, 0.08);
}
.eyebrow { .eyebrow {
@apply text-xs font-bold uppercase tracking-[0.2em]; @apply text-xs font-bold uppercase tracking-[0.2em];
color: #c2410c; color: #c2410c;
@@ -250,7 +255,6 @@
} }
.settings-hero p, .settings-hero p,
.settings-summary span,
.section-heading p, .section-heading p,
.detail-list span, .detail-list span,
.table-row span, .table-row span,
@@ -260,45 +264,53 @@
color: #526178; color: #526178;
} }
.settings-summary { .settings-page {
@apply flex flex-col gap-1 rounded-[1rem] px-4 py-3; @apply flex flex-col gap-5;
background: rgba(23, 32, 51, 0.05);
} }
.settings-summary strong { .settings-tabs {
@apply text-sm; @apply flex flex-wrap gap-2 border-b pb-3;
color: #172033; border-color: rgba(23, 32, 51, 0.1);
} }
.settings-grid { .settings-tab {
@apply grid gap-4 lg:grid-cols-2; @apply inline-flex h-10 items-center gap-2 rounded-[0.75rem] px-3 text-sm font-semibold transition-colors;
color: #526178;
} }
.settings-section { .settings-tab:hover {
@apply flex flex-col gap-5 rounded-[1.25rem] border p-5;
background: rgba(255, 255, 255, 0.94);
border-color: rgba(23, 32, 51, 0.08);
}
.permissions-section {
@apply lg:col-span-2;
}
.section-heading {
@apply flex gap-4;
}
.section-icon {
@apply flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-[1rem];
background: rgba(23, 32, 51, 0.06); background: rgba(23, 32, 51, 0.06);
color: #172033; color: #172033;
} }
.settings-tab-active {
background: #172033;
color: #fffaf2;
}
.settings-tab :deep(.v-icon) {
@apply text-lg;
}
.settings-content {
@apply flex flex-col gap-4;
}
.section-heading {
@apply flex flex-col gap-1;
}
.section-heading h2 { .section-heading h2 {
@apply text-xl font-black; @apply text-2xl font-black;
color: #172033; color: #172033;
} }
.content-card {
@apply rounded-[0.75rem] border p-5;
background: rgba(255, 255, 255, 0.94);
border-color: rgba(23, 32, 51, 0.08);
}
.detail-list, .detail-list,
.table-list { .table-list {
@apply flex flex-col gap-2; @apply flex flex-col gap-2;
@@ -306,7 +318,7 @@
.detail-list div, .detail-list div,
.table-row { .table-row {
@apply flex items-center justify-between gap-4 rounded-[1rem] px-4 py-3; @apply flex items-center justify-between gap-4 rounded-[0.75rem] px-4 py-3;
background: rgba(23, 32, 51, 0.04); background: rgba(23, 32, 51, 0.04);
} }
@@ -338,12 +350,17 @@
color: #c2410c; color: #c2410c;
} }
.permissions-panel,
.placeholder-panel, .placeholder-panel,
.empty-state { .empty-state {
@apply rounded-[1rem] px-4 py-4; @apply rounded-[0.75rem] px-4 py-4;
background: rgba(23, 32, 51, 0.04); background: rgba(23, 32, 51, 0.04);
} }
.permissions-panel {
@apply flex-col items-start gap-3;
}
.placeholder-panel { .placeholder-panel {
@apply flex flex-col gap-1; @apply flex flex-col gap-1;
} }

View File

@@ -171,7 +171,7 @@
<span class="organization-mark">{{ organization.name.slice(0, 1).toUpperCase() }}</span> <span class="organization-mark">{{ organization.name.slice(0, 1).toUpperCase() }}</span>
<span class="user-menu-item-copy"> <span class="user-menu-item-copy">
<span>{{ organization.name }}</span> <span>{{ organization.name }}</span>
<small>{{ organization.slug }}</small> <small>{{ t('workspaceSelector.organizationLabel') }}</small>
</span> </span>
</button> </button>

View File

@@ -72,10 +72,8 @@
"title": "Organization settings", "title": "Organization settings",
"description": "Manage the SaaS account boundary for members, billing access, connections, and owned workspaces.", "description": "Manage the SaaS account boundary for members, billing access, connections, and owned workspaces.",
"loading": "Loading organization settings...", "loading": "Loading organization settings...",
"slugLabel": "Account slug",
"fields": { "fields": {
"name": "Name", "name": "Name",
"slug": "Slug",
"createdAt": "Created" "createdAt": "Created"
}, },
"sections": { "sections": {

View File

@@ -72,10 +72,8 @@
"title": "Parametres de l'organisation", "title": "Parametres de l'organisation",
"description": "Gerez le compte SaaS pour les membres, la facturation, les connexions et les espaces detenus.", "description": "Gerez le compte SaaS pour les membres, la facturation, les connexions et les espaces detenus.",
"loading": "Chargement des parametres de l'organisation...", "loading": "Chargement des parametres de l'organisation...",
"slugLabel": "Slug du compte",
"fields": { "fields": {
"name": "Nom", "name": "Nom",
"slug": "Slug",
"createdAt": "Cree" "createdAt": "Cree"
}, },
"sections": { "sections": {

View File

@@ -3225,9 +3225,6 @@
"name": { "name": {
"type": "string" "type": "string"
}, },
"slug": {
"type": "string"
},
"ownerUserId": { "ownerUserId": {
"type": "string", "type": "string",
"format": "guid" "format": "guid"