@open-commune/web 0.2.16 → 0.2.17
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<section v-if="state !== 'hidden'" class="rounded-xl border border-default bg-default p-5" aria-label="Fréquentation">
|
|
2
|
+
<section v-if="visible && state !== 'hidden'" class="rounded-xl border border-default bg-default p-5" aria-label="Fréquentation">
|
|
3
3
|
<header class="mb-4 flex flex-wrap items-center justify-between gap-2">
|
|
4
4
|
<span class="text-[10.5px] font-semibold uppercase tracking-[.14em] text-dimmed">
|
|
5
5
|
{{ heading }}
|
|
@@ -115,9 +115,11 @@
|
|
|
115
115
|
/**
|
|
116
116
|
* An audience panel: the site's, a collection's or an entry's, read from the
|
|
117
117
|
* instance's `audience.summary`, which asks the configured audience source.
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
118
|
+
* The session says first whether this user may see it (`useAudience().visible`):
|
|
119
|
+
* if not, nothing renders and nothing is asked. A refusal still means no
|
|
120
|
+
* source is configured, this user is not among its viewers, or the source did
|
|
121
|
+
* not answer: the panel then renders nothing at all. Every block the source
|
|
122
|
+
* leaves out is left out here too.
|
|
121
123
|
*/
|
|
122
124
|
import { AUDIENCE_PERIODS } from '@open-commune/core/dtos';
|
|
123
125
|
import AudienceBarList from './audience-bar-list.vue';
|
|
@@ -147,7 +149,8 @@ const DEVICES: Record<string, string> = {
|
|
|
147
149
|
|
|
148
150
|
const period = ref<(typeof PERIODS)[number]>(30);
|
|
149
151
|
const open = ref(false);
|
|
150
|
-
const {
|
|
152
|
+
const { visible, summary } = useAudience();
|
|
153
|
+
const { data, isPending, isError } = summary(
|
|
151
154
|
computed(() => ({
|
|
152
155
|
period: period.value,
|
|
153
156
|
collection: props.collection?.slug,
|
|
@@ -6,12 +6,22 @@ import { computed, toValue, type MaybeRefOrGetter } from 'vue'
|
|
|
6
6
|
* The audience panels' data surface. The instance asks its configured source
|
|
7
7
|
* and keeps the answer a minute itself, so the cache here only spares a
|
|
8
8
|
* screen that comes back. A refusal is final: the panel hides, no retry.
|
|
9
|
+
*
|
|
10
|
+
* `visible` is the session's own answer, decided by the server at auth.me:
|
|
11
|
+
* a source is configured and this user is among its viewers. It is read from
|
|
12
|
+
* the session and not from the `read:audience` ability, which an admin's
|
|
13
|
+
* `manage:all` grants whatever the server said. Nothing is asked while it is
|
|
14
|
+
* false, so a refused user never sees a panel, not even while it loads.
|
|
9
15
|
*/
|
|
10
16
|
export default function useAudience() {
|
|
11
17
|
const trpc = useTrpc()
|
|
18
|
+
const session = useSession()
|
|
19
|
+
|
|
20
|
+
const visible = computed(() => session.user.value?.audience === true)
|
|
12
21
|
|
|
13
22
|
const summary = (ask: MaybeRefOrGetter<AudienceAsk>) =>
|
|
14
23
|
useQuery({
|
|
24
|
+
enabled: visible,
|
|
15
25
|
queryKey: computed(() => {
|
|
16
26
|
const { period, collection, entry } = toValue(ask)
|
|
17
27
|
return ['audience', period, collection ?? null, entry ?? null]
|
|
@@ -22,5 +32,5 @@ export default function useAudience() {
|
|
|
22
32
|
retry: false,
|
|
23
33
|
})
|
|
24
34
|
|
|
25
|
-
return { summary }
|
|
35
|
+
return { visible, summary }
|
|
26
36
|
}
|
package/package.json
CHANGED
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"@iconify/vue": "^5.0.3",
|
|
20
20
|
"@nuxt/kit": "^4.6.1",
|
|
21
21
|
"@nuxt/ui": "^4.12.0",
|
|
22
|
-
"@open-commune/core": "^0.2.
|
|
23
|
-
"@open-commune/editor": "^0.2.
|
|
22
|
+
"@open-commune/core": "^0.2.17",
|
|
23
|
+
"@open-commune/editor": "^0.2.17",
|
|
24
24
|
"@pinia-orm/nuxt": "^2.0.0",
|
|
25
25
|
"@pinia/nuxt": "^1.0.3",
|
|
26
26
|
"@tanstack/vue-query": "^5.104.3",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"description": "The Open Commune application: the admin interface and the server, on a single origin.",
|
|
45
45
|
"license": "AGPL-3.0-or-later",
|
|
46
|
-
"version": "0.2.
|
|
46
|
+
"version": "0.2.17",
|
|
47
47
|
"type": "module",
|
|
48
48
|
"main": "./nuxt.config.ts",
|
|
49
49
|
"files": [
|
|
@@ -26,7 +26,9 @@ export const useWorkspaceStore = defineStore('layout/workspace', () => {
|
|
|
26
26
|
const user = $session.user.value
|
|
27
27
|
$abilities.assignAbilities([
|
|
28
28
|
'entrance:self',
|
|
29
|
-
...(ROLES.find(({ id }) => id === user?.role)?.permissions ?? [])
|
|
29
|
+
...(ROLES.find(({ id }) => id === user?.role)?.permissions ?? []),
|
|
30
|
+
// Decided by the server, not by the role (auth.me's `audience`).
|
|
31
|
+
...(user?.audience === true ? ['read:audience'] : [])
|
|
30
32
|
])
|
|
31
33
|
}
|
|
32
34
|
|