Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 24d1e472a2 | |||
| da1b210865 | |||
| eadf630c61 | |||
| 4fb073a1ff | |||
| 9ddfa0c3c7 | |||
| a92e188f84 | |||
| dcf181d640 | |||
| 1a8556df68 | |||
| a5f0c41cba | |||
| 268093d223 | |||
| c64a7b8d44 | |||
| 0b368b09fa | |||
| 212dd1c435 | |||
| 69af324b1b | |||
| 5758074f6f | |||
| 5b9e14b442 | |||
| 618e3e84be |
File diff suppressed because it is too large
Load Diff
@@ -2,8 +2,10 @@ package bootstrap
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -58,6 +60,10 @@ func TestEnsureBootstrapPOSIXSkeletonInitializesEmptyRoot(t *testing.T) {
|
||||
filepath.Join(rootPath, "users", "settings.json"),
|
||||
filepath.Join(rootPath, "users", "data.json"),
|
||||
filepath.Join(rootPath, "users", "personals"),
|
||||
filepath.Join(rootPath, "users", "personals", "personal-ronald", "settings.json"),
|
||||
filepath.Join(rootPath, "users", "personals", "personal-ronald", "layout.json"),
|
||||
filepath.Join(rootPath, "users", "personals", "personal-ronald", "home.json"),
|
||||
filepath.Join(rootPath, "users", "personals", "personal-ronald", "tree"),
|
||||
}
|
||||
|
||||
for _, path := range requiredPaths {
|
||||
@@ -101,6 +107,459 @@ func TestEnsureBootstrapPOSIXSkeletonInitializesEmptyRoot(t *testing.T) {
|
||||
if usersSettings["primaryAdminId"] != "admin-1" {
|
||||
t.Fatalf("expected primary admin id admin-1, got %#v", usersSettings["primaryAdminId"])
|
||||
}
|
||||
|
||||
personalSettings := readJSONFileForTest[map[string]any](t, filepath.Join(rootPath, "users", "personals", "personal-ronald", "settings.json"))
|
||||
if personalSettings["type"] != "personal" {
|
||||
t.Fatalf("expected personal settings type personal, got %#v", personalSettings["type"])
|
||||
}
|
||||
if personalSettings["name"] != "Ronald" {
|
||||
t.Fatalf("expected personal name Ronald, got %#v", personalSettings["name"])
|
||||
}
|
||||
if personalSettings["slug"] != "ronald" {
|
||||
t.Fatalf("expected personal slug ronald, got %#v", personalSettings["slug"])
|
||||
}
|
||||
|
||||
personalHome := readJSONFileForTest[map[string]any](t, filepath.Join(rootPath, "users", "personals", "personal-ronald", "home.json"))
|
||||
if personalHome["type"] != "personal-home" {
|
||||
t.Fatalf("expected personal home type personal-home, got %#v", personalHome["type"])
|
||||
}
|
||||
if personalHome["title"] != "Ronald's Home" {
|
||||
t.Fatalf("expected personal home title Ronald's Home, got %#v", personalHome["title"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateProjectHierarchyFolderOnDiskCreatesExpectedFolderShape(t *testing.T) {
|
||||
rootPath := filepath.Join(t.TempDir(), "POSIX")
|
||||
service := NewService(nil, rootPath)
|
||||
|
||||
err := service.ensureBootstrapPOSIXSkeleton(
|
||||
InstallationRecord{ID: "installation-1", Name: "MangoPig", Mode: "personal", Access: "local", Protocol: "http", Host: "localhost", IsBootstrapped: true},
|
||||
AdminSummary{ID: "admin-1", Email: "ronald@example.com", DisplayName: "Ronald"},
|
||||
namedRecord{ID: "org-1", Name: "Primary Organization", Slug: "primary-organization"},
|
||||
namedRecord{ID: "dept-1", Name: "Primary Department", Slug: "primary-department"},
|
||||
namedRecord{ID: "team-1", Name: "Primary Team", Slug: "primary-team"},
|
||||
namedRecord{ID: "project-1", Name: "Primary Project", Slug: "primary-project"},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("ensure bootstrap POSIX skeleton: %v", err)
|
||||
}
|
||||
|
||||
createdPath, createdSlug, err := service.createProjectHierarchyFolderOnDisk("primary-project", "", "Design System")
|
||||
if err != nil {
|
||||
t.Fatalf("createProjectHierarchyFolderOnDisk root folder: %v", err)
|
||||
}
|
||||
if createdPath != "projects/project-primary-project/children/folder-design-system" {
|
||||
t.Fatalf("unexpected created path: %s", createdPath)
|
||||
}
|
||||
if createdSlug != "design-system" {
|
||||
t.Fatalf("unexpected created slug: %s", createdSlug)
|
||||
}
|
||||
|
||||
createdFolderPath := filepath.Join(rootPath, "projects", "project-primary-project", "children", "folder-design-system")
|
||||
for _, path := range []string{
|
||||
filepath.Join(createdFolderPath, "folder.json"),
|
||||
filepath.Join(createdFolderPath, "acl.json"),
|
||||
filepath.Join(createdFolderPath, "children"),
|
||||
} {
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
t.Fatalf("expected path to exist %s: %v", path, err)
|
||||
}
|
||||
}
|
||||
|
||||
folderPayload := readJSONFileForTest[map[string]any](t, filepath.Join(createdFolderPath, "folder.json"))
|
||||
if strings.TrimSpace(asStringForTest(folderPayload["id"])) == "" {
|
||||
t.Fatalf("expected created folder to have stable id, got %#v", folderPayload["id"])
|
||||
}
|
||||
if folderPayload["name"] != "Design System" {
|
||||
t.Fatalf("expected folder name Design System, got %#v", folderPayload["name"])
|
||||
}
|
||||
if folderPayload["slug"] != "design-system" {
|
||||
t.Fatalf("expected folder slug design-system, got %#v", folderPayload["slug"])
|
||||
}
|
||||
|
||||
nestedPath, nestedSlug, err := service.createProjectHierarchyFolderOnDisk("primary-project", createdPath, "Research")
|
||||
if err != nil {
|
||||
t.Fatalf("createProjectHierarchyFolderOnDisk nested folder: %v", err)
|
||||
}
|
||||
if nestedPath != "projects/project-primary-project/children/folder-design-system/children/folder-research" {
|
||||
t.Fatalf("unexpected nested path: %s", nestedPath)
|
||||
}
|
||||
if nestedSlug != "research" {
|
||||
t.Fatalf("unexpected nested slug: %s", nestedSlug)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateProjectTreeFolderOnDiskCreatesExpectedFolderShape(t *testing.T) {
|
||||
rootPath := filepath.Join(t.TempDir(), "POSIX")
|
||||
service := NewService(nil, rootPath)
|
||||
|
||||
err := service.ensureBootstrapPOSIXSkeleton(
|
||||
InstallationRecord{ID: "installation-1", Name: "MangoPig", Mode: "personal", Access: "local", Protocol: "http", Host: "localhost", IsBootstrapped: true},
|
||||
AdminSummary{ID: "admin-1", Email: "ronald@example.com", DisplayName: "Ronald"},
|
||||
namedRecord{ID: "org-1", Name: "Primary Organization", Slug: "primary-organization"},
|
||||
namedRecord{ID: "dept-1", Name: "Primary Department", Slug: "primary-department"},
|
||||
namedRecord{ID: "team-1", Name: "Primary Team", Slug: "primary-team"},
|
||||
namedRecord{ID: "project-1", Name: "Primary Project", Slug: "primary-project"},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("ensure bootstrap POSIX skeleton: %v", err)
|
||||
}
|
||||
|
||||
createdPath, createdSlug, err := service.createProjectTreeFolderOnDisk("primary-project", "", "Docs")
|
||||
if err != nil {
|
||||
t.Fatalf("createProjectTreeFolderOnDisk root folder: %v", err)
|
||||
}
|
||||
if createdPath != "projects/project-primary-project/tree/folder-docs" {
|
||||
t.Fatalf("unexpected created path: %s", createdPath)
|
||||
}
|
||||
if createdSlug != "docs" {
|
||||
t.Fatalf("unexpected created slug: %s", createdSlug)
|
||||
}
|
||||
|
||||
createdFolderPath := filepath.Join(rootPath, "projects", "project-primary-project", "tree", "folder-docs")
|
||||
for _, path := range []string{
|
||||
filepath.Join(createdFolderPath, "folder.json"),
|
||||
filepath.Join(createdFolderPath, "acl.json"),
|
||||
filepath.Join(createdFolderPath, "children"),
|
||||
} {
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
t.Fatalf("expected path to exist %s: %v", path, err)
|
||||
}
|
||||
}
|
||||
|
||||
nestedPath, nestedSlug, err := service.createProjectTreeFolderOnDisk("primary-project", createdPath, "Research")
|
||||
if err != nil {
|
||||
t.Fatalf("createProjectTreeFolderOnDisk nested folder: %v", err)
|
||||
}
|
||||
if nestedPath != "projects/project-primary-project/tree/folder-docs/children/folder-research" {
|
||||
t.Fatalf("unexpected nested path: %s", nestedPath)
|
||||
}
|
||||
if nestedSlug != "research" {
|
||||
t.Fatalf("unexpected nested slug: %s", nestedSlug)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenameProjectHierarchyFolderOnDiskRenamesFolderShape(t *testing.T) {
|
||||
rootPath := filepath.Join(t.TempDir(), "POSIX")
|
||||
service := NewService(nil, rootPath)
|
||||
|
||||
err := service.ensureBootstrapPOSIXSkeleton(
|
||||
InstallationRecord{ID: "installation-1", Name: "MangoPig", Mode: "personal", Access: "local", Protocol: "http", Host: "localhost", IsBootstrapped: true},
|
||||
AdminSummary{ID: "admin-1", Email: "ronald@example.com", DisplayName: "Ronald"},
|
||||
namedRecord{ID: "org-1", Name: "Primary Organization", Slug: "primary-organization"},
|
||||
namedRecord{ID: "dept-1", Name: "Primary Department", Slug: "primary-department"},
|
||||
namedRecord{ID: "team-1", Name: "Primary Team", Slug: "primary-team"},
|
||||
namedRecord{ID: "project-1", Name: "Primary Project", Slug: "primary-project"},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("ensure bootstrap POSIX skeleton: %v", err)
|
||||
}
|
||||
|
||||
createdPath, _, err := service.createProjectHierarchyFolderOnDisk("primary-project", "", "Design System")
|
||||
if err != nil {
|
||||
t.Fatalf("createProjectHierarchyFolderOnDisk root folder: %v", err)
|
||||
}
|
||||
|
||||
nestedPath, _, err := service.createProjectHierarchyFolderOnDisk("primary-project", createdPath, "Research")
|
||||
if err != nil {
|
||||
t.Fatalf("createProjectHierarchyFolderOnDisk nested folder: %v", err)
|
||||
}
|
||||
|
||||
previousPath, renamedPath, err := service.renameProjectHierarchyFolderOnDisk("primary-project", createdPath, "Platform Design")
|
||||
if err != nil {
|
||||
t.Fatalf("renameProjectHierarchyFolderOnDisk: %v", err)
|
||||
}
|
||||
if previousPath != createdPath {
|
||||
t.Fatalf("expected previous path %s, got %s", createdPath, previousPath)
|
||||
}
|
||||
if renamedPath != "projects/project-primary-project/children/folder-platform-design" {
|
||||
t.Fatalf("unexpected renamed path: %s", renamedPath)
|
||||
}
|
||||
|
||||
if _, err := os.Stat(filepath.Join(rootPath, filepath.FromSlash(createdPath))); !os.IsNotExist(err) {
|
||||
t.Fatalf("expected previous folder path to be gone, got err=%v", err)
|
||||
}
|
||||
|
||||
renamedFolderPath := filepath.Join(rootPath, filepath.FromSlash(renamedPath))
|
||||
if _, err := os.Stat(filepath.Join(renamedFolderPath, "children", filepath.Base(nestedPath))); err != nil {
|
||||
t.Fatalf("expected nested child folder to move with renamed parent: %v", err)
|
||||
}
|
||||
|
||||
folderPayload := readJSONFileForTest[map[string]any](t, filepath.Join(renamedFolderPath, "folder.json"))
|
||||
if strings.TrimSpace(asStringForTest(folderPayload["id"])) == "" {
|
||||
t.Fatalf("expected renamed folder to preserve stable id, got %#v", folderPayload["id"])
|
||||
}
|
||||
if folderPayload["name"] != "Platform Design" {
|
||||
t.Fatalf("expected renamed folder name Platform Design, got %#v", folderPayload["name"])
|
||||
}
|
||||
if folderPayload["slug"] != "platform-design" {
|
||||
t.Fatalf("expected renamed folder slug platform-design, got %#v", folderPayload["slug"])
|
||||
}
|
||||
if folderPayload["type"] != "folder" {
|
||||
t.Fatalf("expected renamed folder type folder, got %#v", folderPayload["type"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenameProjectTreeFolderOnDiskRenamesFolderShape(t *testing.T) {
|
||||
rootPath := filepath.Join(t.TempDir(), "POSIX")
|
||||
service := NewService(nil, rootPath)
|
||||
|
||||
err := service.ensureBootstrapPOSIXSkeleton(
|
||||
InstallationRecord{ID: "installation-1", Name: "MangoPig", Mode: "personal", Access: "local", Protocol: "http", Host: "localhost", IsBootstrapped: true},
|
||||
AdminSummary{ID: "admin-1", Email: "ronald@example.com", DisplayName: "Ronald"},
|
||||
namedRecord{ID: "org-1", Name: "Primary Organization", Slug: "primary-organization"},
|
||||
namedRecord{ID: "dept-1", Name: "Primary Department", Slug: "primary-department"},
|
||||
namedRecord{ID: "team-1", Name: "Primary Team", Slug: "primary-team"},
|
||||
namedRecord{ID: "project-1", Name: "Primary Project", Slug: "primary-project"},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("ensure bootstrap POSIX skeleton: %v", err)
|
||||
}
|
||||
|
||||
createdPath, _, err := service.createProjectTreeFolderOnDisk("primary-project", "", "Docs")
|
||||
if err != nil {
|
||||
t.Fatalf("createProjectTreeFolderOnDisk root folder: %v", err)
|
||||
}
|
||||
|
||||
previousPath, renamedPath, err := service.renameProjectTreeFolderOnDisk("primary-project", createdPath, "Specifications")
|
||||
if err != nil {
|
||||
t.Fatalf("renameProjectTreeFolderOnDisk: %v", err)
|
||||
}
|
||||
if previousPath != createdPath {
|
||||
t.Fatalf("expected previous path %s, got %s", createdPath, previousPath)
|
||||
}
|
||||
if renamedPath != "projects/project-primary-project/tree/folder-specifications" {
|
||||
t.Fatalf("unexpected renamed path: %s", renamedPath)
|
||||
}
|
||||
|
||||
folderPayload := readJSONFileForTest[map[string]any](t, filepath.Join(rootPath, filepath.FromSlash(renamedPath), "folder.json"))
|
||||
if folderPayload["name"] != "Specifications" {
|
||||
t.Fatalf("expected renamed folder name Specifications, got %#v", folderPayload["name"])
|
||||
}
|
||||
if folderPayload["slug"] != "specifications" {
|
||||
t.Fatalf("expected renamed folder slug specifications, got %#v", folderPayload["slug"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestMoveProjectHierarchyFolderOnDiskMovesFolderToNewParent(t *testing.T) {
|
||||
rootPath := filepath.Join(t.TempDir(), "POSIX")
|
||||
service := NewService(nil, rootPath)
|
||||
|
||||
err := service.ensureBootstrapPOSIXSkeleton(
|
||||
InstallationRecord{ID: "installation-1", Name: "MangoPig", Mode: "personal", Access: "local", Protocol: "http", Host: "localhost", IsBootstrapped: true},
|
||||
AdminSummary{ID: "admin-1", Email: "ronald@example.com", DisplayName: "Ronald"},
|
||||
namedRecord{ID: "org-1", Name: "Primary Organization", Slug: "primary-organization"},
|
||||
namedRecord{ID: "dept-1", Name: "Primary Department", Slug: "primary-department"},
|
||||
namedRecord{ID: "team-1", Name: "Primary Team", Slug: "primary-team"},
|
||||
namedRecord{ID: "project-1", Name: "Primary Project", Slug: "primary-project"},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("ensure bootstrap POSIX skeleton: %v", err)
|
||||
}
|
||||
|
||||
designPath, _, err := service.createProjectHierarchyFolderOnDisk("primary-project", "", "Design")
|
||||
if err != nil {
|
||||
t.Fatalf("create design folder: %v", err)
|
||||
}
|
||||
operationsPath, _, err := service.createProjectHierarchyFolderOnDisk("primary-project", "", "Operations")
|
||||
if err != nil {
|
||||
t.Fatalf("create operations folder: %v", err)
|
||||
}
|
||||
researchPath, _, err := service.createProjectHierarchyFolderOnDisk("primary-project", designPath, "Research")
|
||||
if err != nil {
|
||||
t.Fatalf("create research folder: %v", err)
|
||||
}
|
||||
nestedPath, _, err := service.createProjectHierarchyFolderOnDisk("primary-project", researchPath, "Interview Notes")
|
||||
if err != nil {
|
||||
t.Fatalf("create nested folder: %v", err)
|
||||
}
|
||||
|
||||
previousPath, movedPath, err := service.moveProjectHierarchyFolderOnDisk("primary-project", researchPath, operationsPath)
|
||||
if err != nil {
|
||||
t.Fatalf("moveProjectHierarchyFolderOnDisk: %v", err)
|
||||
}
|
||||
if previousPath != researchPath {
|
||||
t.Fatalf("expected previous path %s, got %s", researchPath, previousPath)
|
||||
}
|
||||
if movedPath != "projects/project-primary-project/children/folder-operations/children/folder-research" {
|
||||
t.Fatalf("unexpected moved path: %s", movedPath)
|
||||
}
|
||||
|
||||
if _, err := os.Stat(filepath.Join(rootPath, filepath.FromSlash(researchPath))); !os.IsNotExist(err) {
|
||||
t.Fatalf("expected previous folder path to be gone, got err=%v", err)
|
||||
}
|
||||
|
||||
movedFolderPath := filepath.Join(rootPath, filepath.FromSlash(movedPath))
|
||||
if _, err := os.Stat(filepath.Join(movedFolderPath, "children", filepath.Base(nestedPath))); err != nil {
|
||||
t.Fatalf("expected nested child folder to move with moved parent: %v", err)
|
||||
}
|
||||
|
||||
folderPayload := readJSONFileForTest[map[string]any](t, filepath.Join(movedFolderPath, "folder.json"))
|
||||
if strings.TrimSpace(asStringForTest(folderPayload["id"])) == "" {
|
||||
t.Fatalf("expected moved folder to preserve stable id, got %#v", folderPayload["id"])
|
||||
}
|
||||
if folderPayload["name"] != "Research" {
|
||||
t.Fatalf("expected moved folder name Research, got %#v", folderPayload["name"])
|
||||
}
|
||||
if folderPayload["slug"] != "research" {
|
||||
t.Fatalf("expected moved folder slug research, got %#v", folderPayload["slug"])
|
||||
}
|
||||
if folderPayload["type"] != "folder" {
|
||||
t.Fatalf("expected moved folder type folder, got %#v", folderPayload["type"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestMoveProjectTreeFolderOnDiskMovesFolderToNewParent(t *testing.T) {
|
||||
rootPath := filepath.Join(t.TempDir(), "POSIX")
|
||||
service := NewService(nil, rootPath)
|
||||
|
||||
err := service.ensureBootstrapPOSIXSkeleton(
|
||||
InstallationRecord{ID: "installation-1", Name: "MangoPig", Mode: "personal", Access: "local", Protocol: "http", Host: "localhost", IsBootstrapped: true},
|
||||
AdminSummary{ID: "admin-1", Email: "ronald@example.com", DisplayName: "Ronald"},
|
||||
namedRecord{ID: "org-1", Name: "Primary Organization", Slug: "primary-organization"},
|
||||
namedRecord{ID: "dept-1", Name: "Primary Department", Slug: "primary-department"},
|
||||
namedRecord{ID: "team-1", Name: "Primary Team", Slug: "primary-team"},
|
||||
namedRecord{ID: "project-1", Name: "Primary Project", Slug: "primary-project"},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("ensure bootstrap POSIX skeleton: %v", err)
|
||||
}
|
||||
|
||||
docsPath, _, err := service.createProjectTreeFolderOnDisk("primary-project", "", "Docs")
|
||||
if err != nil {
|
||||
t.Fatalf("create docs folder: %v", err)
|
||||
}
|
||||
archivePath, _, err := service.createProjectTreeFolderOnDisk("primary-project", "", "Archive")
|
||||
if err != nil {
|
||||
t.Fatalf("create archive folder: %v", err)
|
||||
}
|
||||
|
||||
previousPath, movedPath, err := service.moveProjectTreeFolderOnDisk("primary-project", docsPath, archivePath)
|
||||
if err != nil {
|
||||
t.Fatalf("moveProjectTreeFolderOnDisk: %v", err)
|
||||
}
|
||||
if previousPath != docsPath {
|
||||
t.Fatalf("expected previous path %s, got %s", docsPath, previousPath)
|
||||
}
|
||||
if movedPath != "projects/project-primary-project/tree/folder-archive/children/folder-docs" {
|
||||
t.Fatalf("unexpected moved path: %s", movedPath)
|
||||
}
|
||||
|
||||
folderPayload := readJSONFileForTest[map[string]any](t, filepath.Join(rootPath, filepath.FromSlash(movedPath), "folder.json"))
|
||||
if folderPayload["name"] != "Docs" {
|
||||
t.Fatalf("expected moved folder name Docs, got %#v", folderPayload["name"])
|
||||
}
|
||||
if folderPayload["slug"] != "docs" {
|
||||
t.Fatalf("expected moved folder slug docs, got %#v", folderPayload["slug"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestMoveProjectHierarchyFolderOnDiskRejectsDescendantTarget(t *testing.T) {
|
||||
rootPath := filepath.Join(t.TempDir(), "POSIX")
|
||||
service := NewService(nil, rootPath)
|
||||
|
||||
err := service.ensureBootstrapPOSIXSkeleton(
|
||||
InstallationRecord{ID: "installation-1", Name: "MangoPig", Mode: "personal", Access: "local", Protocol: "http", Host: "localhost", IsBootstrapped: true},
|
||||
AdminSummary{ID: "admin-1", Email: "ronald@example.com", DisplayName: "Ronald"},
|
||||
namedRecord{ID: "org-1", Name: "Primary Organization", Slug: "primary-organization"},
|
||||
namedRecord{ID: "dept-1", Name: "Primary Department", Slug: "primary-department"},
|
||||
namedRecord{ID: "team-1", Name: "Primary Team", Slug: "primary-team"},
|
||||
namedRecord{ID: "project-1", Name: "Primary Project", Slug: "primary-project"},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("ensure bootstrap POSIX skeleton: %v", err)
|
||||
}
|
||||
|
||||
parentPath, _, err := service.createProjectHierarchyFolderOnDisk("primary-project", "", "Parent")
|
||||
if err != nil {
|
||||
t.Fatalf("create parent folder: %v", err)
|
||||
}
|
||||
childPath, _, err := service.createProjectHierarchyFolderOnDisk("primary-project", parentPath, "Child")
|
||||
if err != nil {
|
||||
t.Fatalf("create child folder: %v", err)
|
||||
}
|
||||
|
||||
_, _, err = service.moveProjectHierarchyFolderOnDisk("primary-project", parentPath, childPath)
|
||||
if !errors.Is(err, ErrInvalidProjectFolderMove) {
|
||||
t.Fatalf("expected ErrInvalidProjectFolderMove, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildProjectHierarchyFolderTreeBuildsNestedStructure(t *testing.T) {
|
||||
rows := []projectHierarchyFolderRow{
|
||||
{ID: "folder-design-id", Path: "projects/project-primary-project/children/folder-design", ParentPath: projectHierarchyRootPath("primary-project"), Label: "Design"},
|
||||
{ID: "folder-research-id", Path: "projects/project-primary-project/children/folder-design/children/folder-research", ParentPath: "projects/project-primary-project/children/folder-design/children", Label: "Research"},
|
||||
{ID: "folder-ops-id", Path: "projects/project-primary-project/children/folder-ops", ParentPath: projectHierarchyRootPath("primary-project"), Label: "Ops"},
|
||||
}
|
||||
|
||||
folders := buildProjectHierarchyFolderTree(rows, projectHierarchyRootPath("primary-project"))
|
||||
if len(folders) != 2 {
|
||||
t.Fatalf("expected 2 top-level folders, got %d", len(folders))
|
||||
}
|
||||
if folders[0].Label != "Design" || folders[1].Label != "Ops" {
|
||||
t.Fatalf("unexpected top-level folder labels: %#v", folders)
|
||||
}
|
||||
if len(folders[0].Children) != 1 || folders[0].Children[0].Label != "Research" {
|
||||
t.Fatalf("unexpected nested folder structure: %#v", folders[0].Children)
|
||||
}
|
||||
if folders[0].ID != "folder-design-id" || folders[0].Path != "projects/project-primary-project/children/folder-design" {
|
||||
t.Fatalf("expected design folder to retain stable id/path, got %#v", folders[0])
|
||||
}
|
||||
if folders[0].Children[0].ID != "folder-research-id" || folders[1].ID != "folder-ops-id" {
|
||||
t.Fatalf("expected nested/top-level folder ids to be preserved, got %#v / %#v", folders[0].Children[0], folders[1])
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplyProjectHierarchyFolderOrderingOrdersRootAndChildrenByStableID(t *testing.T) {
|
||||
folders := []ProjectHierarchyFolderRecord{
|
||||
{
|
||||
ID: "folder-design-id",
|
||||
Path: "projects/project-primary-project/children/folder-design",
|
||||
Label: "Design",
|
||||
Children: []ProjectHierarchyFolderRecord{
|
||||
{ID: "folder-research-id", Path: "projects/project-primary-project/children/folder-design/children/folder-research", Label: "Research"},
|
||||
{ID: "folder-assets-id", Path: "projects/project-primary-project/children/folder-design/children/folder-assets", Label: "Assets"},
|
||||
},
|
||||
},
|
||||
{ID: "folder-ops-id", Path: "projects/project-primary-project/children/folder-ops", Label: "Ops"},
|
||||
{ID: "folder-qa-id", Path: "projects/project-primary-project/children/folder-qa", Label: "QA"},
|
||||
}
|
||||
|
||||
ordered := applyProjectHierarchyFolderOrdering(folders, map[string][]string{
|
||||
projectFolderOrderRootKey: {"folder-qa-id", "folder-design-id"},
|
||||
"folder-design-id": {"folder-assets-id", "folder-research-id"},
|
||||
})
|
||||
|
||||
if len(ordered) != 3 {
|
||||
t.Fatalf("expected 3 ordered root folders, got %d", len(ordered))
|
||||
}
|
||||
if ordered[0].ID != "folder-qa-id" || ordered[1].ID != "folder-design-id" || ordered[2].ID != "folder-ops-id" {
|
||||
t.Fatalf("unexpected ordered root ids: %#v", ordered)
|
||||
}
|
||||
if len(ordered[1].Children) != 2 {
|
||||
t.Fatalf("expected design folder children to be preserved, got %#v", ordered[1].Children)
|
||||
}
|
||||
if ordered[1].Children[0].ID != "folder-assets-id" || ordered[1].Children[1].ID != "folder-research-id" {
|
||||
t.Fatalf("unexpected ordered child ids: %#v", ordered[1].Children)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInsertFolderOrderReordersWithinSameParent(t *testing.T) {
|
||||
folderOrder := map[string][]string{
|
||||
projectFolderOrderRootKey: {"folder-a", "folder-b", "folder-c"},
|
||||
}
|
||||
|
||||
insertFolderOrder(folderOrder, "", "folder-c", 0)
|
||||
|
||||
got := folderOrder[projectFolderOrderRootKey]
|
||||
if len(got) != 3 || got[0] != "folder-c" || got[1] != "folder-a" || got[2] != "folder-b" {
|
||||
t.Fatalf("unexpected reordered root children: %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func asStringForTest(value any) string {
|
||||
text, _ := value.(string)
|
||||
return text
|
||||
}
|
||||
|
||||
func readJSONFileForTest[T any](t *testing.T, path string) T {
|
||||
|
||||
@@ -0,0 +1,485 @@
|
||||
package httpx
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
bootstrapservice "moku-backend/internal/bootstrap"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
type createProjectFolderRequest struct {
|
||||
Name string `json:"name"`
|
||||
ParentFolderID string `json:"parentFolderId"`
|
||||
}
|
||||
|
||||
type renameProjectFolderRequest struct {
|
||||
FolderID string `json:"folderId"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type deleteProjectFolderRequest struct {
|
||||
FolderID string `json:"folderId"`
|
||||
}
|
||||
|
||||
type moveProjectFolderRequest struct {
|
||||
FolderID string `json:"folderId"`
|
||||
FolderNodeID string `json:"folderNodeId"`
|
||||
ParentFolderID string `json:"parentFolderId"`
|
||||
ParentNodeID string `json:"parentNodeId"`
|
||||
TargetIndex int `json:"targetIndex"`
|
||||
}
|
||||
|
||||
func (routes apiRoutes) handleProjectFolders(w http.ResponseWriter, r *http.Request) {
|
||||
projectID := strings.TrimSpace(chi.URLParam(r, "projectId"))
|
||||
if projectID == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Project ID is required.")
|
||||
return
|
||||
}
|
||||
|
||||
folders, err := routes.bootstrapService().GetProjectHierarchyFolders(r.Context(), projectID)
|
||||
if err != nil {
|
||||
routes.writeProjectFolderError(w, r, err, "load")
|
||||
return
|
||||
}
|
||||
|
||||
WriteJSON(w, http.StatusOK, map[string]any{
|
||||
"data": map[string]any{
|
||||
"projectId": projectID,
|
||||
"folders": folders,
|
||||
},
|
||||
"meta": map[string]any{
|
||||
"resource": "project-folders",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (routes apiRoutes) handleCreateProjectFolder(w http.ResponseWriter, r *http.Request) {
|
||||
projectID := strings.TrimSpace(chi.URLParam(r, "projectId"))
|
||||
if projectID == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Project ID is required.")
|
||||
return
|
||||
}
|
||||
|
||||
payload, ok := decodeProjectFolderRequest(w, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
payload.Name = strings.TrimSpace(payload.Name)
|
||||
payload.ParentFolderID = strings.TrimSpace(payload.ParentFolderID)
|
||||
if payload.Name == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Folder name is required.")
|
||||
return
|
||||
}
|
||||
|
||||
result, err := routes.bootstrapService().CreateProjectFolder(r.Context(), bootstrapservice.CreateProjectFolderInput{
|
||||
ProjectID: projectID,
|
||||
ParentFolderID: payload.ParentFolderID,
|
||||
Name: payload.Name,
|
||||
})
|
||||
if err != nil {
|
||||
routes.writeProjectFolderError(w, r, err, "persist")
|
||||
return
|
||||
}
|
||||
|
||||
WriteJSON(w, http.StatusCreated, map[string]any{
|
||||
"data": result,
|
||||
"meta": map[string]any{
|
||||
"resource": "project-folder-create",
|
||||
"persisted": true,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (routes apiRoutes) handleDeleteProjectFolder(w http.ResponseWriter, r *http.Request) {
|
||||
projectID := strings.TrimSpace(chi.URLParam(r, "projectId"))
|
||||
if projectID == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Project ID is required.")
|
||||
return
|
||||
}
|
||||
|
||||
payload := decodeDeleteProjectFolderRequest(r)
|
||||
if strings.TrimSpace(payload.FolderID) == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Folder ID is required.")
|
||||
return
|
||||
}
|
||||
|
||||
result, err := routes.bootstrapService().DeleteProjectFolder(r.Context(), bootstrapservice.DeleteProjectFolderInput{
|
||||
ProjectID: projectID,
|
||||
FolderID: payload.FolderID,
|
||||
})
|
||||
if err != nil {
|
||||
routes.writeProjectFolderError(w, r, err, "delete")
|
||||
return
|
||||
}
|
||||
|
||||
WriteJSON(w, http.StatusOK, map[string]any{
|
||||
"data": result,
|
||||
"meta": map[string]any{
|
||||
"resource": "project-folder-delete",
|
||||
"persisted": true,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (routes apiRoutes) handleRenameProjectFolder(w http.ResponseWriter, r *http.Request) {
|
||||
projectID := strings.TrimSpace(chi.URLParam(r, "projectId"))
|
||||
if projectID == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Project ID is required.")
|
||||
return
|
||||
}
|
||||
|
||||
payload, ok := decodeRenameProjectFolderRequest(w, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
payload.FolderID = strings.TrimSpace(payload.FolderID)
|
||||
payload.Name = strings.TrimSpace(payload.Name)
|
||||
if payload.FolderID == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Folder ID is required.")
|
||||
return
|
||||
}
|
||||
if payload.Name == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Folder name is required.")
|
||||
return
|
||||
}
|
||||
|
||||
result, err := routes.bootstrapService().RenameProjectFolder(r.Context(), bootstrapservice.RenameProjectFolderInput{
|
||||
ProjectID: projectID,
|
||||
FolderID: payload.FolderID,
|
||||
Name: payload.Name,
|
||||
})
|
||||
if err != nil {
|
||||
routes.writeProjectFolderError(w, r, err, "rename")
|
||||
return
|
||||
}
|
||||
|
||||
WriteJSON(w, http.StatusOK, map[string]any{
|
||||
"data": result,
|
||||
"meta": map[string]any{
|
||||
"resource": "project-folder-rename",
|
||||
"persisted": true,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (routes apiRoutes) handleMoveProjectFolder(w http.ResponseWriter, r *http.Request) {
|
||||
projectID := strings.TrimSpace(chi.URLParam(r, "projectId"))
|
||||
if projectID == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Project ID is required.")
|
||||
return
|
||||
}
|
||||
|
||||
payload, ok := decodeMoveProjectFolderRequest(w, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
payload.FolderID = strings.TrimSpace(payload.FolderID)
|
||||
payload.FolderNodeID = strings.TrimSpace(payload.FolderNodeID)
|
||||
payload.ParentFolderID = strings.TrimSpace(payload.ParentFolderID)
|
||||
payload.ParentNodeID = strings.TrimSpace(payload.ParentNodeID)
|
||||
if payload.FolderID == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Folder ID is required.")
|
||||
return
|
||||
}
|
||||
|
||||
result, err := routes.bootstrapService().MoveProjectFolder(r.Context(), bootstrapservice.MoveProjectFolderInput{
|
||||
ProjectID: projectID,
|
||||
FolderID: payload.FolderID,
|
||||
FolderNodeID: payload.FolderNodeID,
|
||||
ParentFolderID: payload.ParentFolderID,
|
||||
ParentNodeID: payload.ParentNodeID,
|
||||
TargetIndex: payload.TargetIndex,
|
||||
})
|
||||
if err != nil {
|
||||
routes.writeProjectFolderError(w, r, err, "move")
|
||||
return
|
||||
}
|
||||
|
||||
WriteJSON(w, http.StatusOK, map[string]any{
|
||||
"data": result,
|
||||
"meta": map[string]any{
|
||||
"resource": "project-folder-move",
|
||||
"persisted": true,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (routes apiRoutes) handleProjectTreeFolders(w http.ResponseWriter, r *http.Request) {
|
||||
projectID := strings.TrimSpace(chi.URLParam(r, "projectId"))
|
||||
if projectID == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Project ID is required.")
|
||||
return
|
||||
}
|
||||
|
||||
folders, err := routes.bootstrapService().GetProjectTreeFolders(r.Context(), projectID)
|
||||
if err != nil {
|
||||
routes.writeProjectFolderError(w, r, err, "load")
|
||||
return
|
||||
}
|
||||
|
||||
WriteJSON(w, http.StatusOK, map[string]any{
|
||||
"data": map[string]any{
|
||||
"projectId": projectID,
|
||||
"folders": folders,
|
||||
},
|
||||
"meta": map[string]any{
|
||||
"resource": "project-tree-folders",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (routes apiRoutes) handleCreateProjectTreeFolder(w http.ResponseWriter, r *http.Request) {
|
||||
projectID := strings.TrimSpace(chi.URLParam(r, "projectId"))
|
||||
if projectID == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Project ID is required.")
|
||||
return
|
||||
}
|
||||
|
||||
payload, ok := decodeProjectFolderRequest(w, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
payload.Name = strings.TrimSpace(payload.Name)
|
||||
payload.ParentFolderID = strings.TrimSpace(payload.ParentFolderID)
|
||||
if payload.Name == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Folder name is required.")
|
||||
return
|
||||
}
|
||||
|
||||
result, err := routes.bootstrapService().CreateProjectTreeFolder(r.Context(), bootstrapservice.CreateProjectFolderInput{
|
||||
ProjectID: projectID,
|
||||
ParentFolderID: payload.ParentFolderID,
|
||||
Name: payload.Name,
|
||||
})
|
||||
if err != nil {
|
||||
routes.writeProjectFolderError(w, r, err, "persist")
|
||||
return
|
||||
}
|
||||
|
||||
WriteJSON(w, http.StatusCreated, map[string]any{
|
||||
"data": result,
|
||||
"meta": map[string]any{
|
||||
"resource": "project-tree-folder-create",
|
||||
"persisted": true,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (routes apiRoutes) handleDeleteProjectTreeFolder(w http.ResponseWriter, r *http.Request) {
|
||||
projectID := strings.TrimSpace(chi.URLParam(r, "projectId"))
|
||||
if projectID == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Project ID is required.")
|
||||
return
|
||||
}
|
||||
|
||||
payload := decodeDeleteProjectFolderRequest(r)
|
||||
if strings.TrimSpace(payload.FolderID) == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Folder ID is required.")
|
||||
return
|
||||
}
|
||||
|
||||
result, err := routes.bootstrapService().DeleteProjectTreeFolder(r.Context(), bootstrapservice.DeleteProjectFolderInput{
|
||||
ProjectID: projectID,
|
||||
FolderID: payload.FolderID,
|
||||
})
|
||||
if err != nil {
|
||||
routes.writeProjectFolderError(w, r, err, "delete")
|
||||
return
|
||||
}
|
||||
|
||||
WriteJSON(w, http.StatusOK, map[string]any{
|
||||
"data": result,
|
||||
"meta": map[string]any{
|
||||
"resource": "project-tree-folder-delete",
|
||||
"persisted": true,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (routes apiRoutes) handleRenameProjectTreeFolder(w http.ResponseWriter, r *http.Request) {
|
||||
projectID := strings.TrimSpace(chi.URLParam(r, "projectId"))
|
||||
if projectID == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Project ID is required.")
|
||||
return
|
||||
}
|
||||
|
||||
payload, ok := decodeRenameProjectFolderRequest(w, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
payload.FolderID = strings.TrimSpace(payload.FolderID)
|
||||
payload.Name = strings.TrimSpace(payload.Name)
|
||||
if payload.FolderID == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Folder ID is required.")
|
||||
return
|
||||
}
|
||||
if payload.Name == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Folder name is required.")
|
||||
return
|
||||
}
|
||||
|
||||
result, err := routes.bootstrapService().RenameProjectTreeFolder(r.Context(), bootstrapservice.RenameProjectFolderInput{
|
||||
ProjectID: projectID,
|
||||
FolderID: payload.FolderID,
|
||||
Name: payload.Name,
|
||||
})
|
||||
if err != nil {
|
||||
routes.writeProjectFolderError(w, r, err, "rename")
|
||||
return
|
||||
}
|
||||
|
||||
WriteJSON(w, http.StatusOK, map[string]any{
|
||||
"data": result,
|
||||
"meta": map[string]any{
|
||||
"resource": "project-tree-folder-rename",
|
||||
"persisted": true,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (routes apiRoutes) handleMoveProjectTreeFolder(w http.ResponseWriter, r *http.Request) {
|
||||
projectID := strings.TrimSpace(chi.URLParam(r, "projectId"))
|
||||
if projectID == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Project ID is required.")
|
||||
return
|
||||
}
|
||||
|
||||
payload, ok := decodeMoveProjectFolderRequest(w, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
payload.FolderID = strings.TrimSpace(payload.FolderID)
|
||||
payload.FolderNodeID = strings.TrimSpace(payload.FolderNodeID)
|
||||
payload.ParentFolderID = strings.TrimSpace(payload.ParentFolderID)
|
||||
payload.ParentNodeID = strings.TrimSpace(payload.ParentNodeID)
|
||||
if payload.FolderID == "" {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Folder ID is required.")
|
||||
return
|
||||
}
|
||||
|
||||
result, err := routes.bootstrapService().MoveProjectTreeFolder(r.Context(), bootstrapservice.MoveProjectFolderInput{
|
||||
ProjectID: projectID,
|
||||
FolderID: payload.FolderID,
|
||||
FolderNodeID: payload.FolderNodeID,
|
||||
ParentFolderID: payload.ParentFolderID,
|
||||
ParentNodeID: payload.ParentNodeID,
|
||||
TargetIndex: payload.TargetIndex,
|
||||
})
|
||||
if err != nil {
|
||||
routes.writeProjectFolderError(w, r, err, "move")
|
||||
return
|
||||
}
|
||||
|
||||
WriteJSON(w, http.StatusOK, map[string]any{
|
||||
"data": result,
|
||||
"meta": map[string]any{
|
||||
"resource": "project-tree-folder-move",
|
||||
"persisted": true,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (routes apiRoutes) writeProjectFolderError(w http.ResponseWriter, r *http.Request, err error, operation string) {
|
||||
switch {
|
||||
case errors.Is(err, bootstrapservice.ErrProjectNotFound), errors.Is(err, bootstrapservice.ErrProjectFolderNotFound):
|
||||
WriteError(w, http.StatusNotFound, RequestIDFromContext(r.Context()), "not_found", err.Error())
|
||||
case errors.Is(err, bootstrapservice.ErrInvalidProjectFolderMove):
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", err.Error())
|
||||
default:
|
||||
routes.cfg.Logger.Error(operation+" project folder", "error", err, "path", r.URL.Path)
|
||||
message := "Failed to " + operation + " project folder."
|
||||
if routes.cfg.Config.IsDevelopment() {
|
||||
message = message + " " + err.Error()
|
||||
}
|
||||
WriteError(w, http.StatusInternalServerError, RequestIDFromContext(r.Context()), "project_folder_"+operation+"_failed", message)
|
||||
}
|
||||
}
|
||||
|
||||
func decodeMoveProjectFolderRequest(w http.ResponseWriter, r *http.Request) (moveProjectFolderRequest, bool) {
|
||||
var payload moveProjectFolderRequest
|
||||
|
||||
decoder := json.NewDecoder(r.Body)
|
||||
decoder.DisallowUnknownFields()
|
||||
|
||||
if err := decoder.Decode(&payload); err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_json", "The request body is required and must be valid JSON.")
|
||||
return payload, false
|
||||
}
|
||||
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_json", "The request body must be valid JSON.")
|
||||
return payload, false
|
||||
}
|
||||
|
||||
if err := decoder.Decode(&struct{}{}); !errors.Is(err, io.EOF) {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_json", "The request body must contain a single JSON object.")
|
||||
return payload, false
|
||||
}
|
||||
|
||||
return payload, true
|
||||
}
|
||||
|
||||
func decodeDeleteProjectFolderRequest(r *http.Request) deleteProjectFolderRequest {
|
||||
return deleteProjectFolderRequest{
|
||||
FolderID: strings.TrimSpace(r.URL.Query().Get("folderId")),
|
||||
}
|
||||
}
|
||||
|
||||
func decodeRenameProjectFolderRequest(w http.ResponseWriter, r *http.Request) (renameProjectFolderRequest, bool) {
|
||||
var payload renameProjectFolderRequest
|
||||
|
||||
decoder := json.NewDecoder(r.Body)
|
||||
decoder.DisallowUnknownFields()
|
||||
|
||||
if err := decoder.Decode(&payload); err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_json", "The request body is required and must be valid JSON.")
|
||||
return payload, false
|
||||
}
|
||||
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_json", "The request body must be valid JSON.")
|
||||
return payload, false
|
||||
}
|
||||
|
||||
if err := decoder.Decode(&struct{}{}); !errors.Is(err, io.EOF) {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_json", "The request body must contain a single JSON object.")
|
||||
return payload, false
|
||||
}
|
||||
|
||||
return payload, true
|
||||
}
|
||||
|
||||
func decodeProjectFolderRequest(w http.ResponseWriter, r *http.Request) (createProjectFolderRequest, bool) {
|
||||
var payload createProjectFolderRequest
|
||||
|
||||
decoder := json.NewDecoder(r.Body)
|
||||
decoder.DisallowUnknownFields()
|
||||
|
||||
if err := decoder.Decode(&payload); err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_json", "The request body is required and must be valid JSON.")
|
||||
return payload, false
|
||||
}
|
||||
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_json", "The request body must be valid JSON.")
|
||||
return payload, false
|
||||
}
|
||||
|
||||
if err := decoder.Decode(&struct{}{}); !errors.Is(err, io.EOF) {
|
||||
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_json", "The request body must contain a single JSON object.")
|
||||
return payload, false
|
||||
}
|
||||
|
||||
return payload, true
|
||||
}
|
||||
@@ -33,6 +33,18 @@ func (routes apiRoutes) Register(router chi.Router) {
|
||||
apiRouter.Get("/app-shell", routes.handleAppShellState)
|
||||
apiRouter.Get("/organizations", routes.handleOrganizations)
|
||||
apiRouter.Get("/workspaces", routes.handleWorkspaces)
|
||||
apiRouter.Route("/projects/{projectId}", func(projectRouter chi.Router) {
|
||||
projectRouter.Get("/folders", routes.handleProjectFolders)
|
||||
projectRouter.Post("/folders", routes.handleCreateProjectFolder)
|
||||
projectRouter.Patch("/folders", routes.handleRenameProjectFolder)
|
||||
projectRouter.Patch("/folders/move", routes.handleMoveProjectFolder)
|
||||
projectRouter.Delete("/folders", routes.handleDeleteProjectFolder)
|
||||
projectRouter.Get("/tree/folders", routes.handleProjectTreeFolders)
|
||||
projectRouter.Post("/tree/folders", routes.handleCreateProjectTreeFolder)
|
||||
projectRouter.Patch("/tree/folders", routes.handleRenameProjectTreeFolder)
|
||||
projectRouter.Patch("/tree/folders/move", routes.handleMoveProjectTreeFolder)
|
||||
projectRouter.Delete("/tree/folders", routes.handleDeleteProjectTreeFolder)
|
||||
})
|
||||
|
||||
if routes.cfg.Config.IsDevelopment() {
|
||||
apiRouter.Post("/dev/bootstrap/reset", routes.handleDevelopmentBootstrapReset)
|
||||
|
||||
@@ -411,7 +411,7 @@ func classifyPath(relPath string, isDir bool) (logicalType, fileRole string) {
|
||||
return "hierarchy_folder", ""
|
||||
}
|
||||
if hasTreeAncestor && strings.HasPrefix(name, "folder-") {
|
||||
return "folder", ""
|
||||
return "hierarchy_folder", ""
|
||||
}
|
||||
if hasTreeAncestor && strings.HasPrefix(name, "item-") {
|
||||
return "item", ""
|
||||
@@ -425,7 +425,7 @@ func classifyPath(relPath string, isDir bool) (logicalType, fileRole string) {
|
||||
return "item", fileRole
|
||||
}
|
||||
if strings.HasPrefix(parentName, "folder-") {
|
||||
return "folder", fileRole
|
||||
return "hierarchy_folder", fileRole
|
||||
}
|
||||
}
|
||||
return "project", fileRole
|
||||
|
||||
@@ -16,6 +16,7 @@ func TestScanRootBuildsProjectedNodesFromBootstrapShape(t *testing.T) {
|
||||
mustMkdirAll(t, filepath.Join(root, "projects", "project-primary-project", "children", "folder-design", "children", "project-web", "children"))
|
||||
mustMkdirAll(t, filepath.Join(root, "projects", "project-primary-project", "children", "folder-design", "children", "project-web", "tree"))
|
||||
mustMkdirAll(t, filepath.Join(root, "projects", "project-primary-project", "tree"))
|
||||
mustMkdirAll(t, filepath.Join(root, "projects", "project-primary-project", "tree", "folder-docs", "children"))
|
||||
mustMkdirAll(t, filepath.Join(root, "projects", "project-primary-project", "tree", "folder-docs", "item-roadmap"))
|
||||
mustMkdirAll(t, filepath.Join(root, "users", "personals"))
|
||||
|
||||
@@ -185,10 +186,15 @@ func TestScanRootBuildsProjectedNodesFromBootstrapShape(t *testing.T) {
|
||||
}
|
||||
|
||||
treeFolder := index["projects/project-primary-project/tree/folder-docs"]
|
||||
if treeFolder.LogicalType != "folder" || treeFolder.ProjectSlug != "primary-project" {
|
||||
if treeFolder.LogicalType != "hierarchy_folder" || treeFolder.ProjectSlug != "primary-project" {
|
||||
t.Fatalf("unexpected tree folder node: %#v", treeFolder)
|
||||
}
|
||||
|
||||
treeFolderACL := index["projects/project-primary-project/tree/folder-docs/folder.json"]
|
||||
if treeFolderACL.LogicalType != "hierarchy_folder" || treeFolderACL.FileRole != "folder" {
|
||||
t.Fatalf("unexpected tree folder file classification: %#v", treeFolderACL)
|
||||
}
|
||||
|
||||
treeItem := index["projects/project-primary-project/tree/folder-docs/item-roadmap/item.json"]
|
||||
if treeItem.LogicalType != "item" || treeItem.FileRole != "item" {
|
||||
t.Fatalf("unexpected tree item classification: %#v", treeItem)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@use "../shared/tree-nav" as treeNav;
|
||||
|
||||
.root {
|
||||
display: grid;
|
||||
--project-drawer-gap: var(--space-3);
|
||||
@@ -191,142 +193,126 @@
|
||||
}
|
||||
|
||||
.treeSectionLabel {
|
||||
@include text-caption;
|
||||
margin: 0 0 var(--space-2);
|
||||
@include treeNav.section-label;
|
||||
margin: 0;
|
||||
padding: 0 var(--space-3);
|
||||
color: var(--color-text-subtle);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
.treeList {
|
||||
list-style: none;
|
||||
display: grid;
|
||||
gap: var(--space-1);
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.treeEmptySlot {
|
||||
min-height: calc(var(--control-size-lg) - var(--space-2));
|
||||
padding-left: calc(var(--space-3) + (var(--tree-depth, 0) * var(--space-4)));
|
||||
border-radius: var(--radius-lg);
|
||||
border: 1px dashed color-mix(in srgb, var(--color-border) 38%, transparent);
|
||||
opacity: 0.35;
|
||||
}
|
||||
|
||||
.treeInputRow {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
.treeSectionHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-2);
|
||||
min-height: calc(var(--control-size-lg) - var(--space-2));
|
||||
padding: var(--space-2) var(--space-3);
|
||||
padding-left: calc(var(--space-3) + (var(--tree-depth, 0) * var(--space-4)));
|
||||
border: 1px solid color-mix(in srgb, var(--color-border) 42%, transparent);
|
||||
border-radius: var(--radius-lg);
|
||||
background: color-mix(in srgb, var(--color-surface) 94%, transparent);
|
||||
margin-bottom: var(--space-2);
|
||||
padding-right: var(--space-1);
|
||||
}
|
||||
|
||||
.treeInput {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
.treeControls {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.treeControlButton {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: calc(var(--control-size-md) - var(--space-1));
|
||||
height: calc(var(--control-size-md) - var(--space-1));
|
||||
@include text-caption;
|
||||
padding: 0;
|
||||
border: 1px solid color-mix(in srgb, var(--color-border) 46%, transparent);
|
||||
border-radius: var(--radius-pill);
|
||||
background: color-mix(in srgb, var(--color-surface) 95%, transparent);
|
||||
color: var(--color-text-muted);
|
||||
transition:
|
||||
border-color 160ms var(--easing-standard),
|
||||
background 160ms var(--easing-standard),
|
||||
color 160ms var(--easing-standard);
|
||||
}
|
||||
|
||||
.treeControlButton:hover,
|
||||
.treeControlButton:focus-visible {
|
||||
border-color: color-mix(in srgb, var(--color-border-strong) 56%, transparent);
|
||||
background: var(--color-surface-hover);
|
||||
color: var(--color-text);
|
||||
font: inherit;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.treeInput::placeholder {
|
||||
color: var(--color-text-muted);
|
||||
.treeControlButton:disabled {
|
||||
opacity: 0.45;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.treeList {
|
||||
@include treeNav.tree-list;
|
||||
}
|
||||
|
||||
.treeEmptySlot {
|
||||
@include treeNav.empty-slot;
|
||||
}
|
||||
|
||||
.treeInputRow {
|
||||
@include treeNav.input-row;
|
||||
}
|
||||
|
||||
.treeInput {
|
||||
@include treeNav.input;
|
||||
}
|
||||
|
||||
.treeItem {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
grid-template-columns: auto auto minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
min-height: calc(var(--control-size-lg) - var(--space-2));
|
||||
padding: var(--space-2) var(--space-3);
|
||||
padding-left: calc(var(--space-3) + (var(--tree-depth, 0) * var(--space-4)));
|
||||
border: 1px solid transparent;
|
||||
border-radius: var(--radius-lg);
|
||||
background: transparent;
|
||||
color: var(--color-text-muted);
|
||||
transition:
|
||||
background 160ms var(--easing-standard),
|
||||
color 160ms var(--easing-standard),
|
||||
border-color 160ms var(--easing-standard),
|
||||
box-shadow 160ms var(--easing-standard),
|
||||
transform 180ms var(--easing-standard);
|
||||
text-align: left;
|
||||
@include treeNav.item;
|
||||
}
|
||||
|
||||
.treeItem:hover,
|
||||
.treeItem:focus-visible {
|
||||
background: color-mix(in srgb, var(--color-surface-hover) 80%, var(--color-accent-soft) 20%);
|
||||
color: var(--color-text);
|
||||
box-shadow: inset 0 1px 0 color-mix(in srgb, white 4%, transparent);
|
||||
@include treeNav.item-hover;
|
||||
}
|
||||
|
||||
.treeItemFolder {
|
||||
color: var(--color-text);
|
||||
@include treeNav.item-folder;
|
||||
}
|
||||
|
||||
.treeItemDragging {
|
||||
opacity: 0.45;
|
||||
transform: scale(0.985);
|
||||
box-shadow: none;
|
||||
@include treeNav.item-dragging;
|
||||
}
|
||||
|
||||
.treeItemDropBefore {
|
||||
box-shadow: inset 0 2px 0 color-mix(in srgb, var(--color-accent-strong) 78%, transparent);
|
||||
@include treeNav.item-drop-before;
|
||||
}
|
||||
|
||||
.treeItemDropAfter {
|
||||
box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--color-accent-strong) 78%, transparent);
|
||||
@include treeNav.item-drop-after;
|
||||
}
|
||||
|
||||
.treeItemDropInside {
|
||||
border-color: color-mix(in srgb, var(--color-accent-strong) 55%, transparent);
|
||||
background: color-mix(in srgb, var(--color-accent-soft) 36%, var(--color-surface));
|
||||
color: var(--color-text);
|
||||
box-shadow: inset 0 1px 0 color-mix(in srgb, white 4%, transparent);
|
||||
@include treeNav.item-drop-inside;
|
||||
}
|
||||
|
||||
.folderChevron {
|
||||
color: var(--color-text-muted);
|
||||
transition: transform 160ms var(--easing-standard);
|
||||
@include treeNav.folder-chevron;
|
||||
}
|
||||
|
||||
.folderChevronOpen {
|
||||
transform: rotate(90deg);
|
||||
@include treeNav.folder-chevron-open;
|
||||
}
|
||||
|
||||
.treeItemActive {
|
||||
border-color: var(--color-border);
|
||||
background: var(--color-surface);
|
||||
color: var(--color-text);
|
||||
box-shadow: inset 0 1px 0 color-mix(in srgb, white 4%, transparent);
|
||||
@include treeNav.item-active;
|
||||
}
|
||||
|
||||
.icon {
|
||||
color: inherit;
|
||||
opacity: 0.85;
|
||||
@include treeNav.icon;
|
||||
}
|
||||
|
||||
.label {
|
||||
@include text-label;
|
||||
min-width: 0;
|
||||
@include treeNav.label;
|
||||
}
|
||||
|
||||
.itemMeta {
|
||||
@include text-caption;
|
||||
color: var(--color-text-muted);
|
||||
@include treeNav.item-meta;
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,5 @@
|
||||
@use "../shared/tree-nav" as treeNav;
|
||||
|
||||
.sidebar {
|
||||
--sidebar-nav-item-min-height: var(--control-size-lg);
|
||||
position: relative;
|
||||
@@ -117,56 +119,25 @@
|
||||
}
|
||||
|
||||
.treeSectionLabel {
|
||||
@include text-caption;
|
||||
@include treeNav.section-label;
|
||||
margin: var(--space-3) 0 var(--space-2);
|
||||
padding: 0 var(--space-3);
|
||||
color: var(--color-text-subtle);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
.treeList {
|
||||
list-style: none;
|
||||
display: grid;
|
||||
gap: var(--space-1);
|
||||
padding: 0;
|
||||
@include treeNav.tree-list;
|
||||
}
|
||||
|
||||
.treeEmptySlot {
|
||||
min-height: calc(var(--control-size-lg) - var(--space-2));
|
||||
padding-left: calc(var(--space-3) + (var(--tree-depth, 0) * var(--space-4)));
|
||||
border-radius: var(--radius-lg);
|
||||
border: 1px dashed color-mix(in srgb, var(--color-border) 38%, transparent);
|
||||
opacity: 0.35;
|
||||
@include treeNav.empty-slot;
|
||||
}
|
||||
|
||||
.treeInputRow {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
min-height: calc(var(--control-size-lg) - var(--space-2));
|
||||
padding: var(--space-2) var(--space-3);
|
||||
padding-left: calc(var(--space-3) + (var(--tree-depth, 0) * var(--space-4)));
|
||||
border: 1px solid color-mix(in srgb, var(--color-border) 42%, transparent);
|
||||
border-radius: var(--radius-lg);
|
||||
background: color-mix(in srgb, var(--color-surface) 94%, transparent);
|
||||
@include treeNav.input-row;
|
||||
}
|
||||
|
||||
.treeInput {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--color-text);
|
||||
font: inherit;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.treeInput::placeholder {
|
||||
color: var(--color-text-muted);
|
||||
@include treeNav.input;
|
||||
}
|
||||
|
||||
.navItem {
|
||||
@@ -184,74 +155,44 @@
|
||||
}
|
||||
|
||||
.treeItem {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
grid-template-columns: auto auto minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
min-height: calc(var(--control-size-lg) - var(--space-2));
|
||||
padding: var(--space-2) var(--space-3);
|
||||
padding-left: calc(var(--space-3) + (var(--tree-depth, 0) * var(--space-4)));
|
||||
border: 1px solid transparent;
|
||||
border-radius: var(--radius-lg);
|
||||
background: transparent;
|
||||
color: var(--color-text-muted);
|
||||
text-align: left;
|
||||
transition:
|
||||
background 160ms var(--easing-standard),
|
||||
color 160ms var(--easing-standard),
|
||||
border-color 160ms var(--easing-standard),
|
||||
box-shadow 160ms var(--easing-standard),
|
||||
transform 180ms var(--easing-standard);
|
||||
@include treeNav.item;
|
||||
}
|
||||
|
||||
.treeItem:hover,
|
||||
.treeItem:focus-visible {
|
||||
background: color-mix(in srgb, var(--color-surface-hover) 80%, var(--color-accent-soft) 20%);
|
||||
color: var(--color-text);
|
||||
box-shadow: inset 0 1px 0 color-mix(in srgb, white 4%, transparent);
|
||||
@include treeNav.item-hover;
|
||||
}
|
||||
|
||||
.treeItemFolder {
|
||||
color: var(--color-text);
|
||||
@include treeNav.item-folder;
|
||||
}
|
||||
|
||||
.treeItemDragging {
|
||||
opacity: 0.45;
|
||||
transform: scale(0.985);
|
||||
box-shadow: none;
|
||||
@include treeNav.item-dragging;
|
||||
}
|
||||
|
||||
.treeItemDropBefore {
|
||||
box-shadow: inset 0 2px 0 color-mix(in srgb, var(--color-accent-strong) 78%, transparent);
|
||||
@include treeNav.item-drop-before;
|
||||
}
|
||||
|
||||
.treeItemDropAfter {
|
||||
box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--color-accent-strong) 78%, transparent);
|
||||
@include treeNav.item-drop-after;
|
||||
}
|
||||
|
||||
.treeItemDropInside {
|
||||
border-color: color-mix(in srgb, var(--color-accent-strong) 55%, transparent);
|
||||
background: color-mix(in srgb, var(--color-accent-soft) 36%, var(--color-surface));
|
||||
color: var(--color-text);
|
||||
box-shadow: inset 0 1px 0 color-mix(in srgb, white 4%, transparent);
|
||||
@include treeNav.item-drop-inside;
|
||||
}
|
||||
|
||||
.folderChevron {
|
||||
color: var(--color-text-muted);
|
||||
transition: transform 160ms var(--easing-standard);
|
||||
@include treeNav.folder-chevron;
|
||||
}
|
||||
|
||||
.folderChevronOpen {
|
||||
transform: rotate(90deg);
|
||||
@include treeNav.folder-chevron-open;
|
||||
}
|
||||
|
||||
.treeItemActive {
|
||||
border-color: var(--color-border);
|
||||
background: var(--color-surface);
|
||||
color: var(--color-text);
|
||||
box-shadow: inset 0 1px 0 color-mix(in srgb, white 4%, transparent);
|
||||
@include treeNav.item-active;
|
||||
}
|
||||
|
||||
.navItemActive {
|
||||
@@ -262,18 +203,15 @@
|
||||
}
|
||||
|
||||
.icon {
|
||||
color: inherit;
|
||||
opacity: 0.85;
|
||||
@include treeNav.icon;
|
||||
}
|
||||
|
||||
.label {
|
||||
@include text-label;
|
||||
min-width: 0;
|
||||
@include treeNav.label;
|
||||
}
|
||||
|
||||
.itemMeta {
|
||||
@include text-caption;
|
||||
color: var(--color-text-muted);
|
||||
@include treeNav.item-meta;
|
||||
}
|
||||
|
||||
.sidebarCollapsed {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,7 @@ import {
|
||||
Home,
|
||||
Keyboard,
|
||||
LayoutGrid,
|
||||
ListCollapse,
|
||||
LogOut,
|
||||
Repeat,
|
||||
Search,
|
||||
@@ -128,6 +129,7 @@ export type WorkspaceStaticItem = SidebarItem & {
|
||||
|
||||
export type WorkspaceFolderNode = {
|
||||
id: string;
|
||||
path?: string;
|
||||
label: string;
|
||||
kind: "folder";
|
||||
icon: ShellIcon;
|
||||
@@ -476,6 +478,7 @@ export const workspaceTree: readonly WorkspaceTreeNode[] = [
|
||||
|
||||
export const workspaceSidebarHeaderActions: readonly SidebarHeaderAction[] = [
|
||||
{ id: "search-workspace", label: "Search workspace", icon: Search },
|
||||
{ id: "toggle-workspace-folders", label: "Collapse all folders", icon: ListCollapse },
|
||||
] as const;
|
||||
|
||||
export const mobileBottomNavItems: readonly MobileBottomNavItem[] = [
|
||||
@@ -595,6 +598,12 @@ const getProjectCreateActions = (): readonly ProjectContextMenuAction[] =>
|
||||
{ id: "new-folder", label: "New folder" },
|
||||
] as const;
|
||||
|
||||
const getProjectFolderDangerActions = (): readonly ProjectContextMenuAction[] =>
|
||||
[
|
||||
{ id: "rename-folder", label: "Rename", shortcut: { modifiers: ["meta"], key: "r" } },
|
||||
{ id: "delete-folder", label: "Delete", shortcut: { modifiers: ["meta"], key: "delete" }, tone: "danger" },
|
||||
] as const;
|
||||
|
||||
export const createProjectSurfaceTarget = (label = "Projects"): ProjectMenuTarget => ({
|
||||
id: "project-surface",
|
||||
label,
|
||||
@@ -641,6 +650,10 @@ export const getProjectContextMenuSections = (target: ProjectMenuTarget): readon
|
||||
id: "create",
|
||||
items: createActions,
|
||||
},
|
||||
{
|
||||
id: "organize",
|
||||
items: getProjectFolderDangerActions(),
|
||||
},
|
||||
] as const;
|
||||
case "project":
|
||||
return [
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
@use "../../../styles/tools/mixins" as *;
|
||||
|
||||
@mixin section-label {
|
||||
@include text-caption;
|
||||
color: var(--color-text-subtle);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
@mixin tree-list {
|
||||
list-style: none;
|
||||
display: grid;
|
||||
gap: var(--space-1);
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
@mixin empty-slot {
|
||||
min-height: calc(var(--control-size-lg) - var(--space-2));
|
||||
padding-left: calc(var(--space-3) + (var(--tree-depth, 0) * var(--space-4)));
|
||||
border-radius: var(--radius-lg);
|
||||
border: 1px dashed color-mix(in srgb, var(--color-border) 38%, transparent);
|
||||
opacity: 0.35;
|
||||
}
|
||||
|
||||
@mixin input-row {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
min-height: calc(var(--control-size-lg) - var(--space-2));
|
||||
padding: var(--space-2) var(--space-3);
|
||||
padding-left: calc(var(--space-3) + (var(--tree-depth, 0) * var(--space-4)));
|
||||
border: 1px solid color-mix(in srgb, var(--color-border) 42%, transparent);
|
||||
border-radius: var(--radius-lg);
|
||||
background: color-mix(in srgb, var(--color-surface) 94%, transparent);
|
||||
}
|
||||
|
||||
@mixin input {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--color-text);
|
||||
font: inherit;
|
||||
outline: none;
|
||||
|
||||
&::placeholder {
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
}
|
||||
|
||||
@mixin item {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
position: relative;
|
||||
isolation: isolate;
|
||||
grid-template-columns: auto auto minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
min-height: calc(var(--control-size-lg) - var(--space-2));
|
||||
padding: var(--space-2) var(--space-3);
|
||||
padding-left: calc(var(--space-3) + (var(--tree-depth, 0) * var(--space-4)));
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
color: var(--color-text-muted);
|
||||
text-align: left;
|
||||
transition:
|
||||
color 160ms var(--easing-standard),
|
||||
box-shadow 160ms var(--easing-standard),
|
||||
transform 180ms var(--easing-standard);
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border: 1px solid transparent;
|
||||
border-radius: var(--radius-lg);
|
||||
background: transparent;
|
||||
transition:
|
||||
background 160ms var(--easing-standard),
|
||||
border-color 160ms var(--easing-standard),
|
||||
box-shadow 160ms var(--easing-standard);
|
||||
pointer-events: none;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
> * {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin item-hover {
|
||||
color: var(--color-text);
|
||||
|
||||
&::after {
|
||||
background: color-mix(in srgb, var(--color-surface-hover) 80%, var(--color-accent-soft) 20%);
|
||||
box-shadow: inset 0 1px 0 color-mix(in srgb, white 4%, transparent);
|
||||
}
|
||||
}
|
||||
|
||||
@mixin item-folder {
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
@mixin item-dragging {
|
||||
opacity: 0.45;
|
||||
transform: scale(0.985);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
@mixin item-drop-before {
|
||||
&::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: calc(var(--space-3) + (var(--tree-depth, 0) * var(--space-4)));
|
||||
right: var(--space-3);
|
||||
top: calc((var(--space-1) * -0.5) - 1px);
|
||||
height: 2px;
|
||||
border-radius: 999px;
|
||||
background: color-mix(in srgb, var(--color-accent-strong) 78%, transparent);
|
||||
pointer-events: none;
|
||||
z-index: 2;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin item-drop-after {
|
||||
&::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: calc(var(--space-3) + (var(--tree-depth, 0) * var(--space-4)));
|
||||
right: var(--space-3);
|
||||
bottom: calc((var(--space-1) * -0.5) - 1px);
|
||||
height: 2px;
|
||||
border-radius: 999px;
|
||||
background: color-mix(in srgb, var(--color-accent-strong) 78%, transparent);
|
||||
pointer-events: none;
|
||||
z-index: 2;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin item-drop-inside {
|
||||
color: var(--color-text);
|
||||
|
||||
&::after {
|
||||
border-color: color-mix(in srgb, var(--color-accent-strong) 55%, transparent);
|
||||
background: color-mix(in srgb, var(--color-accent-soft) 36%, var(--color-surface));
|
||||
box-shadow: inset 0 1px 0 color-mix(in srgb, white 4%, transparent);
|
||||
}
|
||||
}
|
||||
|
||||
@mixin folder-chevron {
|
||||
color: var(--color-text-muted);
|
||||
transition: transform 160ms var(--easing-standard);
|
||||
}
|
||||
|
||||
@mixin folder-chevron-open {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
@mixin item-active {
|
||||
color: var(--color-text);
|
||||
|
||||
&::after {
|
||||
border-color: var(--color-border);
|
||||
background: var(--color-surface);
|
||||
box-shadow: inset 0 1px 0 color-mix(in srgb, white 4%, transparent);
|
||||
}
|
||||
}
|
||||
|
||||
@mixin icon {
|
||||
color: inherit;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
@mixin label {
|
||||
@include text-label;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@mixin item-meta {
|
||||
@include text-caption;
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
@@ -0,0 +1,278 @@
|
||||
export type NavTreeDropIntent = "before" | "after" | "inside";
|
||||
|
||||
export type NavTreeDropTarget = {
|
||||
parentId: string | null;
|
||||
index: number;
|
||||
intent: NavTreeDropIntent;
|
||||
targetNodeId?: string;
|
||||
};
|
||||
|
||||
export type NavTreeDragState = {
|
||||
draggedNodeId: string;
|
||||
dropTarget: NavTreeDropTarget | null;
|
||||
};
|
||||
|
||||
export type NavTreeLocation<TNode> = {
|
||||
parentId: string | null;
|
||||
index: number;
|
||||
node: TNode;
|
||||
};
|
||||
|
||||
export type NavTreeAdapter<TNode> = {
|
||||
getNodeId: (node: TNode) => string;
|
||||
isBranchNode: (node: TNode) => boolean;
|
||||
getChildren: (node: TNode) => readonly TNode[];
|
||||
withChildren: (node: TNode, children: readonly TNode[]) => TNode;
|
||||
};
|
||||
|
||||
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
||||
|
||||
export const isUuidString = (value: string | null | undefined): boolean => {
|
||||
if (typeof value !== "string") {
|
||||
return false;
|
||||
}
|
||||
|
||||
return UUID_PATTERN.test(value.trim());
|
||||
};
|
||||
|
||||
export const collectBranchNodeIds = <TNode>(
|
||||
nodes: readonly TNode[],
|
||||
adapter: NavTreeAdapter<TNode>,
|
||||
): string[] => {
|
||||
const ids: string[] = [];
|
||||
|
||||
for (const node of nodes) {
|
||||
if (!adapter.isBranchNode(node)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ids.push(adapter.getNodeId(node));
|
||||
ids.push(...collectBranchNodeIds(adapter.getChildren(node), adapter));
|
||||
}
|
||||
|
||||
return ids;
|
||||
};
|
||||
|
||||
export const findTreeNodeLocation = <TNode>(
|
||||
nodes: readonly TNode[],
|
||||
nodeId: string,
|
||||
adapter: NavTreeAdapter<TNode>,
|
||||
parentId: string | null = null,
|
||||
): NavTreeLocation<TNode> | null => {
|
||||
for (let index = 0; index < nodes.length; index += 1) {
|
||||
const node = nodes[index];
|
||||
|
||||
if (adapter.getNodeId(node) === nodeId) {
|
||||
return { parentId, index, node };
|
||||
}
|
||||
|
||||
if (!adapter.isBranchNode(node)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const nestedLocation = findTreeNodeLocation(adapter.getChildren(node), nodeId, adapter, adapter.getNodeId(node));
|
||||
if (nestedLocation) {
|
||||
return nestedLocation;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export const findTreeNodeDepth = <TNode>(
|
||||
nodes: readonly TNode[],
|
||||
nodeId: string,
|
||||
adapter: NavTreeAdapter<TNode>,
|
||||
depth = 0,
|
||||
): number | null => {
|
||||
for (const node of nodes) {
|
||||
if (adapter.getNodeId(node) === nodeId) {
|
||||
return depth;
|
||||
}
|
||||
|
||||
if (!adapter.isBranchNode(node)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const nestedDepth = findTreeNodeDepth(adapter.getChildren(node), nodeId, adapter, depth + 1);
|
||||
if (nestedDepth !== null) {
|
||||
return nestedDepth;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export const treeContainsNode = <TNode>(
|
||||
nodes: readonly TNode[],
|
||||
nodeId: string,
|
||||
adapter: NavTreeAdapter<TNode>,
|
||||
): boolean => {
|
||||
for (const node of nodes) {
|
||||
if (adapter.getNodeId(node) === nodeId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (adapter.isBranchNode(node) && treeContainsNode(adapter.getChildren(node), nodeId, adapter)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
export const removeTreeNode = <TNode>(
|
||||
nodes: readonly TNode[],
|
||||
nodeId: string,
|
||||
adapter: NavTreeAdapter<TNode>,
|
||||
): { nodes: TNode[]; removed: TNode | null } => {
|
||||
const nextNodes: TNode[] = [];
|
||||
let removed: TNode | null = null;
|
||||
|
||||
for (const node of nodes) {
|
||||
if (adapter.getNodeId(node) === nodeId) {
|
||||
removed = node;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (adapter.isBranchNode(node)) {
|
||||
const result = removeTreeNode(adapter.getChildren(node), nodeId, adapter);
|
||||
|
||||
if (result.removed) {
|
||||
removed = result.removed;
|
||||
nextNodes.push(adapter.withChildren(node, result.nodes));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
nextNodes.push(node);
|
||||
}
|
||||
|
||||
return { nodes: nextNodes, removed };
|
||||
};
|
||||
|
||||
export const insertTreeNode = <TNode>(
|
||||
nodes: readonly TNode[],
|
||||
parentId: string | null,
|
||||
index: number,
|
||||
nodeToInsert: TNode,
|
||||
adapter: NavTreeAdapter<TNode>,
|
||||
): TNode[] => {
|
||||
if (parentId === null) {
|
||||
const nextNodes = [...nodes];
|
||||
nextNodes.splice(Math.max(0, Math.min(index, nextNodes.length)), 0, nodeToInsert);
|
||||
return nextNodes;
|
||||
}
|
||||
|
||||
return nodes.map((node) => {
|
||||
if (!adapter.isBranchNode(node)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
if (adapter.getNodeId(node) === parentId) {
|
||||
const nextChildren = [...adapter.getChildren(node)];
|
||||
nextChildren.splice(Math.max(0, Math.min(index, nextChildren.length)), 0, nodeToInsert);
|
||||
return adapter.withChildren(node, nextChildren);
|
||||
}
|
||||
|
||||
return adapter.withChildren(node, insertTreeNode(adapter.getChildren(node), parentId, index, nodeToInsert, adapter));
|
||||
});
|
||||
};
|
||||
|
||||
export const moveTreeNode = <TNode>(
|
||||
nodes: readonly TNode[],
|
||||
draggedNodeId: string,
|
||||
dropTarget: NavTreeDropTarget,
|
||||
adapter: NavTreeAdapter<TNode>,
|
||||
): TNode[] => {
|
||||
const location = findTreeNodeLocation(nodes, draggedNodeId, adapter);
|
||||
|
||||
if (!location) {
|
||||
return [...nodes];
|
||||
}
|
||||
|
||||
if (
|
||||
adapter.isBranchNode(location.node) &&
|
||||
dropTarget.parentId !== null &&
|
||||
(treeContainsNode(adapter.getChildren(location.node), dropTarget.parentId, adapter) ||
|
||||
dropTarget.parentId === adapter.getNodeId(location.node))
|
||||
) {
|
||||
return [...nodes];
|
||||
}
|
||||
|
||||
let normalizedIndex = dropTarget.index;
|
||||
if (dropTarget.parentId === location.parentId && dropTarget.index > location.index) {
|
||||
normalizedIndex -= 1;
|
||||
}
|
||||
|
||||
if (dropTarget.parentId === location.parentId && normalizedIndex === location.index) {
|
||||
return [...nodes];
|
||||
}
|
||||
|
||||
const removalResult = removeTreeNode(nodes, draggedNodeId, adapter);
|
||||
if (!removalResult.removed) {
|
||||
return [...nodes];
|
||||
}
|
||||
|
||||
return insertTreeNode(removalResult.nodes, dropTarget.parentId, normalizedIndex, removalResult.removed, adapter);
|
||||
};
|
||||
|
||||
export const getPointerRelativeY = (event: PointerEvent): number | null => {
|
||||
const currentTarget = event.currentTarget;
|
||||
if (!(currentTarget instanceof HTMLElement)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const bounds = currentTarget.getBoundingClientRect();
|
||||
return bounds.height <= 0 ? 0.5 : (event.clientY - bounds.top) / bounds.height;
|
||||
};
|
||||
|
||||
export const resolveTreeDropTarget = <TNode>(params: {
|
||||
parentId: string | null;
|
||||
index: number;
|
||||
node: TNode;
|
||||
relativeY: number;
|
||||
adapter: NavTreeAdapter<TNode>;
|
||||
beforeThreshold?: number;
|
||||
beforeThresholdFirstSibling?: number;
|
||||
afterThreshold?: number;
|
||||
}): NavTreeDropTarget => {
|
||||
const {
|
||||
parentId,
|
||||
index,
|
||||
node,
|
||||
relativeY,
|
||||
adapter,
|
||||
beforeThreshold = 0.28,
|
||||
beforeThresholdFirstSibling = 0.42,
|
||||
afterThreshold = 0.72,
|
||||
} = params;
|
||||
|
||||
const targetNodeId = adapter.getNodeId(node);
|
||||
|
||||
if (adapter.isBranchNode(node)) {
|
||||
const nextBeforeThreshold = index === 0 ? beforeThresholdFirstSibling : beforeThreshold;
|
||||
|
||||
if (relativeY < nextBeforeThreshold) {
|
||||
return { parentId, index, intent: "before", targetNodeId };
|
||||
}
|
||||
|
||||
if (relativeY > afterThreshold) {
|
||||
return { parentId, index: index + 1, intent: "after", targetNodeId };
|
||||
}
|
||||
|
||||
return {
|
||||
parentId: targetNodeId,
|
||||
index: adapter.getChildren(node).length,
|
||||
intent: "inside",
|
||||
targetNodeId,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
parentId,
|
||||
index: relativeY < 0.5 ? index : index + 1,
|
||||
intent: relativeY < 0.5 ? "before" : "after",
|
||||
targetNodeId,
|
||||
};
|
||||
};
|
||||
@@ -21,6 +21,29 @@ type BootstrapSubmissionState = {
|
||||
error: string;
|
||||
};
|
||||
|
||||
type InstanceForm = {
|
||||
protocol: "http" | "https";
|
||||
access: "local" | "remote";
|
||||
host: string;
|
||||
};
|
||||
|
||||
type ModeForm = {
|
||||
mode: "personal" | "organizational";
|
||||
name: string;
|
||||
};
|
||||
|
||||
type AdminForm = {
|
||||
displayName: string;
|
||||
email: string;
|
||||
password: string;
|
||||
};
|
||||
|
||||
type StructureForm = {
|
||||
departmentName: string;
|
||||
teamName: string;
|
||||
projectName: string;
|
||||
};
|
||||
|
||||
const bootstrapStepDefinitions: readonly BootstrapStepDefinition[] = [
|
||||
{
|
||||
id: "instance",
|
||||
@@ -44,37 +67,37 @@ const bootstrapStepDefinitions: readonly BootstrapStepDefinition[] = [
|
||||
},
|
||||
];
|
||||
|
||||
const defaultInstanceForm = {
|
||||
const defaultInstanceForm: InstanceForm = {
|
||||
protocol: "http",
|
||||
access: "local",
|
||||
host: "localhost",
|
||||
} as const;
|
||||
};
|
||||
|
||||
const defaultModeForm = {
|
||||
const defaultModeForm: ModeForm = {
|
||||
mode: "personal",
|
||||
name: "",
|
||||
} as const;
|
||||
};
|
||||
|
||||
const defaultAdminForm = {
|
||||
const defaultAdminForm: AdminForm = {
|
||||
displayName: "Admin",
|
||||
email: "admin@example.com",
|
||||
password: "",
|
||||
} as const;
|
||||
};
|
||||
|
||||
const personalStructureDefaults = {
|
||||
departmentName: "Default",
|
||||
teamName: "Personal",
|
||||
} as const;
|
||||
};
|
||||
|
||||
const organizationalStructureDefaults = {
|
||||
departmentName: "Department",
|
||||
teamName: "Team",
|
||||
} as const;
|
||||
};
|
||||
|
||||
const defaultStructureForm = {
|
||||
const defaultStructureForm: StructureForm = {
|
||||
...personalStructureDefaults,
|
||||
projectName: "Project",
|
||||
} as const;
|
||||
};
|
||||
|
||||
const initialSubmissionState = (): BootstrapSubmissionState => ({
|
||||
status: "idle",
|
||||
@@ -148,10 +171,10 @@ type WorkspaceHomeProps = {
|
||||
|
||||
export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
|
||||
const appShellData = useAppShellData();
|
||||
const [instanceForm, setInstanceForm] = createStore({ ...defaultInstanceForm });
|
||||
const [modeForm, setModeForm] = createStore({ ...defaultModeForm });
|
||||
const [adminForm, setAdminForm] = createStore({ ...defaultAdminForm });
|
||||
const [structureForm, setStructureForm] = createStore({ ...defaultStructureForm });
|
||||
const [instanceForm, setInstanceForm] = createStore<InstanceForm>({ ...defaultInstanceForm });
|
||||
const [modeForm, setModeForm] = createStore<ModeForm>({ ...defaultModeForm });
|
||||
const [adminForm, setAdminForm] = createStore<AdminForm>({ ...defaultAdminForm });
|
||||
const [structureForm, setStructureForm] = createStore<StructureForm>({ ...defaultStructureForm });
|
||||
const [stepState, setStepState] = createStore<Record<BootstrapStepKey, BootstrapSubmissionState>>({
|
||||
instance: initialSubmissionState(),
|
||||
mode: initialSubmissionState(),
|
||||
@@ -363,7 +386,13 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
|
||||
<h1 class={styles.title}>{isBootstrapComplete() ? appShellData.activeServer().name : bootstrapTargetLabel()}</h1>
|
||||
<Show when={isBootstrapStateResolved() && !isBootstrapComplete()}>
|
||||
<div class={styles.heroActions}>
|
||||
<button type="button" class={styles.primaryButton} onClick={(): void => setIsWizardOpen(true)}>
|
||||
<button
|
||||
type="button"
|
||||
class={styles.primaryButton}
|
||||
onClick={(): void => {
|
||||
setIsWizardOpen(true);
|
||||
}}
|
||||
>
|
||||
Open bootstrap wizard
|
||||
</button>
|
||||
</div>
|
||||
@@ -384,7 +413,13 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
|
||||
</h2>
|
||||
</div>
|
||||
<Show when={canDismissWizard()}>
|
||||
<button type="button" class={styles.wizardCloseButton} onClick={(): void => setIsWizardOpen(false)}>
|
||||
<button
|
||||
type="button"
|
||||
class={styles.wizardCloseButton}
|
||||
onClick={(): void => {
|
||||
setIsWizardOpen(false);
|
||||
}}
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
</Show>
|
||||
@@ -433,14 +468,24 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
|
||||
<>
|
||||
<label class={styles.field}>
|
||||
<span class={styles.fieldLabel}>Protocol</span>
|
||||
<select value={instanceForm.protocol} onInput={(event): void => setInstanceForm("protocol", event.currentTarget.value)}>
|
||||
<select
|
||||
value={instanceForm.protocol}
|
||||
onInput={(event): void =>
|
||||
setInstanceForm("protocol", event.currentTarget.value as InstanceForm["protocol"])
|
||||
}
|
||||
>
|
||||
<option value="http">http</option>
|
||||
<option value="https">https</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class={styles.field}>
|
||||
<span class={styles.fieldLabel}>Access</span>
|
||||
<select value={instanceForm.access} onInput={(event): void => setInstanceForm("access", event.currentTarget.value)}>
|
||||
<select
|
||||
value={instanceForm.access}
|
||||
onInput={(event): void =>
|
||||
setInstanceForm("access", event.currentTarget.value as InstanceForm["access"])
|
||||
}
|
||||
>
|
||||
<option value="local">local</option>
|
||||
<option value="remote">remote</option>
|
||||
</select>
|
||||
@@ -461,7 +506,10 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
|
||||
<>
|
||||
<label class={styles.field}>
|
||||
<span class={styles.fieldLabel}>Mode</span>
|
||||
<select value={modeForm.mode} onInput={(event): void => setModeForm("mode", event.currentTarget.value)}>
|
||||
<select
|
||||
value={modeForm.mode}
|
||||
onInput={(event): void => setModeForm("mode", event.currentTarget.value as ModeForm["mode"])}
|
||||
>
|
||||
<option value="personal">personal</option>
|
||||
<option value="organizational">organizational</option>
|
||||
</select>
|
||||
@@ -553,7 +601,9 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
|
||||
type="button"
|
||||
class={styles.secondaryButton}
|
||||
disabled={isFirstStep()}
|
||||
onClick={(): void => setCurrentStepIndex((index) => Math.max(index - 1, 0))}
|
||||
onClick={(): void => {
|
||||
setCurrentStepIndex((index) => Math.max(index - 1, 0));
|
||||
}}
|
||||
>
|
||||
Back
|
||||
</button>
|
||||
|
||||
@@ -10,6 +10,7 @@ export { default as Folder } from "lucide-solid/icons/folder";
|
||||
export { default as Home } from "lucide-solid/icons/house";
|
||||
export { default as Keyboard } from "lucide-solid/icons/keyboard";
|
||||
export { default as LayoutGrid } from "lucide-solid/icons/layout-grid";
|
||||
export { default as ListCollapse } from "lucide-solid/icons/list-collapse";
|
||||
export { default as LogOut } from "lucide-solid/icons/log-out";
|
||||
export { default as Moon } from "lucide-solid/icons/moon";
|
||||
export { default as Plus } from "lucide-solid/icons/plus";
|
||||
@@ -18,5 +19,6 @@ export { default as Search } from "lucide-solid/icons/search";
|
||||
export { default as Settings } from "lucide-solid/icons/settings";
|
||||
export { default as Shield } from "lucide-solid/icons/shield";
|
||||
export { default as Sun } from "lucide-solid/icons/sun";
|
||||
export { default as UnfoldVertical } from "lucide-solid/icons/unfold-vertical";
|
||||
export { default as User } from "lucide-solid/icons/user";
|
||||
export { default as X } from "lucide-solid/icons/x";
|
||||
|
||||
Reference in New Issue
Block a user