@tekkare/romulus 0.1.261 → 0.1.263

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.
Files changed (28) hide show
  1. package/dist/module.json +1 -1
  2. package/layer/app/components/layout/viewEmptyState.vue +11 -2
  3. package/layer/app/components/panels/OipPanelProjects.vue +70 -21
  4. package/layer/app/components/project/AddButton.vue +127 -0
  5. package/layer/app/components/project/Banner.vue +68 -0
  6. package/layer/app/components/project/Dashboard.vue +85 -0
  7. package/layer/app/components/project/DiscardConfirm.vue +74 -0
  8. package/layer/app/components/project/Documents.vue +611 -0
  9. package/layer/app/components/project/Export.vue +205 -0
  10. package/layer/app/components/project/Inbox.vue +1241 -0
  11. package/layer/app/components/project/ListPage.vue +102 -0
  12. package/layer/app/components/project/NewButton.vue +147 -0
  13. package/layer/app/components/project/Notes.vue +1158 -0
  14. package/layer/app/components/project/Page.vue +820 -0
  15. package/layer/app/components/project/Share.vue +135 -0
  16. package/layer/app/components/project/Watch.vue +273 -0
  17. package/layer/app/composables/useOipProjectKinds.ts +71 -0
  18. package/layer/app/composables/useOipResourceHooks.ts +8 -3
  19. package/layer/app/composables/useProjectDashboard.ts +22 -0
  20. package/layer/app/composables/useProjects.ts +646 -0
  21. package/layer/app/oip-defaults/projects.ts +175 -0
  22. package/layer/app/pages/projects/[id].vue +8 -0
  23. package/layer/app/pages/projects/index.vue +8 -0
  24. package/layer/app/types/projects.ts +168 -0
  25. package/layer/app/utils/projectNoteWelcome.ts +137 -0
  26. package/layer/nuxt.config.ts +16 -0
  27. package/layer/server/api/oip/sharing/artifacts.get.ts +44 -0
  28. package/package.json +2 -1
