From 729f97f38ae0d14f3f96448e21798880bb88157a Mon Sep 17 00:00:00 2001 From: Anton Tranelis <31516529+antontranelis@users.noreply.github.com> Date: Tue, 1 Jul 2025 16:51:46 +0200 Subject: [PATCH 1/3] refactor(app): rename frontend directory (#273) --- .github/workflows/test.lint.frontend.yml | 10 +++++----- .github/workflows/test.lint.pr.yml | 2 +- {frontend => app}/.env | 0 {frontend => app}/.eslintignore | 0 {frontend => app}/.eslintrc.cjs | 0 {frontend => app}/.gitignore | 0 {frontend => app}/.prettierrc.json | 0 {frontend => app}/docker-compose.yml | 2 +- {frontend => app}/index.html | 0 {frontend => app}/localhost-cert.pem | 0 {frontend => app}/localhost-key.pem | 0 {frontend => app}/package-lock.json | 0 {frontend => app}/package.json | 0 {frontend => app}/public/3markers-globe.svg | 0 {frontend => app}/public/bg1.webp | Bin {frontend => app}/public/github.svg | 0 {frontend => app}/public/opencollective.svg | 0 {frontend => app}/public/style.css | 0 {frontend => app}/src/App.css | 0 {frontend => app}/src/App.tsx | 0 {frontend => app}/src/ModalContent.tsx | 0 {frontend => app}/src/api/assetsApi.ts | 0 {frontend => app}/src/api/directus.ts | 0 {frontend => app}/src/api/itemsApi.ts | 0 {frontend => app}/src/api/layersApi.ts | 0 {frontend => app}/src/api/mapApi.ts | 0 {frontend => app}/src/api/permissionsApi.ts | 0 {frontend => app}/src/api/readUserApi.ts | 0 {frontend => app}/src/api/refiBcnApi.ts | 0 {frontend => app}/src/api/userApi.ts | 0 {frontend => app}/src/index.css | 0 {frontend => app}/src/main.tsx | 0 {frontend => app}/src/pages/Concept.tsx | 0 {frontend => app}/src/pages/ConceptDE.tsx | 0 {frontend => app}/src/pages/Landingpage.tsx | 0 {frontend => app}/src/pages/MapContainer.tsx | 0 {frontend => app}/src/pages/data.ts | 0 {frontend => app}/src/routes/sidebar.tsx | 0 {frontend => app}/src/vite-env.d.ts | 0 {frontend => app}/tailwind.config.js | 0 {frontend => app}/tsconfig.json | 0 {frontend => app}/tsconfig.node.json | 0 {frontend => app}/video_preview.png | Bin {frontend => app}/vite.config.ts | 0 backend/README.md | 2 +- 45 files changed, 8 insertions(+), 8 deletions(-) rename {frontend => app}/.env (100%) rename {frontend => app}/.eslintignore (100%) rename {frontend => app}/.eslintrc.cjs (100%) rename {frontend => app}/.gitignore (100%) rename {frontend => app}/.prettierrc.json (100%) rename {frontend => app}/docker-compose.yml (98%) rename {frontend => app}/index.html (100%) rename {frontend => app}/localhost-cert.pem (100%) rename {frontend => app}/localhost-key.pem (100%) rename {frontend => app}/package-lock.json (100%) rename {frontend => app}/package.json (100%) rename {frontend => app}/public/3markers-globe.svg (100%) rename {frontend => app}/public/bg1.webp (100%) rename {frontend => app}/public/github.svg (100%) rename {frontend => app}/public/opencollective.svg (100%) rename {frontend => app}/public/style.css (100%) rename {frontend => app}/src/App.css (100%) rename {frontend => app}/src/App.tsx (100%) rename {frontend => app}/src/ModalContent.tsx (100%) rename {frontend => app}/src/api/assetsApi.ts (100%) rename {frontend => app}/src/api/directus.ts (100%) rename {frontend => app}/src/api/itemsApi.ts (100%) rename {frontend => app}/src/api/layersApi.ts (100%) rename {frontend => app}/src/api/mapApi.ts (100%) rename {frontend => app}/src/api/permissionsApi.ts (100%) rename {frontend => app}/src/api/readUserApi.ts (100%) rename {frontend => app}/src/api/refiBcnApi.ts (100%) rename {frontend => app}/src/api/userApi.ts (100%) rename {frontend => app}/src/index.css (100%) rename {frontend => app}/src/main.tsx (100%) rename {frontend => app}/src/pages/Concept.tsx (100%) rename {frontend => app}/src/pages/ConceptDE.tsx (100%) rename {frontend => app}/src/pages/Landingpage.tsx (100%) rename {frontend => app}/src/pages/MapContainer.tsx (100%) rename {frontend => app}/src/pages/data.ts (100%) rename {frontend => app}/src/routes/sidebar.tsx (100%) rename {frontend => app}/src/vite-env.d.ts (100%) rename {frontend => app}/tailwind.config.js (100%) rename {frontend => app}/tsconfig.json (100%) rename {frontend => app}/tsconfig.node.json (100%) rename {frontend => app}/video_preview.png (100%) rename {frontend => app}/vite.config.ts (100%) diff --git a/.github/workflows/test.lint.frontend.yml b/.github/workflows/test.lint.frontend.yml index 93364ca7..ab7229f4 100644 --- a/.github/workflows/test.lint.frontend.yml +++ b/.github/workflows/test.lint.frontend.yml @@ -1,10 +1,10 @@ -name: test:lint:frontend +name: test:lint:app on: push jobs: files-changed: - name: Detect File Changes - lint - frontend + name: Detect File Changes - lint - app runs-on: ubuntu-latest outputs: lint: ${{ steps.filter.outputs.lint }} @@ -16,11 +16,11 @@ jobs: filters: | lint: - '.github/workflows/**/*' - - 'frontend/**/*' + - 'app/**/*' lint: if: needs.files-changed.outputs.lint == 'true' - name: Lint - frontend + name: Lint - app needs: files-changed runs-on: ubuntu-latest steps: @@ -30,4 +30,4 @@ jobs: node-version-file: '.tool-versions' - name: Lint run: npm install && npm run test:lint:eslint - working-directory: frontend/ + working-directory: app/ diff --git a/.github/workflows/test.lint.pr.yml b/.github/workflows/test.lint.pr.yml index 43f8438d..8e24a2c7 100644 --- a/.github/workflows/test.lint.pr.yml +++ b/.github/workflows/test.lint.pr.yml @@ -30,7 +30,7 @@ jobs: # Append a scope for each service here scopes: | backend - frontend + app lib docu docker diff --git a/frontend/.env b/app/.env similarity index 100% rename from frontend/.env rename to app/.env diff --git a/frontend/.eslintignore b/app/.eslintignore similarity index 100% rename from frontend/.eslintignore rename to app/.eslintignore diff --git a/frontend/.eslintrc.cjs b/app/.eslintrc.cjs similarity index 100% rename from frontend/.eslintrc.cjs rename to app/.eslintrc.cjs diff --git a/frontend/.gitignore b/app/.gitignore similarity index 100% rename from frontend/.gitignore rename to app/.gitignore diff --git a/frontend/.prettierrc.json b/app/.prettierrc.json similarity index 100% rename from frontend/.prettierrc.json rename to app/.prettierrc.json diff --git a/frontend/docker-compose.yml b/app/docker-compose.yml similarity index 98% rename from frontend/docker-compose.yml rename to app/docker-compose.yml index 829739ed..ff7d9f5e 100644 --- a/frontend/docker-compose.yml +++ b/app/docker-compose.yml @@ -38,7 +38,7 @@ services: backend: container_name: backend build: - context: ./backend + context: ../backend depends_on: database: condition: service_healthy diff --git a/frontend/index.html b/app/index.html similarity index 100% rename from frontend/index.html rename to app/index.html diff --git a/frontend/localhost-cert.pem b/app/localhost-cert.pem similarity index 100% rename from frontend/localhost-cert.pem rename to app/localhost-cert.pem diff --git a/frontend/localhost-key.pem b/app/localhost-key.pem similarity index 100% rename from frontend/localhost-key.pem rename to app/localhost-key.pem diff --git a/frontend/package-lock.json b/app/package-lock.json similarity index 100% rename from frontend/package-lock.json rename to app/package-lock.json diff --git a/frontend/package.json b/app/package.json similarity index 100% rename from frontend/package.json rename to app/package.json diff --git a/frontend/public/3markers-globe.svg b/app/public/3markers-globe.svg similarity index 100% rename from frontend/public/3markers-globe.svg rename to app/public/3markers-globe.svg diff --git a/frontend/public/bg1.webp b/app/public/bg1.webp similarity index 100% rename from frontend/public/bg1.webp rename to app/public/bg1.webp diff --git a/frontend/public/github.svg b/app/public/github.svg similarity index 100% rename from frontend/public/github.svg rename to app/public/github.svg diff --git a/frontend/public/opencollective.svg b/app/public/opencollective.svg similarity index 100% rename from frontend/public/opencollective.svg rename to app/public/opencollective.svg diff --git a/frontend/public/style.css b/app/public/style.css similarity index 100% rename from frontend/public/style.css rename to app/public/style.css diff --git a/frontend/src/App.css b/app/src/App.css similarity index 100% rename from frontend/src/App.css rename to app/src/App.css diff --git a/frontend/src/App.tsx b/app/src/App.tsx similarity index 100% rename from frontend/src/App.tsx rename to app/src/App.tsx diff --git a/frontend/src/ModalContent.tsx b/app/src/ModalContent.tsx similarity index 100% rename from frontend/src/ModalContent.tsx rename to app/src/ModalContent.tsx diff --git a/frontend/src/api/assetsApi.ts b/app/src/api/assetsApi.ts similarity index 100% rename from frontend/src/api/assetsApi.ts rename to app/src/api/assetsApi.ts diff --git a/frontend/src/api/directus.ts b/app/src/api/directus.ts similarity index 100% rename from frontend/src/api/directus.ts rename to app/src/api/directus.ts diff --git a/frontend/src/api/itemsApi.ts b/app/src/api/itemsApi.ts similarity index 100% rename from frontend/src/api/itemsApi.ts rename to app/src/api/itemsApi.ts diff --git a/frontend/src/api/layersApi.ts b/app/src/api/layersApi.ts similarity index 100% rename from frontend/src/api/layersApi.ts rename to app/src/api/layersApi.ts diff --git a/frontend/src/api/mapApi.ts b/app/src/api/mapApi.ts similarity index 100% rename from frontend/src/api/mapApi.ts rename to app/src/api/mapApi.ts diff --git a/frontend/src/api/permissionsApi.ts b/app/src/api/permissionsApi.ts similarity index 100% rename from frontend/src/api/permissionsApi.ts rename to app/src/api/permissionsApi.ts diff --git a/frontend/src/api/readUserApi.ts b/app/src/api/readUserApi.ts similarity index 100% rename from frontend/src/api/readUserApi.ts rename to app/src/api/readUserApi.ts diff --git a/frontend/src/api/refiBcnApi.ts b/app/src/api/refiBcnApi.ts similarity index 100% rename from frontend/src/api/refiBcnApi.ts rename to app/src/api/refiBcnApi.ts diff --git a/frontend/src/api/userApi.ts b/app/src/api/userApi.ts similarity index 100% rename from frontend/src/api/userApi.ts rename to app/src/api/userApi.ts diff --git a/frontend/src/index.css b/app/src/index.css similarity index 100% rename from frontend/src/index.css rename to app/src/index.css diff --git a/frontend/src/main.tsx b/app/src/main.tsx similarity index 100% rename from frontend/src/main.tsx rename to app/src/main.tsx diff --git a/frontend/src/pages/Concept.tsx b/app/src/pages/Concept.tsx similarity index 100% rename from frontend/src/pages/Concept.tsx rename to app/src/pages/Concept.tsx diff --git a/frontend/src/pages/ConceptDE.tsx b/app/src/pages/ConceptDE.tsx similarity index 100% rename from frontend/src/pages/ConceptDE.tsx rename to app/src/pages/ConceptDE.tsx diff --git a/frontend/src/pages/Landingpage.tsx b/app/src/pages/Landingpage.tsx similarity index 100% rename from frontend/src/pages/Landingpage.tsx rename to app/src/pages/Landingpage.tsx diff --git a/frontend/src/pages/MapContainer.tsx b/app/src/pages/MapContainer.tsx similarity index 100% rename from frontend/src/pages/MapContainer.tsx rename to app/src/pages/MapContainer.tsx diff --git a/frontend/src/pages/data.ts b/app/src/pages/data.ts similarity index 100% rename from frontend/src/pages/data.ts rename to app/src/pages/data.ts diff --git a/frontend/src/routes/sidebar.tsx b/app/src/routes/sidebar.tsx similarity index 100% rename from frontend/src/routes/sidebar.tsx rename to app/src/routes/sidebar.tsx diff --git a/frontend/src/vite-env.d.ts b/app/src/vite-env.d.ts similarity index 100% rename from frontend/src/vite-env.d.ts rename to app/src/vite-env.d.ts diff --git a/frontend/tailwind.config.js b/app/tailwind.config.js similarity index 100% rename from frontend/tailwind.config.js rename to app/tailwind.config.js diff --git a/frontend/tsconfig.json b/app/tsconfig.json similarity index 100% rename from frontend/tsconfig.json rename to app/tsconfig.json diff --git a/frontend/tsconfig.node.json b/app/tsconfig.node.json similarity index 100% rename from frontend/tsconfig.node.json rename to app/tsconfig.node.json diff --git a/frontend/video_preview.png b/app/video_preview.png similarity index 100% rename from frontend/video_preview.png rename to app/video_preview.png diff --git a/frontend/vite.config.ts b/app/vite.config.ts similarity index 100% rename from frontend/vite.config.ts rename to app/vite.config.ts diff --git a/backend/README.md b/backend/README.md index f796ee30..7d280167 100644 --- a/backend/README.md +++ b/backend/README.md @@ -1,4 +1,4 @@ -In order to pull data from your locally running backend (see [docker-compose](../docker-compose.yml)) to your local harddrive, you can run the following command +In order to pull data from your locally running backend (see [docker-compose](../app/docker-compose.yml)) to your local harddrive, you can run the following command ``` npx directus-sync pull \ From c92695eea76ba0bc9994a761dab92cb18b577a39 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 3 Jul 2025 09:21:31 +0200 Subject: [PATCH 2/3] fix(frontend): update directus collections (#269) * Update directus collections * item_secrets is not a collection we call via directus client --------- Co-authored-by: Anton Tranelis <31516529+antontranelis@users.noreply.github.com> --- .github/workflows/test.build.lib.yml | 2 +- app/src/api/directus.ts | 5 +++++ app/src/api/itemsApi.ts | 14 +++++--------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.build.lib.yml b/.github/workflows/test.build.lib.yml index 2c7c26b6..00e82f3b 100644 --- a/.github/workflows/test.build.lib.yml +++ b/.github/workflows/test.build.lib.yml @@ -37,7 +37,7 @@ jobs: build-examples: if: needs.files-changed.outputs.build == 'true' name: Test Example Apps - needs: build + needs: [build, files-changed] runs-on: ubuntu-latest strategy: matrix: diff --git a/app/src/api/directus.ts b/app/src/api/directus.ts index 032be4b4..c49a10f5 100644 --- a/app/src/api/directus.ts +++ b/app/src/api/directus.ts @@ -6,6 +6,7 @@ import { createDirectus, rest, authentication } from '@directus/sdk' import type { AuthenticationData, AuthenticationStorage } from '@directus/sdk' import type { Point } from 'geojson' +import type { Item } from 'utopia-ui' export interface Place { id: string @@ -57,6 +58,10 @@ export interface MyCollections { tags: Tag[] projects: Project[] directus_users: CustomUserFields[] + items: Item[] + team: any[] + features: any[] + attestations: any[] } export const authLocalStorage = (mainKey = 'directus_storage') => diff --git a/app/src/api/itemsApi.ts b/app/src/api/itemsApi.ts index c67ccc5f..854734ab 100644 --- a/app/src/api/itemsApi.ts +++ b/app/src/api/itemsApi.ts @@ -12,14 +12,14 @@ import type { MyCollections } from './directus' import type { ItemsApi } from 'utopia-ui' export class itemsApi implements ItemsApi { - collectionName: string + collectionName: keyof MyCollections filter: any layerId: string | undefined mapId: string | undefined customParameter: any constructor( - collectionName: string, + collectionName: keyof MyCollections, layerId?: string | undefined, mapId?: string | undefined, filter?: any, @@ -81,7 +81,7 @@ export class itemsApi implements ItemsApi { async createItem(item: T & { id?: string }): Promise { try { const result = await directusClient.request( - createItem(this.collectionName as keyof MyCollections, { + createItem(this.collectionName, { ...item, ...(this.customParameter && this.customParameter), ...(this.layerId && { layer: this.layerId }), @@ -99,9 +99,7 @@ export class itemsApi implements ItemsApi { async updateItem(item: T & { id?: string }): Promise { try { - const result = await directusClient.request( - updateItem(this.collectionName as keyof MyCollections, item.id!, item), - ) + const result = await directusClient.request(updateItem(this.collectionName, item.id!, item)) return result as T } catch (error: any) { console.log(error) @@ -112,9 +110,7 @@ export class itemsApi implements ItemsApi { async deleteItem(id: string): Promise { try { - const result = await directusClient.request( - deleteItem(this.collectionName as keyof MyCollections, id), - ) + const result = await directusClient.request(deleteItem(this.collectionName, id)) return result as unknown as boolean } catch (error: any) { console.log(error) From 045ec726eb71abcf3e8312fd57c95386e792786b Mon Sep 17 00:00:00 2001 From: Anton Tranelis <31516529+antontranelis@users.noreply.github.com> Date: Thu, 3 Jul 2025 13:18:10 +0200 Subject: [PATCH 3/3] fix(lib): auto close update position toast (#277) * add close button to custom info modal * auto close update position toat * Revert "add close button to custom info modal" This reverts commit cf5b9a407effe0772ed622ce2369cf16e0b82175. * fix: reset position for new items without text --- .../Map/Subcomponents/SelectPosition.tsx | 2 +- .../Map/hooks/useSelectPosition.tsx | 57 ++++++++++++++++--- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/lib/src/Components/Map/Subcomponents/SelectPosition.tsx b/lib/src/Components/Map/Subcomponents/SelectPosition.tsx index 6f4eccbe..ceae1c72 100644 --- a/lib/src/Components/Map/Subcomponents/SelectPosition.tsx +++ b/lib/src/Components/Map/Subcomponents/SelectPosition.tsx @@ -20,7 +20,7 @@ export const SelectPosition = ({
- {selectNewItemPosition && 'text' in selectNewItemPosition && ( + {selectNewItemPosition && 'layer' in selectNewItemPosition && ( Select new position of {selectNewItemPosition.name} on the map! diff --git a/lib/src/Components/Map/hooks/useSelectPosition.tsx b/lib/src/Components/Map/hooks/useSelectPosition.tsx index 0b7a56ab..6868fb09 100644 --- a/lib/src/Components/Map/hooks/useSelectPosition.tsx +++ b/lib/src/Components/Map/hooks/useSelectPosition.tsx @@ -69,7 +69,7 @@ function useSelectPositionManager(): { }) setSelectPosition(null) } - if ('text' in selectPosition) { + if ('layer' in selectPosition) { // if selectPosition is an Item const position = mapClicked?.position.lng && @@ -101,9 +101,9 @@ function useSelectPositionManager(): { success = true } catch (error: unknown) { if (error instanceof Error) { - toast.update(toastId, { render: error.message, type: 'error' }) + toast.update(toastId, { render: error.message, type: 'error', autoClose: 5000 }) } else if (typeof error === 'string') { - toast.update(toastId, { render: error, type: 'error' }) + toast.update(toastId, { render: error, type: 'error', autoClose: 5000 }) } else { throw error } @@ -115,6 +115,7 @@ function useSelectPositionManager(): { render: 'Item position updated', type: 'success', isLoading: false, + autoClose: 5000, }) setSelectPosition(null) setMarkerClicked(null) @@ -125,6 +126,8 @@ function useSelectPositionManager(): { render: "you don't have permission to add items to " + markerClicked?.name, type: 'error', isLoading: false, + autoClose: 5000, + closeButton: true, }) } } @@ -140,16 +143,34 @@ function useSelectPositionManager(): { success = true } catch (error: unknown) { if (error instanceof Error) { - toast.update(toastId, { render: error.message, type: 'error', isLoading: false }) + toast.update(toastId, { + render: error.message, + type: 'error', + isLoading: false, + autoClose: 5000, + closeButton: true, + }) } else if (typeof error === 'string') { - toast.update(toastId, { render: error, type: 'error', isLoading: false }) + toast.update(toastId, { + render: error, + type: 'error', + isLoading: false, + autoClose: 5000, + closeButton: true, + }) } else { throw error } } if (success) { updateItem(updatedItem) - toast.update(toastId, { render: 'Item position updated', type: 'success', isLoading: false }) + toast.update(toastId, { + render: 'Item position updated', + type: 'success', + isLoading: false, + autoClose: 5000, + closeButton: true, + }) } } @@ -168,16 +189,34 @@ function useSelectPositionManager(): { success = true } catch (error: unknown) { if (error instanceof Error) { - toast.update(toastId, { render: error.message, type: 'error', isLoading: false }) + toast.update(toastId, { + render: error.message, + type: 'error', + isLoading: false, + autoClose: 5000, + closeButton: true, + }) } else if (typeof error === 'string') { - toast.update(toastId, { render: error, type: 'error', isLoading: false }) + toast.update(toastId, { + render: error, + type: 'error', + isLoading: false, + autoClose: 5000, + closeButton: true, + }) } else { throw error } } if (success) { updateItem({ ...markerClicked, relations: newRelations }) - toast.update(toastId, { render: 'Item linked', type: 'success', isLoading: false }) + toast.update(toastId, { + render: 'Item linked', + type: 'success', + isLoading: false, + autoClose: 5000, + closeButton: true, + }) } } }