-
Notifications
You must be signed in to change notification settings - Fork 5
feat!(datagouv-components): explode DatasetInformationPanel into multiple components #912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ThibaudDauce
wants to merge
5
commits into
main
Choose a base branch
from
extract_dataset_information_to_datagouv_components
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c381810
feat!(datagouv-components): explode DatasetInformationPanel into mult…
ThibaudDauce 018812e
remove some props
ThibaudDauce cf938f6
add default get tag url
ThibaudDauce 4645aac
extract LicenseBadge
ThibaudDauce aa0a1e1
fix lint
ThibaudDauce File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
datagouv-components/src/components/DatasetInformation/DatasetEmbedSection.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| <template> | ||
| <div class="space-y-1 py-6"> | ||
| <div class="flex items-center space-x-2 mb-1"> | ||
| <h3 class="mb-0 uppercase text-gray-plain text-sm font-bold"> | ||
| {{ t('Intégrer sur votre site') }} | ||
| </h3> | ||
| <CopyButton | ||
| :hide-label="true" | ||
| :label="t('Copier le code embarqué')" | ||
| :copied-label="t('Code embarqué copié !')" | ||
| :text="embedHtml" | ||
| /> | ||
| </div> | ||
| <textarea | ||
| ref="textAreaRef" | ||
| class="bg-gray-lower text-gray-medium rounded font-mono text-sm px-1 py-[2px] w-full border resize-none" | ||
| :value="embedHtml" | ||
| readonly="true" | ||
| @click="selectContent" | ||
| /> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { ref, computed } from 'vue' | ||
| import { useTranslation } from '../../composables/useTranslation' | ||
| import { getDatasetOEmbedHtml } from '../../functions/datasets' | ||
| import type { Dataset, DatasetV2, DatasetV2WithFullObject } from '../../types/datasets' | ||
| import CopyButton from '../CopyButton.vue' | ||
|
|
||
| const props = defineProps<{ | ||
| dataset: Dataset | DatasetV2 | DatasetV2WithFullObject | ||
| }>() | ||
|
|
||
| const { t } = useTranslation() | ||
| const textAreaRef = ref<HTMLTextAreaElement | null>(null) | ||
|
|
||
| const embedHtml = computed(() => getDatasetOEmbedHtml('dataset', props.dataset.id)) | ||
|
|
||
| function selectContent(e: Event) { | ||
| (e.target as HTMLTextAreaElement).select() | ||
| } | ||
| </script> |
73 changes: 73 additions & 0 deletions
73
datagouv-components/src/components/DatasetInformation/DatasetInformationSection.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| <template> | ||
| <div class="space-y-1 py-6"> | ||
| <h3 class="uppercase text-gray-plain text-sm font-bold"> | ||
| {{ t('Informations') }} | ||
| </h3> | ||
| <DescriptionList> | ||
| <div v-if="dataset.tags && dataset.tags.length"> | ||
| <DescriptionListTerm>{{ t('Mots-clés') }}</DescriptionListTerm> | ||
| <DescriptionListDetails class="flex flex-wrap gap-2 items-start"> | ||
| <AppLink | ||
| v-for="tag in dataset.tags" | ||
| :key="tag" | ||
| class="fr-raw-link" | ||
| :to="getTagUrl(tag)" | ||
| > | ||
| <Tag type="secondary"> | ||
| {{ tag }} | ||
| </Tag> | ||
| </AppLink> | ||
| </DescriptionListDetails> | ||
| </div> | ||
| <div> | ||
| <DescriptionListTerm>{{ t('Identifiant') }}</DescriptionListTerm> | ||
| <DescriptionListDetails class="flex items-center gap-2"> | ||
| {{ dataset.id }} | ||
| <CopyButton | ||
| class="!-mt-0.5" | ||
| :label="t(`Copier l'identifiant`)" | ||
| :copied-label="t('Identifiant copié !')" | ||
| :text="dataset.id" | ||
| :hide-label="true" | ||
| /> | ||
| </DescriptionListDetails> | ||
| </div> | ||
| <div v-if="dataset.license"> | ||
| <DescriptionListTerm>{{ t('Licence') }}</DescriptionListTerm> | ||
| <DescriptionListDetails> | ||
| <LicenseBadge :license="dataset.license" /> | ||
| </DescriptionListDetails> | ||
| </div> | ||
| <slot /> | ||
| </DescriptionList> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { useTranslation } from '../../composables/useTranslation' | ||
| import { useComponentsConfig } from '../../config' | ||
| import type { DatasetV2WithFullObject } from '../../types/datasets' | ||
| import DescriptionList from '../DescriptionList.vue' | ||
| import DescriptionListTerm from '../DescriptionListTerm.vue' | ||
| import DescriptionListDetails from '../DescriptionListDetails.vue' | ||
| import AppLink from '../AppLink.vue' | ||
| import CopyButton from '../CopyButton.vue' | ||
| import LicenseBadge from '../LicenseBadge.vue' | ||
| import Tag from '../Tag.vue' | ||
|
|
||
| const props = defineProps<{ | ||
| dataset: DatasetV2WithFullObject | ||
| tagUrl?: (tag: string) => string | ||
| }>() | ||
|
|
||
| const { t } = useTranslation() | ||
| const config = useComponentsConfig() | ||
|
|
||
| function getTagUrl(tag: string): string { | ||
| if (props.tagUrl) { | ||
| return props.tagUrl(tag) | ||
| } | ||
| const base = config.baseUrl.endsWith('/') ? config.baseUrl.slice(0, -1) : config.baseUrl | ||
| return `${base}/datasets/search?tag=${tag}` | ||
| } | ||
| </script> |
74 changes: 74 additions & 0 deletions
74
datagouv-components/src/components/DatasetInformation/DatasetSchemaSection.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| <template> | ||
| <div | ||
| v-if="schemas && schemas.length" | ||
| class="space-y-1 py-6" | ||
| > | ||
| <h3 class="uppercase text-gray-plain text-sm font-bold"> | ||
| {{ t('Schéma de données') }} | ||
| </h3> | ||
| <div class="space-y-4"> | ||
| <div | ||
| v-for="schema, index in schemas" | ||
| :key="index" | ||
| class="flex flex-col md:flex-row gap-2 justify-between items-center" | ||
| > | ||
| <p class="text-sm mb-0"> | ||
| {{ t('Les fichiers du jeu de données suivent le schéma :') }} | ||
| <Tag | ||
| type="secondary" | ||
| :icon="RiCheckboxCircleLine" | ||
| > | ||
| {{ schema.name || schema.url }} | ||
| </Tag> | ||
| </p> | ||
| <div v-if="schema.url || schema.name"> | ||
| <BrandedButton | ||
| color="secondary" | ||
| :icon="RiBook2Line" | ||
| :href="schema.url ? schema.url : `${config.schemasSiteUrl}${schema.name}`" | ||
| > | ||
| {{ t('Voir la documentation du schéma') }} | ||
| </BrandedButton> | ||
| </div> | ||
| </div> | ||
| <p | ||
| v-if="config.schemasSiteUrl && config.schemasSiteName" | ||
| class="text-sm" | ||
| > | ||
| <TranslationT keypath="Les schémas de données permettent de décrire des modèles de données, découvrez comment les schémas améliorent la qualité des données et quels sont les cas d'usages possibles sur {link}"> | ||
| <template #link> | ||
| <AppLink | ||
| :to="config.schemasSiteUrl" | ||
| external | ||
| > | ||
| {{ config.schemasSiteName }} | ||
| </AppLink> | ||
| </template> | ||
| </TranslationT> | ||
| </p> | ||
| </div> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { RiBook2Line, RiCheckboxCircleLine } from '@remixicon/vue' | ||
| import { useTranslation } from '../../composables/useTranslation' | ||
| import { useComponentsConfig } from '../../config' | ||
| import { useFetch } from '../../functions/api' | ||
| import type { Dataset, DatasetV2, DatasetV2WithFullObject } from '../../types/datasets' | ||
| import type { Schema } from '../../types/schemas' | ||
| import Tag from '../Tag.vue' | ||
| import BrandedButton from '../BrandedButton.vue' | ||
| import TranslationT from '../TranslationT.vue' | ||
| import AppLink from '../AppLink.vue' | ||
|
|
||
| const props = defineProps<{ | ||
| dataset: Dataset | DatasetV2 | DatasetV2WithFullObject | ||
| }>() | ||
|
|
||
| const { t } = useTranslation() | ||
| const config = useComponentsConfig() | ||
|
|
||
| const { data } = await useFetch<Array<Schema>>(`/api/2/datasets/${props.dataset.id}/schemas/`) | ||
| const schemas = data | ||
| </script> |
59 changes: 59 additions & 0 deletions
59
datagouv-components/src/components/DatasetInformation/DatasetSpatialSection.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| <template> | ||
| <div | ||
| v-if="dataset.spatial" | ||
| class="space-y-1 py-6" | ||
| > | ||
| <h3 class="uppercase text-gray-plain text-sm font-bold"> | ||
| {{ t('Couverture spatiale') }} | ||
| </h3> | ||
| <DescriptionList> | ||
| <div v-if="dataset.spatial.zones && dataset.spatial.zones.length"> | ||
| <DescriptionListTerm>{{ t('Zones') }}</DescriptionListTerm> | ||
| <DescriptionListDetails>{{ zonesDisplay }}</DescriptionListDetails> | ||
| </div> | ||
| <div v-if="dataset.spatial.geom"> | ||
| <DescriptionListTerm>{{ t('Couverture géographique') }}</DescriptionListTerm> | ||
| <DescriptionListDetails> | ||
| <slot | ||
| name="map" | ||
| :geojson="dataset.spatial.geom" | ||
| /> | ||
| </DescriptionListDetails> | ||
| </div> | ||
| <div v-if="dataset.spatial.granularity"> | ||
| <DescriptionListTerm>{{ t('Granularité de la couverture territoriale') }}</DescriptionListTerm> | ||
| <DescriptionListDetails>{{ dataset.spatial.granularity.name }}</DescriptionListDetails> | ||
| </div> | ||
| <slot /> | ||
| </DescriptionList> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { computed } from 'vue' | ||
| import { useTranslation } from '../../composables/useTranslation' | ||
| import type { DatasetV2WithFullObject } from '../../types/datasets' | ||
| import DescriptionList from '../DescriptionList.vue' | ||
| import DescriptionListTerm from '../DescriptionListTerm.vue' | ||
| import DescriptionListDetails from '../DescriptionListDetails.vue' | ||
|
|
||
| const props = defineProps<{ | ||
| dataset: DatasetV2WithFullObject | ||
| }>() | ||
|
|
||
| const { t } = useTranslation() | ||
|
|
||
| const zonesDisplay = computed(() => { | ||
| if (!props.dataset.spatial?.zones?.length) return '' | ||
| const names = props.dataset.spatial.zones.map(z => z.name) | ||
| return humanJoin(names) | ||
| }) | ||
|
|
||
| function humanJoin(source: Array<string>): string { | ||
| const array = [...source] | ||
| if (!array.length) return '' | ||
| if (array.length === 1) return array[0]! | ||
| const last = array.pop()! | ||
| return `${array.join(', ')} ${t('et')} ${last}` | ||
| } | ||
| </script> |
45 changes: 45 additions & 0 deletions
45
datagouv-components/src/components/DatasetInformation/DatasetTemporalitySection.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| <template> | ||
| <div class="space-y-1 py-6"> | ||
| <h3 class="uppercase text-gray-plain text-sm font-bold"> | ||
| {{ t('Temporalité') }} | ||
| </h3> | ||
| <DescriptionList> | ||
| <div> | ||
| <DescriptionListTerm>{{ t('Création') }}</DescriptionListTerm> | ||
| <DescriptionListDetails>{{ formatDate(dataset.created_at) }}</DescriptionListDetails> | ||
| </div> | ||
| <div v-if="dataset.frequency"> | ||
| <DescriptionListTerm>{{ t('Fréquence') }}</DescriptionListTerm> | ||
| <DescriptionListDetails>{{ dataset.frequency.label }}</DescriptionListDetails> | ||
| </div> | ||
| <div v-if="dataset.temporal_coverage"> | ||
| <DescriptionListTerm>{{ t('Couverture temporelle') }}</DescriptionListTerm> | ||
| <DescriptionListDetails> | ||
| <DateRangeDetails :range="dataset.temporal_coverage" /> | ||
| </DescriptionListDetails> | ||
| </div> | ||
| <div> | ||
| <DescriptionListTerm>{{ t('Dernière mise à jour') }}</DescriptionListTerm> | ||
| <DescriptionListDetails>{{ formatDate(dataset.last_update) }}</DescriptionListDetails> | ||
| </div> | ||
| <slot /> | ||
| </DescriptionList> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { useTranslation } from '../../composables/useTranslation' | ||
| import { useFormatDate } from '../../functions/dates' | ||
| import type { DatasetV2WithFullObject } from '../../types/datasets' | ||
| import DescriptionList from '../DescriptionList.vue' | ||
| import DescriptionListTerm from '../DescriptionListTerm.vue' | ||
| import DescriptionListDetails from '../DescriptionListDetails.vue' | ||
| import DateRangeDetails from '../DateRangeDetails.vue' | ||
|
|
||
| defineProps<{ | ||
| dataset: DatasetV2WithFullObject | ||
| }>() | ||
|
|
||
| const { t } = useTranslation() | ||
| const { formatDate } = useFormatDate() | ||
| </script> |
5 changes: 5 additions & 0 deletions
5
datagouv-components/src/components/DatasetInformation/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export { default as DatasetInformationSection } from './DatasetInformationSection.vue' | ||
| export { default as DatasetTemporalitySection } from './DatasetTemporalitySection.vue' | ||
| export { default as DatasetSpatialSection } from './DatasetSpatialSection.vue' | ||
| export { default as DatasetSchemaSection } from './DatasetSchemaSection.vue' | ||
| export { default as DatasetEmbedSection } from './DatasetEmbedSection.vue' |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the goal of this file ?