@open-commune/web 0.2.14 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app.config.ts +7 -0
- package/components/data/lists/data-table.vue +203 -0
- package/components/data/lists/row-actions.vue +41 -0
- package/components/elements/badges/status-badge.vue +23 -0
- package/components/elements/media/media-image.vue +26 -0
- package/components/forms/fields/input-files-media.vue +87 -0
- package/components/forms/{inputs → fields}/input-filter-status.vue +2 -2
- package/components/forms/{inputs → fields}/input-search.vue +8 -2
- package/components/forms/fields/input-text-area.vue +86 -0
- package/components/forms/fields/input-text.vue +47 -0
- package/components/forms/fields/select-enum.vue +69 -0
- package/components/forms/handlers/handler-collections.vue +100 -170
- package/components/forms/handlers/handler-list.vue +187 -0
- package/components/forms/handlers/handler-members.vue +171 -0
- package/components/forms/handlers/handler-password-reset.vue +45 -0
- package/components/forms/handlers/handler-roles.vue +28 -166
- package/components/forms/handlers/handler-sessions.vue +77 -0
- package/components/forms/handlers/handler-tokens.vue +54 -69
- package/components/forms/layouts/form-default.vue +99 -0
- package/components/forms/layouts/form.vue +4 -0
- package/components/forms/layouts/forms-layout.vue +236 -0
- package/components/forms/layouts/forms-section.vue +186 -0
- package/components/forms/layouts/layout.vue +4 -0
- package/components/forms/layouts/modal.vue +4 -0
- package/components/forms/layouts/section.vue +4 -0
- package/components/layout/shell/shell-account-menu.vue +10 -2
- package/composables/core/domains/use-api-tokens.ts +80 -0
- package/composables/core/domains/use-auth.ts +56 -2
- package/composables/core/domains/use-definitions.ts +18 -5
- package/composables/core/domains/use-entries.ts +113 -3
- package/composables/core/domains/use-media.ts +24 -1
- package/composables/core/domains/use-members.ts +68 -0
- package/composables/core/domains/use-organization.ts +53 -0
- package/composables/use-models.js +1 -7
- package/constants/errors.ts +28 -0
- package/constants/forms/account.ts +62 -0
- package/constants/forms/collections.ts +39 -0
- package/constants/forms/members.ts +40 -0
- package/constants/forms/organization.ts +188 -0
- package/constants/forms/tokens.ts +15 -0
- package/constants/roles.ts +57 -0
- package/constants/settings.ts +26 -0
- package/constants/statuses.ts +8 -5
- package/package.json +3 -3
- package/pages/[collection]/index.vue +92 -79
- package/pages/account.vue +40 -0
- package/pages/settings.vue +26 -181
- package/plugins/01.validation.client.ts +23 -0
- package/store/layout/workspace.js +4 -28
- package/utils/colors.ts +26 -0
- package/utils/errors.ts +13 -0
- package/utils/forms.ts +67 -0
- package/utils/list-columns.ts +90 -0
- package/utils/settings.ts +38 -0
- package/utils/statuses.ts +4 -0
- package/models/role.js +0 -66
- package/models/token.js +0 -56
- package/models/user.js +0 -97
- package/pages/management/index.vue +0 -15
- package/pages/management/members.vue +0 -176
- package/pages/management/organizations.vue +0 -192
- package/pages/management/roles.vue +0 -183
- /package/components/forms/{inputs → fields}/input-filter.vue +0 -0
|
@@ -1,5 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { PublicationStatus } from '@open-commune/core/collections/constants'
|
|
2
|
+
import { keepPreviousData, useInfiniteQuery, useMutation, useQueries, useQuery, useQueryClient } from '@tanstack/vue-query'
|
|
3
|
+
import { computed, toValue, unref, type MaybeRef, type MaybeRefOrGetter } from 'vue'
|
|
4
|
+
|
|
5
|
+
type ListOptions = {
|
|
6
|
+
status?: PublicationStatus[]
|
|
7
|
+
search?: string
|
|
8
|
+
skip?: number
|
|
9
|
+
limit?: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** What NARROWS a listing, as opposed to what windows it. */
|
|
13
|
+
type Filters = Omit<ListOptions, 'skip' | 'limit'>
|
|
14
|
+
|
|
15
|
+
type Entry = Record<string, unknown>
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The filters alone, the window dropped. The count is taken under them and
|
|
19
|
+
* only them, or the total would describe another set than the rows beside it.
|
|
20
|
+
*/
|
|
21
|
+
const filtersOf = ({ skip: _skip, limit: _limit, ...filters }: ListOptions): Filters => filters
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* An entry has columns (title, slug, status…) and a bag of `data` holding the
|
|
25
|
+
* fields its collection declares. A listing sees one flat object.
|
|
26
|
+
*/
|
|
27
|
+
const flatten = (entry: Entry | null | undefined) => {
|
|
28
|
+
if (!entry) return entry
|
|
29
|
+
const { data, ...columns } = entry as { data?: Entry }
|
|
30
|
+
return { ...columns, ...data }
|
|
31
|
+
}
|
|
3
32
|
|
|
4
33
|
/**
|
|
5
34
|
* Entries domain composable. Keys: ['entries', collectionId] for lists,
|
|
@@ -30,6 +59,80 @@ export default function useEntries() {
|
|
|
30
59
|
enabled: computed(() => Boolean(unref(collectionId))),
|
|
31
60
|
})
|
|
32
61
|
|
|
62
|
+
/**
|
|
63
|
+
* A listing that grows: TanStack's infinite query holds the slices, fetches
|
|
64
|
+
* the next one, and refetches them all when a write invalidates the
|
|
65
|
+
* collection. Collection and filters are in the key, so moving either
|
|
66
|
+
* starts the window over; the rows on screen are kept while the next ones
|
|
67
|
+
* travel, which lets `isPending` mean the first load and nothing else.
|
|
68
|
+
*
|
|
69
|
+
* The total is the server's own count under the same filters, and only
|
|
70
|
+
* them, or it would describe another set than the rows beside it.
|
|
71
|
+
*/
|
|
72
|
+
const infinite = (
|
|
73
|
+
collectionId: MaybeRefOrGetter<string | undefined>,
|
|
74
|
+
options: MaybeRefOrGetter<Filters & { limit?: number }> = {},
|
|
75
|
+
) => {
|
|
76
|
+
const id = computed(() => toValue(collectionId))
|
|
77
|
+
const enabled = computed(() => Boolean(id.value))
|
|
78
|
+
const limit = computed(() => toValue(options).limit ?? 20)
|
|
79
|
+
const filters = computed(() => filtersOf(toValue(options)))
|
|
80
|
+
|
|
81
|
+
const pages = useInfiniteQuery({
|
|
82
|
+
queryKey: computed(() => ['entries', id.value, 'pages', filters.value, limit.value]),
|
|
83
|
+
queryFn: async ({ pageParam }) =>
|
|
84
|
+
(await trpc.collections.entries.list.query({
|
|
85
|
+
collectionId: id.value as string,
|
|
86
|
+
...filters.value,
|
|
87
|
+
skip: pageParam,
|
|
88
|
+
limit: limit.value,
|
|
89
|
+
})).map(flatten) as Entry[],
|
|
90
|
+
initialPageParam: 0,
|
|
91
|
+
// A slice shorter than asked is the last one.
|
|
92
|
+
getNextPageParam: (last, all) => (last.length < limit.value ? undefined : all.flat().length),
|
|
93
|
+
enabled,
|
|
94
|
+
placeholderData: keepPreviousData,
|
|
95
|
+
})
|
|
96
|
+
const counted = useQuery({
|
|
97
|
+
queryKey: computed(() => ['entries', id.value, 'count', filters.value]),
|
|
98
|
+
queryFn: () => trpc.collections.entries.count.query({ collectionId: id.value as string, ...filters.value }),
|
|
99
|
+
enabled,
|
|
100
|
+
placeholderData: keepPreviousData,
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
const records = computed(() => pages.data.value?.pages.flat() ?? [])
|
|
104
|
+
const total = computed(() => counted.data.value ?? null)
|
|
105
|
+
return {
|
|
106
|
+
records,
|
|
107
|
+
total,
|
|
108
|
+
isPending: computed(() => pages.isPending.value || counted.isPending.value),
|
|
109
|
+
isFetching: pages.isFetching,
|
|
110
|
+
isFetchingNextPage: pages.isFetchingNextPage,
|
|
111
|
+
// The count settles the one case the slices cannot: a total that is an
|
|
112
|
+
// exact multiple of the slice.
|
|
113
|
+
hasNextPage: computed(() => Boolean(pages.hasNextPage.value) && (total.value === null || records.value.length < total.value)),
|
|
114
|
+
fetchNextPage: pages.fetchNextPage,
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Several entries by id: a relation column shows titles, the server sends
|
|
120
|
+
* ids. Same keys as `get`, so an entry is not asked for twice.
|
|
121
|
+
*/
|
|
122
|
+
const getMany = (ids: MaybeRefOrGetter<string[] | string | undefined>) => {
|
|
123
|
+
const wanted = computed(() => {
|
|
124
|
+
const value = toValue(ids)
|
|
125
|
+
return (Array.isArray(value) ? value : [value]).filter(Boolean) as string[]
|
|
126
|
+
})
|
|
127
|
+
return useQueries({
|
|
128
|
+
queries: computed(() => wanted.value.map(id => ({
|
|
129
|
+
queryKey: ['entries', 'byId', id],
|
|
130
|
+
queryFn: () => trpc.collections.entries.get.query({ id }),
|
|
131
|
+
}))),
|
|
132
|
+
combine: results => results.map(({ data }) => data).filter(Boolean) as Entry[],
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
|
|
33
136
|
const get = (id: MaybeRef<string>) =>
|
|
34
137
|
useQuery({
|
|
35
138
|
queryKey: computed(() => ['entries', 'byId', unref(id)]),
|
|
@@ -58,5 +161,12 @@ export default function useEntries() {
|
|
|
58
161
|
onSuccess: (_result, { collectionId }) => invalidateCollection(collectionId),
|
|
59
162
|
})
|
|
60
163
|
|
|
61
|
-
|
|
164
|
+
/** How many entries a collection holds, counted on the server. */
|
|
165
|
+
const count = (collectionId: string) =>
|
|
166
|
+
queryClient.fetchQuery({
|
|
167
|
+
queryKey: ['entries', 'count', collectionId],
|
|
168
|
+
queryFn: () => trpc.collections.entries.count.query({ collectionId }),
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
return { list, infinite, get, getMany, count, create, update, remove, invalidateCollection }
|
|
62
172
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { OpenCommuneEditorMedia } from '@open-commune/editor'
|
|
2
|
+
import { readonly, ref, toValue, watch, type MaybeRefOrGetter } from 'vue'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Media domain composable: tRPC calls plus the direct-to-S3 upload step.
|
|
@@ -78,5 +79,27 @@ export default function useMedia() {
|
|
|
78
79
|
/** The upload/resolve pair in the shape the editor extensions expect. */
|
|
79
80
|
const forEditor = (): OpenCommuneEditorMedia => ({ upload, fetch: resolve })
|
|
80
81
|
|
|
81
|
-
|
|
82
|
+
/**
|
|
83
|
+
* A media followed reactively: turning an id into an image took the same
|
|
84
|
+
* ref, watch and catch in every component that shows one. The source is a
|
|
85
|
+
* ref or a getter, so a thumbnail changes media without being remounted.
|
|
86
|
+
*/
|
|
87
|
+
const asset = (source: MaybeRefOrGetter<string | undefined>) => {
|
|
88
|
+
const src = ref('')
|
|
89
|
+
const title = ref('')
|
|
90
|
+
|
|
91
|
+
watch(() => toValue(source), async (id) => {
|
|
92
|
+
if (!id) {
|
|
93
|
+
src.value = title.value = ''
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
const media = await resolve({ id }).catch(() => undefined)
|
|
97
|
+
src.value = media?.src ?? ''
|
|
98
|
+
title.value = media?.title ?? ''
|
|
99
|
+
}, { immediate: true })
|
|
100
|
+
|
|
101
|
+
return { src: readonly(src), title: readonly(title) }
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return { upload, resolve, asset, forEditor }
|
|
82
105
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/vue-query'
|
|
2
|
+
import { computed, toValue, type MaybeRefOrGetter } from 'vue'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Members: who reaches this administration space, and with which role.
|
|
6
|
+
*
|
|
7
|
+
* There is no direct creation — one INVITES. The server sends the mail and
|
|
8
|
+
* returns the link, which stays the fallback when the mail does not arrive.
|
|
9
|
+
*/
|
|
10
|
+
export default function useMembers() {
|
|
11
|
+
const trpc = useTrpc()
|
|
12
|
+
const queryClient = useQueryClient()
|
|
13
|
+
|
|
14
|
+
const invalidate = () => queryClient.invalidateQueries({ queryKey: ['members'] })
|
|
15
|
+
|
|
16
|
+
const list = () =>
|
|
17
|
+
useQuery({ queryKey: ['members'], queryFn: () => trpc.users.list.query() })
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Invitations sent and not yet accepted. Nothing else shows them: an invited
|
|
21
|
+
* person becomes a member only once they have opened their link.
|
|
22
|
+
*/
|
|
23
|
+
const pending = () =>
|
|
24
|
+
useQuery({
|
|
25
|
+
queryKey: ['members', 'pending'],
|
|
26
|
+
queryFn: () => trpc.invitations.list.query(),
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Who is who, readable by any signed-in member: a listing shows the name of
|
|
31
|
+
* whoever last touched an entry, and the server sends an id.
|
|
32
|
+
*/
|
|
33
|
+
const directory = () =>
|
|
34
|
+
useQuery({
|
|
35
|
+
queryKey: ['members', 'directory'],
|
|
36
|
+
queryFn: () => trpc.users.directory.query(),
|
|
37
|
+
staleTime: 5 * 60 * 1000,
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
// Writes are mutation factories: call one in a setup, then `mutateAsync`.
|
|
41
|
+
const invite = () =>
|
|
42
|
+
useMutation({
|
|
43
|
+
mutationFn: ({ email, role = 'redacteur' }: { email: string; role?: 'admin' | 'redacteur' }) =>
|
|
44
|
+
trpc.invitations.create.mutate({ email, role }),
|
|
45
|
+
onSuccess: invalidate,
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const revokeInvitation = () =>
|
|
49
|
+
useMutation({
|
|
50
|
+
mutationFn: (id: string) => trpc.invitations.revoke.mutate({ id }),
|
|
51
|
+
onSuccess: invalidate,
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const update = () =>
|
|
55
|
+
useMutation({
|
|
56
|
+
mutationFn: ({ id, data }: { id: string; data: { name?: string; role?: 'admin' | 'redacteur' } }) =>
|
|
57
|
+
trpc.users.update.mutate({ id, data }),
|
|
58
|
+
onSuccess: invalidate,
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
const remove = () =>
|
|
62
|
+
useMutation({
|
|
63
|
+
mutationFn: (id: string) => trpc.users.remove.mutate({ id }),
|
|
64
|
+
onSuccess: invalidate,
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
return { list, pending, directory, invite, update, remove, revokeInvitation }
|
|
68
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/vue-query'
|
|
2
|
+
import { useWorkspaceStore } from '~/store/layout/workspace'
|
|
3
|
+
|
|
4
|
+
/** What the settings screen may change; the rest is derived. */
|
|
5
|
+
const UPDATABLE = ['name', 'type', 'slug', 'description', 'address', 'deployment', 'settings'] as const
|
|
6
|
+
|
|
7
|
+
type Organization = Awaited<ReturnType<ReturnType<typeof useTrpc>['organization']['get']['query']>>
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The organization — there is exactly one per instance (single-tenant).
|
|
11
|
+
*
|
|
12
|
+
* The logo is stored in `settings.logo`; the settings form edits it as a field
|
|
13
|
+
* of its own, `logo`, so it is lifted out on read and put back on write.
|
|
14
|
+
*/
|
|
15
|
+
export default function useOrganization() {
|
|
16
|
+
const trpc = useTrpc()
|
|
17
|
+
const queryClient = useQueryClient()
|
|
18
|
+
|
|
19
|
+
const query = () =>
|
|
20
|
+
useQuery({
|
|
21
|
+
queryKey: ['organization'],
|
|
22
|
+
queryFn: () => trpc.organization.get.query(),
|
|
23
|
+
select: (organization: Organization) => organization && {
|
|
24
|
+
...organization,
|
|
25
|
+
logo: (organization.settings as { logo?: unknown } | null)?.logo ?? null,
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
/** A mutation factory: call it in a setup, then `mutateAsync(changes)`. */
|
|
30
|
+
const update = () =>
|
|
31
|
+
useMutation({
|
|
32
|
+
mutationFn: (changes: Record<string, unknown>) => {
|
|
33
|
+
const payload: Record<string, unknown> = {}
|
|
34
|
+
for (const key of UPDATABLE) {
|
|
35
|
+
if (changes[key] !== undefined) payload[key] = changes[key]
|
|
36
|
+
}
|
|
37
|
+
if (changes.logo !== undefined) {
|
|
38
|
+
const current = queryClient.getQueryData<Organization>(['organization'])
|
|
39
|
+
payload.settings = { ...(current?.settings ?? {}), ...((payload.settings as object) ?? {}), logo: changes.logo }
|
|
40
|
+
}
|
|
41
|
+
return trpc.organization.update.mutate(payload)
|
|
42
|
+
},
|
|
43
|
+
onSuccess: async () => {
|
|
44
|
+
await queryClient.invalidateQueries({ queryKey: ['organization'] })
|
|
45
|
+
// The shell still reads the organization from the Pinia store, until the
|
|
46
|
+
// store goes (A8): it is refreshed here so a new name or logo shows at once.
|
|
47
|
+
const [legacy] = await useModels().Organization.list()
|
|
48
|
+
if (legacy) useWorkspaceStore().organization = legacy
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
return { query, update }
|
|
53
|
+
}
|
|
@@ -2,9 +2,6 @@ import Organization from '~/models/organization'
|
|
|
2
2
|
import Collection from '~/models/collection'
|
|
3
3
|
import Media from '~/models/media'
|
|
4
4
|
import Record from '~/models/record'
|
|
5
|
-
import Role from '~/models/role'
|
|
6
|
-
import Token from '~/models/token'
|
|
7
|
-
import User from '~/models/user'
|
|
8
5
|
|
|
9
6
|
// @review on pourrait pas déplacer le dossier models dans le dossier composables pour ajouter plus de clareté ? Aussi cette factory me semble un peu alambiquée, pourquoi a t on besoin de passer le model + api url dans un objet exporté par le model lui meme
|
|
10
7
|
// bref, je pense que qu'il y a de l'overengineering ici aussi non ?
|
|
@@ -17,9 +14,6 @@ export default () => {
|
|
|
17
14
|
Organization: new Organization.api(Organization.model, apiURL),
|
|
18
15
|
Collection: new Collection.api(Collection.model, apiURL),
|
|
19
16
|
Media: new Media.api(Media.model, apiURL),
|
|
20
|
-
Record: new Record.api(Record.model, apiURL)
|
|
21
|
-
Role: new Role.api(Role.model, apiURL),
|
|
22
|
-
Token: new Token.api(Token.model, apiURL),
|
|
23
|
-
User: new User.api(User.model, apiURL)
|
|
17
|
+
Record: new Record.api(Record.model, apiURL)
|
|
24
18
|
}
|
|
25
19
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ERROR_TYPES, type ErrorType } from '@open-commune/core/dtos';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The core's refusals, worded. A domain error travels as a `type` and never
|
|
5
|
+
* as a sentence: the core identifies, the interface says. The keys are the
|
|
6
|
+
* core's own catalogue and the record is exhaustive: a refusal the core adds
|
|
7
|
+
* stops this file compiling until it has its sentence.
|
|
8
|
+
*/
|
|
9
|
+
export const REFUSALS: Record<ErrorType, string> = {
|
|
10
|
+
[ERROR_TYPES.COLLECTION_NOT_FOUND]: "Cette collection n'existe plus.",
|
|
11
|
+
[ERROR_TYPES.ENTRY_NOT_FOUND]: "Cette entrée n'existe plus.",
|
|
12
|
+
[ERROR_TYPES.INVALID_ENTRY_DATA]:
|
|
13
|
+
'Certaines valeurs ne correspondent pas aux champs de la collection.',
|
|
14
|
+
[ERROR_TYPES.DUPLICATE_SLUG]: 'Cet identifiant (slug) est déjà utilisé. Choisissez-en un autre.',
|
|
15
|
+
[ERROR_TYPES.MEDIA_NOT_FOUND]: "Ce fichier n'existe plus.",
|
|
16
|
+
[ERROR_TYPES.UNSUPPORTED_MIME]: "Ce type de fichier n'est pas accepté.",
|
|
17
|
+
[ERROR_TYPES.UPLOAD_INCOMPLETE]: "Le fichier n'a pas été reçu en entier. Réessayez.",
|
|
18
|
+
[ERROR_TYPES.ORGANIZATION_NOT_INITIALIZED]: "Cette instance n'est pas encore initialisée.",
|
|
19
|
+
[ERROR_TYPES.ORGANIZATION_ALREADY_INITIALIZED]: 'Cette instance est déjà initialisée.',
|
|
20
|
+
[ERROR_TYPES.DEPLOY_HOOK_MISSING]:
|
|
21
|
+
"La publication du site n'est pas configurée sur cette instance.",
|
|
22
|
+
[ERROR_TYPES.DEPLOY_FAILED]: 'La publication du site a échoué. Réessayez dans un instant.',
|
|
23
|
+
[ERROR_TYPES.USER_NOT_FOUND]: "Ce compte n'existe plus.",
|
|
24
|
+
[ERROR_TYPES.SESSION_NOT_FOUND]: "Cette session n'existe plus.",
|
|
25
|
+
[ERROR_TYPES.INVITATION_INVALID]: "Cette invitation n'est plus valide.",
|
|
26
|
+
[ERROR_TYPES.CANNOT_REMOVE_SELF]: 'Vous ne pouvez pas retirer votre propre compte.',
|
|
27
|
+
[ERROR_TYPES.TOO_MANY_ATTEMPTS]: 'Trop de tentatives. Réessayez dans quelques minutes.',
|
|
28
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { FormTab } from '~/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The account screen, described the way the settings are — same envelope,
|
|
5
|
+
* same `forms-layout` rendering it.
|
|
6
|
+
*
|
|
7
|
+
* Three sections, two of which save nothing: they host a control managing its
|
|
8
|
+
* own data, which `noAction` already names.
|
|
9
|
+
*
|
|
10
|
+
* One TAB per section, not one tab holding three: the account has its own rail
|
|
11
|
+
* now (it left the settings on the 27/08), and a rail lists what it can reach.
|
|
12
|
+
* Stacked in a single tab, the three sections scrolled past one another and
|
|
13
|
+
* the rail had nothing to point at.
|
|
14
|
+
*/
|
|
15
|
+
export const ACCOUNT_FORM: { layout: FormTab[] } = {
|
|
16
|
+
layout: [
|
|
17
|
+
{
|
|
18
|
+
title: 'Profil',
|
|
19
|
+
sections: [
|
|
20
|
+
{
|
|
21
|
+
componentOptions: {
|
|
22
|
+
title: 'Votre nom',
|
|
23
|
+
description: 'Il apparaît dans votre menu de compte et dans la liste des membres.',
|
|
24
|
+
attributes: [
|
|
25
|
+
{
|
|
26
|
+
property: 'name',
|
|
27
|
+
component: 'input-text',
|
|
28
|
+
componentOptions: { name: 'name', label: 'Nom affiché' },
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
title: 'Mot de passe',
|
|
37
|
+
sections: [
|
|
38
|
+
{
|
|
39
|
+
componentOptions: {
|
|
40
|
+
title: 'Mot de passe',
|
|
41
|
+
description: 'Nous vous envoyons un lien pour en choisir un nouveau.',
|
|
42
|
+
noAction: true,
|
|
43
|
+
attributes: [{ componentOptions: {}, component: 'handler-password-reset' }],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
title: 'Appareils connectés',
|
|
50
|
+
sections: [
|
|
51
|
+
{
|
|
52
|
+
componentOptions: {
|
|
53
|
+
title: 'Appareils connectés',
|
|
54
|
+
description: 'Les sessions ouvertes avec votre compte.',
|
|
55
|
+
noAction: true,
|
|
56
|
+
attributes: [{ componentOptions: {}, component: 'handler-sessions' }],
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { FormControl } from '~/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The collection modal, described the way the other forms are.
|
|
5
|
+
*
|
|
6
|
+
* Creating and editing a collection ask for the SAME five fields — only the
|
|
7
|
+
* title and the buttons change with the gesture, and those the handler builds
|
|
8
|
+
* from the action it was given.
|
|
9
|
+
*/
|
|
10
|
+
export const COLLECTION_FORM: FormControl[] = [
|
|
11
|
+
{
|
|
12
|
+
property: 'name',
|
|
13
|
+
component: 'input-text',
|
|
14
|
+
componentOptions: { name: 'name', label: 'Titre de la collection' },
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
property: 'slug',
|
|
18
|
+
component: 'input-text',
|
|
19
|
+
componentOptions: { name: 'slug', label: 'Slug de la collection' },
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
property: 'description',
|
|
23
|
+
component: 'input-text-area',
|
|
24
|
+
componentOptions: { name: 'description', label: 'Description de la collection' },
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
// `fields` is what the server knows (`definitionCreateDto` requires at
|
|
28
|
+
// least one) — the legacy model called this `attributes`, and the stale
|
|
29
|
+
// name made every create fail and every field edit a silent no-op.
|
|
30
|
+
property: 'fields',
|
|
31
|
+
component: 'input-text-area',
|
|
32
|
+
componentOptions: { format: 'json', name: 'fields', label: 'Champ(s) de la collection' },
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
property: 'editor',
|
|
36
|
+
component: 'input-text-area',
|
|
37
|
+
componentOptions: { format: 'json', name: 'editor', label: 'Editeur de la collection' },
|
|
38
|
+
},
|
|
39
|
+
];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { FormControl } from '~/types';
|
|
2
|
+
import { ROLES } from '~/constants/roles';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The two member modals: inviting somebody, and editing somebody already here.
|
|
6
|
+
*
|
|
7
|
+
* They differ by their FIRST field — an address to write to, or a display name
|
|
8
|
+
* to correct — which is why they are two descriptions and not one with a
|
|
9
|
+
* condition.
|
|
10
|
+
*
|
|
11
|
+
* The offered roles come from the frozen list, never from a table copied here.
|
|
12
|
+
*/
|
|
13
|
+
const ROLE_CONTROL: FormControl = {
|
|
14
|
+
property: 'role',
|
|
15
|
+
component: 'select-enum',
|
|
16
|
+
componentOptions: {
|
|
17
|
+
name: 'role',
|
|
18
|
+
label: 'Rôle',
|
|
19
|
+
items: ROLES.map(({ id }) => id),
|
|
20
|
+
object: false,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const MEMBER_INVITE_FORM: FormControl[] = [
|
|
25
|
+
{
|
|
26
|
+
property: 'email',
|
|
27
|
+
component: 'input-text',
|
|
28
|
+
componentOptions: { name: 'email', type: 'email', autoComplete: 'off', label: 'Adresse mail' },
|
|
29
|
+
},
|
|
30
|
+
ROLE_CONTROL,
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
export const MEMBER_UPDATE_FORM: FormControl[] = [
|
|
34
|
+
{
|
|
35
|
+
property: 'name',
|
|
36
|
+
component: 'input-text',
|
|
37
|
+
componentOptions: { name: 'name', label: "Nom d'affichage" },
|
|
38
|
+
},
|
|
39
|
+
ROLE_CONTROL,
|
|
40
|
+
];
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import type { FormTab } from '~/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The organization form, as the settings screen renders it — the same shape a
|
|
5
|
+
* collection's stored `editor` has, written by hand because the organization
|
|
6
|
+
* is not a collection.
|
|
7
|
+
*
|
|
8
|
+
* It lives here rather than inside the page because it is DATA: a hundred
|
|
9
|
+
* lines of layout that change when a setting is added, not when the screen
|
|
10
|
+
* behaves differently.
|
|
11
|
+
*/
|
|
12
|
+
export const ORGANIZATION_FORM: { layout: FormTab[] } = {
|
|
13
|
+
layout: [
|
|
14
|
+
{
|
|
15
|
+
icon: '',
|
|
16
|
+
sections: [
|
|
17
|
+
{
|
|
18
|
+
componentOptions: {
|
|
19
|
+
title: "Logo de l'organisation",
|
|
20
|
+
description: 'Cliquez sur votre logo pour ajouter une image depuis vos fichiers.',
|
|
21
|
+
attributes: [
|
|
22
|
+
{
|
|
23
|
+
property: 'logo',
|
|
24
|
+
componentOptions: {
|
|
25
|
+
name: 'cover',
|
|
26
|
+
limit: 1,
|
|
27
|
+
label: "Logo de l'organisation",
|
|
28
|
+
},
|
|
29
|
+
component: 'input-files-media',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
component: 'form-section-default',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
componentOptions: {
|
|
37
|
+
title: "Nom de l'organisation",
|
|
38
|
+
description:
|
|
39
|
+
'Ces informations seront visibles publiquement, soyez donc attentif avec ce que vous partagerez.',
|
|
40
|
+
attributes: [
|
|
41
|
+
{
|
|
42
|
+
property: 'name',
|
|
43
|
+
componentOptions: {
|
|
44
|
+
previewSlug: false,
|
|
45
|
+
editableSlug: false,
|
|
46
|
+
trim: true,
|
|
47
|
+
placeHolder: "Nom de l'organisation",
|
|
48
|
+
required: true,
|
|
49
|
+
},
|
|
50
|
+
component: 'input-text',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
component: 'form-section-default',
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
title: 'General',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
icon: '',
|
|
61
|
+
sections: [
|
|
62
|
+
{
|
|
63
|
+
componentOptions: {
|
|
64
|
+
title: 'Collections',
|
|
65
|
+
description: 'Les types de contenu du site et leurs champs.',
|
|
66
|
+
attributes: [
|
|
67
|
+
{
|
|
68
|
+
property: 'collections',
|
|
69
|
+
componentOptions: {},
|
|
70
|
+
component: 'handler-collections',
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
noAction: true,
|
|
74
|
+
},
|
|
75
|
+
component: 'form-section-default',
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
title: 'Collections',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
icon: '',
|
|
82
|
+
sections: [
|
|
83
|
+
{
|
|
84
|
+
componentOptions: {
|
|
85
|
+
title: 'Paramètres de déploiement',
|
|
86
|
+
description: 'Renseignez la définition du déploiement.',
|
|
87
|
+
attributes: [
|
|
88
|
+
{
|
|
89
|
+
property: 'deployment',
|
|
90
|
+
componentOptions: {
|
|
91
|
+
format: 'json',
|
|
92
|
+
label: 'Paramètres de déploiement',
|
|
93
|
+
name: 'deployment',
|
|
94
|
+
},
|
|
95
|
+
component: 'input-text-area',
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
component: 'form-section-default',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
componentOptions: {
|
|
103
|
+
title: 'Tokens de déploiement',
|
|
104
|
+
description:
|
|
105
|
+
"Ces tokens permettent d'autres applications à accéder à un contenu restreint de cette organisation.Soyez attentif!",
|
|
106
|
+
attributes: [
|
|
107
|
+
{
|
|
108
|
+
componentOptions: {},
|
|
109
|
+
component: 'handler-tokens',
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
noAction: true,
|
|
113
|
+
},
|
|
114
|
+
component: 'form-section-default',
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
title: 'Déploiement',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
icon: '',
|
|
121
|
+
sections: [
|
|
122
|
+
{
|
|
123
|
+
componentOptions: {
|
|
124
|
+
title: "Configuration de l'injecteur",
|
|
125
|
+
description: 'Définissez les différentes pipelines de données ici',
|
|
126
|
+
attributes: [
|
|
127
|
+
{
|
|
128
|
+
property: 'injector',
|
|
129
|
+
componentOptions: {
|
|
130
|
+
format: 'json',
|
|
131
|
+
label: "Définition de l'injecteur",
|
|
132
|
+
name: 'injector',
|
|
133
|
+
},
|
|
134
|
+
component: 'input-text-area',
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
},
|
|
138
|
+
component: 'form-section-default',
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
title: 'Synchronisation des données',
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
icon: '',
|
|
145
|
+
sections: [
|
|
146
|
+
{
|
|
147
|
+
componentOptions: {
|
|
148
|
+
title: 'Membres',
|
|
149
|
+
description: "Les comptes ayant accès à cet espace d'administration.",
|
|
150
|
+
attributes: [
|
|
151
|
+
{
|
|
152
|
+
componentOptions: {},
|
|
153
|
+
component: 'handler-members',
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
noAction: true,
|
|
157
|
+
},
|
|
158
|
+
component: 'form-section-default',
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
title: 'Membres',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
icon: '',
|
|
165
|
+
sections: [
|
|
166
|
+
{
|
|
167
|
+
componentOptions: {
|
|
168
|
+
title: 'Rôles',
|
|
169
|
+
description:
|
|
170
|
+
'Deux rôles, en consultation : ils sont fixés par Commun et ne se modifient pas depuis cet écran.',
|
|
171
|
+
attributes: [
|
|
172
|
+
{
|
|
173
|
+
componentOptions: {},
|
|
174
|
+
component: 'handler-roles',
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
noAction: true,
|
|
178
|
+
// `handler-roles` draws its own cards: a framed section would sit
|
|
179
|
+
// them inside a second one.
|
|
180
|
+
frameless: true,
|
|
181
|
+
},
|
|
182
|
+
component: 'form-section-default',
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
title: 'Rôles',
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FormControl } from '~/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The token modal: a name, and nothing else.
|
|
5
|
+
*
|
|
6
|
+
* The token itself is never asked for — the server draws it, and hands the
|
|
7
|
+
* plaintext back once, in the creation answer.
|
|
8
|
+
*/
|
|
9
|
+
export const TOKEN_FORM: FormControl[] = [
|
|
10
|
+
{
|
|
11
|
+
property: 'name',
|
|
12
|
+
component: 'input-text',
|
|
13
|
+
componentOptions: { name: 'name', placeHolder: 'ex : site public, application mobile…' },
|
|
14
|
+
},
|
|
15
|
+
];
|