mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
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>
This commit is contained in:
parent
729f97f38a
commit
c92695eea7
2
.github/workflows/test.build.lib.yml
vendored
2
.github/workflows/test.build.lib.yml
vendored
@ -37,7 +37,7 @@ jobs:
|
|||||||
build-examples:
|
build-examples:
|
||||||
if: needs.files-changed.outputs.build == 'true'
|
if: needs.files-changed.outputs.build == 'true'
|
||||||
name: Test Example Apps
|
name: Test Example Apps
|
||||||
needs: build
|
needs: [build, files-changed]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import { createDirectus, rest, authentication } from '@directus/sdk'
|
|||||||
|
|
||||||
import type { AuthenticationData, AuthenticationStorage } from '@directus/sdk'
|
import type { AuthenticationData, AuthenticationStorage } from '@directus/sdk'
|
||||||
import type { Point } from 'geojson'
|
import type { Point } from 'geojson'
|
||||||
|
import type { Item } from 'utopia-ui'
|
||||||
|
|
||||||
export interface Place {
|
export interface Place {
|
||||||
id: string
|
id: string
|
||||||
@ -57,6 +58,10 @@ export interface MyCollections {
|
|||||||
tags: Tag[]
|
tags: Tag[]
|
||||||
projects: Project[]
|
projects: Project[]
|
||||||
directus_users: CustomUserFields[]
|
directus_users: CustomUserFields[]
|
||||||
|
items: Item[]
|
||||||
|
team: any[]
|
||||||
|
features: any[]
|
||||||
|
attestations: any[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const authLocalStorage = (mainKey = 'directus_storage') =>
|
export const authLocalStorage = (mainKey = 'directus_storage') =>
|
||||||
|
|||||||
@ -12,14 +12,14 @@ import type { MyCollections } from './directus'
|
|||||||
import type { ItemsApi } from 'utopia-ui'
|
import type { ItemsApi } from 'utopia-ui'
|
||||||
|
|
||||||
export class itemsApi<T> implements ItemsApi<T> {
|
export class itemsApi<T> implements ItemsApi<T> {
|
||||||
collectionName: string
|
collectionName: keyof MyCollections
|
||||||
filter: any
|
filter: any
|
||||||
layerId: string | undefined
|
layerId: string | undefined
|
||||||
mapId: string | undefined
|
mapId: string | undefined
|
||||||
customParameter: any
|
customParameter: any
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
collectionName: string,
|
collectionName: keyof MyCollections,
|
||||||
layerId?: string | undefined,
|
layerId?: string | undefined,
|
||||||
mapId?: string | undefined,
|
mapId?: string | undefined,
|
||||||
filter?: any,
|
filter?: any,
|
||||||
@ -81,7 +81,7 @@ export class itemsApi<T> implements ItemsApi<T> {
|
|||||||
async createItem(item: T & { id?: string }): Promise<T> {
|
async createItem(item: T & { id?: string }): Promise<T> {
|
||||||
try {
|
try {
|
||||||
const result = await directusClient.request(
|
const result = await directusClient.request(
|
||||||
createItem(this.collectionName as keyof MyCollections, {
|
createItem(this.collectionName, {
|
||||||
...item,
|
...item,
|
||||||
...(this.customParameter && this.customParameter),
|
...(this.customParameter && this.customParameter),
|
||||||
...(this.layerId && { layer: this.layerId }),
|
...(this.layerId && { layer: this.layerId }),
|
||||||
@ -99,9 +99,7 @@ export class itemsApi<T> implements ItemsApi<T> {
|
|||||||
|
|
||||||
async updateItem(item: T & { id?: string }): Promise<T> {
|
async updateItem(item: T & { id?: string }): Promise<T> {
|
||||||
try {
|
try {
|
||||||
const result = await directusClient.request(
|
const result = await directusClient.request(updateItem(this.collectionName, item.id!, item))
|
||||||
updateItem(this.collectionName as keyof MyCollections, item.id!, item),
|
|
||||||
)
|
|
||||||
return result as T
|
return result as T
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
@ -112,9 +110,7 @@ export class itemsApi<T> implements ItemsApi<T> {
|
|||||||
|
|
||||||
async deleteItem(id: string): Promise<boolean> {
|
async deleteItem(id: string): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
const result = await directusClient.request(
|
const result = await directusClient.request(deleteItem(this.collectionName, id))
|
||||||
deleteItem(this.collectionName as keyof MyCollections, id),
|
|
||||||
)
|
|
||||||
return result as unknown as boolean
|
return result as unknown as boolean
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user