@@ -0,0 +1,135 @@
1
+ <!--
2
+ Le partage d'un projet dans l'espace de travail (repris de France
3
+ Augmented Science et de fr_drugs_app).
4
+
5
+ L'API le dit en deux registres, que le dialogue fond en un seul choix :
6
+ `isShared` ouvre le projet a tout l'espace, `/projects/:id/users` l'ouvre a
7
+ des personnes choisies. Repasser en prive retire tout le monde sauf le
8
+ proprietaire : on repart donc de zero avant d'inscrire la liste choisie.
9
+ Seul le proprietaire peut changer le partage : la page ne montre le bouton
10
+ qu'a lui.
11
+ -->
12
+ <template>
13
+ <RmShareDialog
14
+ :model-value="modelValue"
15
+ :title="title"
16
+ :members="members"
17
+ :visibility="isShared ? 'workspace' : 'private'"
18
+ :shared-with="isShared ? [] : sharedIds"
19
+ :texts="texts"
20
+ :loading="busy"
21
+ :lang="en ? 'en' : 'fr'"
22
+ @update:model-value="(value: boolean) => emit('update:modelValue', value)"
23
+ @save="save"
24
+ />
25
+ </template>
26
+
27
+ <script setup lang="ts">
28
+ import { useOipApi } from "#oip-app/api";
29
+ import { oipSnackbar } from "#oip-app/ui";
30
+ import type { ProjectUser } from "../../types/projects";
31
+
32
+ const props = defineProps<{
33
+ modelValue: boolean;
34
+ projectId: string;
35
+ title: string;
36
+ isShared: boolean;
37
+ ownerId: string;
38
+ /** Qui a acces au projet aujourd'hui, proprietaire compris. */
39
+ users: ProjectUser[];
40
+ }>();
41
+
42
+ const emit = defineEmits<{
43
+ "update:modelValue": [value: boolean];
44
+ saved: [value: { isShared: boolean; users: ProjectUser[] }];
45
+ }>();
46
+
47
+ const { locale } = useI18n();
48
+ const en = computed(() => locale.value === "en");
49
+ const api = useOipApi();
50
+ const projects = useProjects();
51
+
52
+ const members = ref<{ userId: string; name: string; email?: string }[]>([]);
53
+ const busy = ref(false);
54
+
55
+ const texts = computed(() =>
56
+ en.value
57
+ ? {
58
+ heading: "Share the project",
59
+ privateHint: "Nobody else sees this project.",
60
+ peopleHint: "They can read, file and comment in the project.",
61
+ workspaceHint: "Every member of the workspace can open it.",
62
+ }
63
+ : {
64
+ heading: "Partager le projet",
65
+ privateHint: "Personne d'autre ne voit ce projet.",
66
+ peopleHint: "Elles peuvent le lire, y ranger des fiches et commenter.",
67
+ workspaceHint: "Chaque membre de l'espace de travail peut l'ouvrir.",
68
+ },
69
+ );
70
+
71
+ /** Les destinataires nommes : le proprietaire n'en est pas un. */
72
+ const sharedIds = computed(() =>
73
+ props.users.map((user) => user.userId).filter((id): id is string => !!id && id !== props.ownerId),
74
+ );
75
+
76
+ // Les membres de l'espace ne se chargent qu'a l'ouverture du dialogue.
77
+ watch(
78
+ () => props.modelValue,
79
+ async (open) => {
80
+ if (!open || members.value.length) return;
81
+ try {
82
+ const response = await api.profile.getWorkspaceMembers();
83
+ members.value = (response?.members ?? [])
84
+ .filter((member) => member.userId !== props.ownerId)
85
+ .map((member) => ({
86
+ userId: member.userId,
87
+ name: member.displayName || [member.firstName, member.lastName].filter(Boolean).join(" ") || member.email,
88
+ email: member.email,
89
+ }));
90
+ } catch (error) {
91
+ console.error("[projects] Error loading workspace members:", error);
92
+ }
93
+ },
94
+ { immediate: true },
95
+ );
96
+
97
+ function notify(text: string) {
98
+ oipSnackbar([
99
+ { attribute: "isVisible", value: true },
100
+ { attribute: "text", value: text },
101
+ { attribute: "hasTimeOut", value: true },
102
+ ]);
103
+ }
104
+
105
+ async function save(share: { visibility: "private" | "workspace"; sharedWith: string[] }) {
106
+ busy.value = true;
107
+ try {
108
+ if (share.visibility === "workspace") {
109
+ if (!props.isShared) await projects.update(props.projectId, { isShared: true });
110
+ } else {
111
+ // Sortir du partage a tout l'espace retire deja chaque membre.
112
+ if (props.isShared) await projects.update(props.projectId, { isShared: false });
113
+ const current = props.isShared ? [] : sharedIds.value;
114
+ const added = share.sharedWith.filter((id) => !current.includes(id));
115
+ const removed = current.filter((id) => !share.sharedWith.includes(id));
116
+ await Promise.all([
117
+ ...added.map((id) => api.projects.addUser(props.projectId, id)),
118
+ ...removed.map((id) => api.projects.removeUser(props.projectId, id)),
119
+ ]);
120
+ }
121
+ const response = await api.projects.getUsers(props.projectId);
122
+ emit("saved", { isShared: share.visibility === "workspace", users: response?.users ?? [] });
123
+ emit("update:modelValue", false);
124
+ notify(en.value ? "Sharing updated" : "Partage mis à jour");
125
+ } catch (error: any) {
126
+ notify(
127
+ error?.data?.error ||
128
+ error?.data?.message ||
129
+ (en.value ? "Sharing could not be saved" : "Le partage n'a pas pu être enregistré"),
130
+ );
131
+ } finally {
132
+ busy.value = false;
133
+ }
134
+ }
135
+ </script>
@@ -0,0 +1,273 @@
1
+ <!--
2
+ ProjectWatch - le suivi du projet : une alerte sur les fiches qu'il range
3
+ (repris de France Augmented Science, d'OIP Case Atlas et de fr_drugs_app).
4
+
5
+ Le suivi est personnel : « Suivre » n'abonne que soi. L'API ne garde qu'une
6
+ alerte par projet, que le premier abonne cree et que les suivants
7
+ rejoignent (le moteur ne compare donc le projet qu'une fois), et elle part
8
+ avec son dernier abonne. Une alerte de projet n'est listee qu'a ceux qui la
9
+ suivent : absente de la liste, c'est que je ne suis pas le projet. Le
10
+ perimetre n'a pas a etre rearme : l'API relit les ressources du projet a
11
+ chaque passage, un element ajoute entre sans bruit dans le suivi.
12
+
13
+ Seules les familles de `projectAlertSpecs` (#oip-app/projects) sont
14
+ suivies, sur les champs que l'app choisit. Ce que d'autres apps ont range
15
+ dans le projet n'est pas suivi d'ici. Une app qui n'en declare aucune n'a
16
+ pas de bouton (cf. la page du projet).
17
+
18
+ Un bouton de l'en-tete de la page projet, a cote de Partager : le suivi
19
+ regle le projet entier, il n'appartient a aucun onglet. Il vivait en carte
20
+ sous la vue d'ensemble, ou on ne le trouvait qu'en descendant, et seulement
21
+ sur cet onglet. Le reglage s'ouvre dans un panneau accroche au bouton.
22
+ La pastille de la tuile Alertes compte ses non-lus comme ceux des vues.
23
+ -->
24
+ <template>
25
+ <span ref="anchor" class="project_watch_anchor">
26
+ <RmButton
27
+ :variant="alert ? 'secondary' : 'tertiary'"
28
+ :prefix-icon="alert ? 'BellRinging' : 'Bell'"
29
+ @click="open = !open"
30
+ >
31
+ {{ alert ? (en ? "Watched" : "Suivi") : en ? "Watch" : "Suivre" }}
32
+ </RmButton>
33
+ </span>
34
+
35
+ <RmPopover
36
+ v-model="open"
37
+ :anchor="anchor"
38
+ :label="en ? 'Project watch' : 'Suivi du projet'"
39
+ width="340px"
40
+ >
41
+ <div class="project_watch_head">
42
+ <span class="project_watch_title">{{ en ? "Project watch" : "Suivi du projet" }}</span>
43
+ <RmTag v-if="alert" :variant="statusTag.variant">{{ statusTag.label }}</RmTag>
44
+ </div>
45
+
46
+ <template v-if="!alert">
47
+ <p class="project_watch_text">
48
+ {{
49
+ en
50
+ ? `Get told when ${PROJECT_WORDING.watch.en} on the ${watchable} tracked item${watchable > 1 ? "s" : ""} of this project, and when one is withdrawn. Only you receive it: each member chooses to follow or not.`
51
+ : `Soyez prévenu quand ${PROJECT_WORDING.watch.fr} sur ${watchable === 1 ? "l'élément suivi" : `les ${watchable} éléments suivis`} de ce projet, ou quand l'un d'eux est retiré. Vous seul le recevez : chaque membre choisit de suivre ou non.`
52
+ }}
53
+ </p>
54
+ <p v-if="untracked" class="project_watch_note">
55
+ {{
56
+ en
57
+ ? `${untracked} item${untracked > 1 ? "s are" : " is"} not watched from this app (filed from another app).`
58
+ : `${untracked} élément${untracked > 1 ? "s" : ""} ne ${untracked > 1 ? "sont" : "est"} pas suivi${untracked > 1 ? "s" : ""} depuis cette app (rangé${untracked > 1 ? "s" : ""} depuis une autre app).`
59
+ }}
60
+ </p>
61
+ <div class="project_watch_row">
62
+ <RmSegmented v-model="cadence" :options="cadenceOptions" size="sm" variant="soft" />
63
+ <RmButton prefix-icon="Bell" :loading="busy" @click="start">
64
+ {{ en ? "Watch this project" : "Suivre ce projet" }}
65
+ </RmButton>
66
+ </div>
67
+ </template>
68
+
69
+ <template v-else>
70
+ <p class="project_watch_text">
71
+ {{ statusText }}
72
+ </p>
73
+ <div class="project_watch_row">
74
+ <RmSegmented
75
+ :model-value="alert.cadence"
76
+ :options="cadenceOptions"
77
+ size="sm"
78
+ variant="soft"
79
+ @update:model-value="setCadence"
80
+ />
81
+ <RmSwitch
82
+ :model-value="alert.channels.includes('email')"
83
+ :active-text="en ? 'Email' : 'E-mail'"
84
+ :inactive-text="en ? 'In app only' : 'Dans l’app seulement'"
85
+ @update:model-value="setEmail"
86
+ />
87
+ </div>
88
+ <div class="project_watch_actions">
89
+ <RmButton
90
+ variant="text-danger"
91
+ size="sm"
92
+ prefix-icon="BellSlash"
93
+ :loading="busy"
94
+ @click="stop"
95
+ >
96
+ {{ en ? "Stop following" : "Ne plus suivre" }}
97
+ </RmButton>
98
+ </div>
99
+ </template>
100
+
101
+ <p v-if="error" class="project_watch_error">{{ error }}</p>
102
+ </RmPopover>
103
+ </template>
104
+
105
+ <script setup lang="ts">
106
+ import { useOipApi } from "#oip-app/api";
107
+ import { PROJECT_WORDING, WATCHABLE_PROJECT_TYPES, projectAlertSpecs } from "#oip-projects";
108
+ import type { ProjectItem } from "../../composables/useProjects";
109
+
110
+ const props = defineProps<{
111
+ projectId: string;
112
+ projectTitle: string;
113
+ items: ProjectItem[];
114
+ }>();
115
+
116
+ const { locale } = useI18n();
117
+ const en = computed(() => locale.value === "en");
118
+ const config = useRuntimeConfig().public as Record<string, any>;
119
+ const elysiaApi = useOipApi();
120
+ const alerts = useAlerts();
121
+
122
+ onMounted(() => alerts.load());
123
+
124
+ const anchor = ref<HTMLElement | null>(null);
125
+ const open = ref(false);
126
+
127
+ const alert = computed(() =>
128
+ alerts.alerts.value.find((entry) => entry.kind === "project" && entry.projectId === props.projectId),
129
+ );
130
+
131
+ const watchable = computed(
132
+ () => props.items.filter((item) => WATCHABLE_PROJECT_TYPES.includes(item.resourceType)).length,
133
+ );
134
+ const untracked = computed(() => props.items.length - watchable.value);
135
+
136
+ const cadence = ref("daily");
137
+ const cadenceOptions = computed(() => [
138
+ { value: "daily", label: en.value ? "Daily" : "Quotidien" },
139
+ { value: "weekly", label: en.value ? "Weekly" : "Hebdomadaire" },
140
+ { value: "monthly", label: en.value ? "Monthly" : "Mensuel" },
141
+ ]);
142
+
143
+ const statusTag = computed(() => {
144
+ const status = alert.value?.status;
145
+ if (status === "seeding") return { variant: "gray" as const, label: en.value ? "Preparing" : "En préparation" };
146
+ if (status === "paused") return { variant: "gray" as const, label: en.value ? "Paused" : "En pause" };
147
+ if (status === "failing") return { variant: "rose" as const, label: en.value ? "Failing" : "En échec" };
148
+ return { variant: "teal" as const, label: en.value ? "Active" : "Actif" };
149
+ });
150
+
151
+ const statusText = computed(() => {
152
+ const a = alert.value!;
153
+ const n = a.trackedCount;
154
+ if (a.status === "seeding") {
155
+ return en.value ? "Capturing the reference, nothing is reported yet." : "Capture de la référence, rien n'est encore signalé.";
156
+ }
157
+ if (a.status === "failing") {
158
+ return en.value
159
+ ? "The last run was refused. The watch resumes on its own at the next clean run."
160
+ : "Le dernier passage a été refusé. Le suivi reprend seul au prochain passage sans incident.";
161
+ }
162
+ return en.value
163
+ ? `${n} item${n > 1 ? "s" : ""} watched. Items added to the project join the watch on their own.`
164
+ : `${n} élément${n > 1 ? "s" : ""} suivi${n > 1 ? "s" : ""}. Les éléments ajoutés au projet rejoignent le suivi d'eux-mêmes.`;
165
+ });
166
+
167
+ const busy = ref(false);
168
+ const error = ref("");
169
+
170
+ async function run(action: () => Promise<unknown>) {
171
+ busy.value = true;
172
+ error.value = "";
173
+ try {
174
+ await action();
175
+ } catch (e: any) {
176
+ error.value = en.value ? "The change did not go through. Try again." : "Le changement n'est pas passé. Réessayez.";
177
+ console.error("[ProjectWatch]", e);
178
+ } finally {
179
+ busy.value = false;
180
+ }
181
+ }
182
+
183
+ function start() {
184
+ return run(async () => {
185
+ const { resourceSpecs, fieldLabels } = projectAlertSpecs(en.value ? "en" : "fr");
186
+ await elysiaApi.alerts.create({
187
+ kind: "project",
188
+ projectId: props.projectId,
189
+ title: props.projectTitle,
190
+ resourceSpecs,
191
+ fieldLabels,
192
+ url: `${window.location.origin}${window.location.pathname}`,
193
+ appName: config.app_name,
194
+ channels: ["in_app", "email"],
195
+ cadence: cadence.value,
196
+ });
197
+ await alerts.load(true);
198
+ alerts.followSeeding();
199
+ });
200
+ }
201
+
202
+ function setCadence(value: string | number | undefined) {
203
+ if (!alert.value || !value) return;
204
+ const id = alert.value.id;
205
+ return run(() => alerts.update(id, { cadence: String(value) }));
206
+ }
207
+
208
+ function setEmail(on: boolean) {
209
+ if (!alert.value) return;
210
+ const id = alert.value.id;
211
+ return run(() => alerts.update(id, { channels: on ? ["in_app", "email"] : ["in_app"] }));
212
+ }
213
+
214
+ function stop() {
215
+ if (!alert.value) return;
216
+ const id = alert.value.id;
217
+ return run(() => alerts.remove(id));
218
+ }
219
+ </script>
220
+
221
+ <style scoped>
222
+ .project_watch_anchor {
223
+ display: inline-flex;
224
+ }
225
+
226
+ .project_watch_head {
227
+ display: flex;
228
+ align-items: center;
229
+ justify-content: space-between;
230
+ gap: 12px;
231
+ margin-bottom: 8px;
232
+ }
233
+
234
+ .project_watch_title {
235
+ color: var(--text-primary);
236
+ font-size: 14px;
237
+ font-weight: 600;
238
+ }
239
+
240
+ .project_watch_text {
241
+ margin: 0 0 8px;
242
+ color: var(--text-secondary);
243
+ font-size: 13px;
244
+ }
245
+
246
+ .project_watch_note {
247
+ margin: 0 0 12px;
248
+ color: var(--text-muted);
249
+ font-size: 12px;
250
+ }
251
+
252
+ .project_watch_row {
253
+ display: flex;
254
+ flex-wrap: wrap;
255
+ align-items: center;
256
+ justify-content: space-between;
257
+ gap: 12px;
258
+ margin-top: 12px;
259
+ }
260
+
261
+ .project_watch_actions {
262
+ display: flex;
263
+ flex-wrap: wrap;
264
+ gap: 8px;
265
+ margin-top: 12px;
266
+ }
267
+
268
+ .project_watch_error {
269
+ margin: 8px 0 0;
270
+ color: var(--error);
271
+ font-size: 12px;
272
+ }
273
+ </style>
@@ -0,0 +1,71 @@
1
+ import type { RmProjectDocuments, RmProjectKind } from "@tekkare/romulus/utils/projects";
2
+ import { PROJECT_KINDS } from "#oip-projects";
3
+ import {
4
+ OIP_RESOURCE_ALIASES,
5
+ OIP_RESOURCE_SPECS,
6
+ oipResourceAppUrl,
7
+ oipResourceViewSpec,
8
+ } from "../utils/oipResources";
9
+ import { oipEsSearch, oipHydrate } from "./useOipResources";
10
+
11
+ /**
12
+ * Les familles qu'un projet sait lister, dans n'importe quelle app : toutes
13
+ * celles du layer (OIP_RESOURCE_SPECS, alias compris), celles de l'app
14
+ * d'abord (`oip.resourceApp`), dans l'ordre du registre. Un type que personne
15
+ * ne decrit reste dans le projet, cache, et ne compte pas.
16
+ *
17
+ * Le lien d'une famille de l'app reste relatif (sans prefixe de langue) ;
18
+ * celui d'une autre app est deja absolu et mene a son app d'origine.
19
+ * `PROJECT_KINDS` (#oip-app/projects) remplace la description d'un type
20
+ * quand l'app le relit avec plus de champs.
21
+ */
22
+ export function useOipProjectKinds(): RmProjectKind[] {
23
+ const own = String(useAppConfig().oip?.resourceApp ?? "");
24
+ const overrides = new Map(PROJECT_KINDS.map((kind) => [kind.type, kind]));
25
+ const types = [...OIP_RESOURCE_SPECS.map((spec) => spec.type), ...Object.keys(OIP_RESOURCE_ALIASES)];
26
+ const kinds = types.map((type) => {
27
+ const spec = oipResourceViewSpec(type)!;
28
+ const mine = spec.app === own;
29
+ const kind: RmProjectKind = {
30
+ ...(overrides.get(type) ?? spec.kind),
31
+ type,
32
+ path: (s, id) => (mine ? spec.detailPath(id, undefined, s) : oipResourceAppUrl(spec.app, spec.detailPath(id, undefined, s), "fr")),
33
+ };
34
+ return { kind, mine };
35
+ });
36
+ return [...kinds.filter((k) => k.mine), ...kinds.filter((k) => !k.mine)].map((k) => k.kind);
37
+ }
38
+
39
+ /**
40
+ * Relit les documents des elements d'un projet par le proxy du layer
41
+ * (/api/oip/es), une requete par famille, avec la cle de son cluster. Un
42
+ * index injoignable ne vide pas la page : ses elements gardent leur id.
43
+ */
44
+ export async function oipProjectHydrate(
45
+ items: { resourceId: string; resourceType: string }[],
46
+ kinds: RmProjectKind[],
47
+ ): Promise<RmProjectDocuments> {
48
+ const byType = new Map<string, string[]>();
49
+ for (const item of items) {
50
+ if (!kinds.some((kind) => kind.type === item.resourceType)) continue;
51
+ byType.set(item.resourceType, [...(byType.get(item.resourceType) ?? []), item.resourceId]);
52
+ }
53
+ const overrides = new Set(PROJECT_KINDS.map((kind) => kind.type));
54
+ const entries = await Promise.all(
55
+ [...byType].map(async ([type, list]) => {
56
+ const ids = [...new Set(list)];
57
+ const read = async (): Promise<Record<string, any>> => {
58
+ if (!overrides.has(type)) return oipHydrate(OIP_RESOURCE_ALIASES[type] ?? type, ids);
59
+ const kind = kinds.find((k) => k.type === type)!;
60
+ const response = await oipEsSearch<any>(oipResourceViewSpec(type)!.cluster, kind.index, {
61
+ size: ids.length,
62
+ ...(kind.source ? { _source: kind.source } : {}),
63
+ query: { ids: { values: ids } },
64
+ });
65
+ return Object.fromEntries((response?.hits?.hits ?? []).map((hit: any) => [String(hit._id), hit._source]));
66
+ };
67
+ return [type, await read().catch(() => ({}))] as const;
68
+ }),
69
+ );
70
+ return Object.fromEntries(entries);
71
+ }
@@ -1,4 +1,4 @@
1
- import type { Component, InjectionKey } from "vue";
1
+ import { defineAsyncComponent, type Component, type InjectionKey } from "vue";
2
2
 
3
3
  /**
4
4
  * Ce que l'app prete aux vues de ressources du layer, et qu'elles ne peuvent
@@ -8,7 +8,9 @@ import type { Component, InjectionKey } from "vue";
8
8
  *
9
9
  * nuxtApp.vueApp.provide(OIP_RESOURCE_HOOKS, { projectButton, openSource })
10
10
  *
11
- * Absents, la vue s'en passe : pas de bouton, source non cliquable.
11
+ * Sans `projectButton`, le bouton Projet du layer (ProjectAddButton, branche
12
+ * sur useProjects) ; `projectButton: null` n'en met aucun. Sans
13
+ * `openSource`, la source n'est pas cliquable.
12
14
  */
13
15
  export interface OipResourceHooks {
14
16
  /**
@@ -22,6 +24,9 @@ export interface OipResourceHooks {
22
24
 
23
25
  export const OIP_RESOURCE_HOOKS: InjectionKey<OipResourceHooks> = Symbol("oip-resource-hooks");
24
26
 
27
+ const LAYER_PROJECT_BUTTON = defineAsyncComponent(() => import("../components/project/AddButton.vue"));
28
+
25
29
  export function useOipResourceHooks(): OipResourceHooks {
26
- return inject(OIP_RESOURCE_HOOKS, {});
30
+ const hooks = inject(OIP_RESOURCE_HOOKS, {});
31
+ return hooks.projectButton === undefined ? { ...hooks, projectButton: LAYER_PROJECT_BUTTON } : hooks;
27
32
  }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Le tableau de bord d'un projet et son branchement sur l'API
3
+ * (`projects.dashboard`, un par projet, commun aux membres et aux apps).
4
+ * Le catalogue et le tableau de depart viennent de l'app
5
+ * (#oip-app/projects), sinon le seul contenu du projet.
6
+ *
7
+ * Tout le reste (sauvegarde temporisee, repli tant que rien n'est
8
+ * enregistre, kinds inconnus conserves) est a useRmDashboard, dans Romulus.
9
+ */
10
+
11
+ import { useOipApi } from "#oip-app/api";
12
+ import { PROJECT_DASHBOARD_WIDGETS, defaultProjectDashboard } from "#oip-projects";
13
+
14
+ export function useProjectDashboard(projectId: string) {
15
+ const api = useOipApi();
16
+ return useRmDashboard({
17
+ catalog: PROJECT_DASHBOARD_WIDGETS,
18
+ load: async () => (await api.projects.getDashboard(projectId))?.dashboard ?? null,
19
+ save: (dashboard) => api.projects.saveDashboard(projectId, dashboard),
20
+ defaults: defaultProjectDashboard,
21
+ });
22
+ }