@datagouv/components-next 1.0.2-dev.239 → 1.0.2-dev.240

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.
@@ -261,13 +261,16 @@ function V(e) {
261
261
  function H(e, t) {
262
262
  return `${e.page}${V(t) ? "/community-resources" : ""}?resource_id=${t.id}`;
263
263
  }
264
- function U(e, t, n) {
264
+ function U(e) {
265
+ return e.geopf?.push_status != null || typeof e.geopf?.offering_id == "string";
266
+ }
267
+ function W(e, t, n) {
265
268
  return n ? n(t) : H(e, t);
266
269
  }
267
- function W(e) {
270
+ function G(e) {
268
271
  return e.filesize ? e.filesize : "analysis:content-length" in e.extras ? e.extras["analysis:content-length"] : null;
269
272
  }
270
- var G = [
273
+ var K = [
271
274
  "png",
272
275
  "jpg",
273
276
  "jpeg",
@@ -275,27 +278,27 @@ var G = [
275
278
  "gif",
276
279
  "webp"
277
280
  ];
278
- function K(e) {
279
- return e ? G.includes(e.toLowerCase()) : !1;
280
- }
281
281
  function q(e) {
282
+ return e ? K.includes(e.toLowerCase()) : !1;
283
+ }
284
+ function J(e) {
282
285
  let t = e.extras["analysis:parsing:error"];
283
286
  if (typeof t != "string" || !t) return null;
284
287
  let [n] = t.split(":", 1);
285
288
  return n ?? null;
286
289
  }
287
- function J(e) {
290
+ function Y(e) {
288
291
  let t = e.extras["analysis:parsing:error"];
289
292
  if (typeof t != "string" || !t) return null;
290
293
  let n = t.indexOf(":");
291
294
  return n === -1 ? t : t.slice(n + 1);
292
295
  }
293
- var Y = ["pmtiles_export", "geojson_export"];
294
- function X(e) {
295
- let t = q(e);
296
- return t !== null && !Y.includes(t);
296
+ var X = ["pmtiles_export", "geojson_export"];
297
+ function Z(e) {
298
+ let t = J(e);
299
+ return t !== null && !X.includes(t);
297
300
  }
298
- var Z = (e) => {
301
+ var Q = (e) => {
299
302
  let t = e.extras;
300
303
  if (!t || !("check:cors:allow-origin" in t)) return "unknown";
301
304
  let r = t["check:cors:allow-origin"], i = t["check:cors:allow-methods"], a = n().trustedDomains ?? [], o = r === "*", s = r ? a.some((e) => {
@@ -309,4 +312,4 @@ var Z = (e) => {
309
312
  return c && u ? "allowed" : "blocked";
310
313
  };
311
314
  //#endregion
312
- export { U as _, J as a, H as c, P as d, R as f, K as g, V as h, B as i, W as l, X as m, L as n, q as o, F as p, I as r, Z as s, z as t, N as u, c as v };
315
+ export { q as _, Y as a, H as c, P as d, R as f, U as g, V as h, B as i, G as l, Z as m, L as n, J as o, F as p, I as r, Q as s, z as t, N as u, W as v, c as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datagouv/components-next",
3
- "version": "1.0.2-dev.239",
3
+ "version": "1.0.2-dev.240",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "engines": {
@@ -4,7 +4,8 @@
4
4
  icon-only
5
5
  :icon="RiPencilLine"
6
6
  color="warning"
7
- :title="t('Éditer le fichier')"
7
+ :disabled="!!disabledReason"
8
+ :title="disabledReason ?? t('Éditer le fichier')"
8
9
  data-testid="edit-button"
9
10
  />
10
11
  </template>
@@ -19,10 +20,12 @@ type Props = {
19
20
  datasetId: string
20
21
  isCommunityResource?: boolean
21
22
  resourceId: string
23
+ disabledReason?: string | null
22
24
  }
23
25
 
24
26
  const props = withDefaults(defineProps<Props>(), {
25
27
  isCommunityResource: false,
28
+ disabledReason: null,
26
29
  })
27
30
 
28
31
  const { t } = useTranslation()
@@ -173,6 +173,7 @@
173
173
  :dataset-id="dataset.id"
174
174
  :resource-id="resource.id"
175
175
  :is-community-resource="isCommunityResource"
176
+ :disabled-reason="editDisabledReason"
176
177
  size="xs"
177
178
  />
178
179
  </p>
@@ -327,7 +328,7 @@ import { trackEvent } from '../../functions/matomo'
327
328
  import CopyButton from '../CopyButton.vue'
328
329
  import { useComponentsConfig } from '../../config'
329
330
  import { getOwnerName } from '../../functions/owned'
330
- import { getResourceFormatIcon, getResourceTitleId, detectOgcService, getResourceFilesize, isImagePreviewFormat, resolveResourceExternalUrl } from '../../functions/resources'
331
+ import { getResourceFormatIcon, getResourceTitleId, detectOgcService, getResourceFilesize, isGeopfSynced, isImagePreviewFormat, resolveResourceExternalUrl } from '../../functions/resources'
331
332
  import BrandedButton from '../BrandedButton.vue'
332
333
  import { useTranslation } from '../../composables/useTranslation'
333
334
  import { useHasTabularData } from '../../composables/useHasTabularData'
@@ -384,6 +385,10 @@ const hasPmtiles = computed(() => {
384
385
  return props.resource.extras['analysis:parsing:pmtiles_url'] || props.resource.format === 'pmtiles'
385
386
  })
386
387
 
388
+ const editDisabledReason = computed(() => {
389
+ return isGeopfSynced(props.resource) ? t('Vous ne pouvez pas modifier cette ressource car elle est synchronisée avec cartes.gouv.fr') : null
390
+ })
391
+
387
392
  const hasDatafairPreview = computed(() => {
388
393
  // Checks if there are the corresponding extras for a datafair preview.
389
394
  // Limited only to datasets published by certified organizations since it will load an iframe.
@@ -179,6 +179,10 @@ export function getResourceExternalUrl(dataset: Dataset | DatasetV2 | Omit<Datas
179
179
  return `${dataset.page}${isCommunityResource(resource) ? '/community-resources' : ''}?resource_id=${resource.id}`
180
180
  }
181
181
 
182
+ export function isGeopfSynced(resource: Resource | CommunityResource): boolean {
183
+ return resource.geopf?.push_status != null || typeof resource.geopf?.offering_id === 'string'
184
+ }
185
+
182
186
  export function resolveResourceExternalUrl<R extends Resource | CommunityResource>(
183
187
  dataset: Dataset | DatasetV2 | Omit<Dataset, 'resources' | 'community_resources'>,
184
188
  resource: R,
@@ -12,6 +12,11 @@ export type FileResourceFileType = 'file'
12
12
 
13
13
  export type ResourceFileType = RemoteResourceFileType | FileResourceFileType
14
14
 
15
+ export type GeopfResourceMetadata = {
16
+ push_status?: 'pending' | 'done' | 'error' | 'timeout' | null
17
+ offering_id?: string | null
18
+ }
19
+
15
20
  export type Resource = {
16
21
  id: string
17
22
  title: string
@@ -22,6 +27,7 @@ export type Resource = {
22
27
  extras: Record<string, unknown>
23
28
  metrics: { views: number }
24
29
  harvest: Harvest
30
+ geopf: GeopfResourceMetadata | null
25
31
  filesize: number | null
26
32
  filetype: ResourceFileType
27
33
  format: string