-
Notifications
You must be signed in to change notification settings - Fork 2
feat: datasets access_type and access_audiences
#688
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
13
commits into
main
Choose a base branch
from
datasets_access_types
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
13 commits
Select commit
Hold shift + click to select a range
7bd0eb2
Extract SelectAudiencesTypes to component
ThibaudDauce 42801b3
Add mone types / conversions
ThibaudDauce 543f2e6
add missing types and show stacktrace on error page
ThibaudDauce d4cff1d
Show AccessTypePanel in datasets
ThibaudDauce 38bec98
Add banner for restricted datasets
ThibaudDauce 3a5cf3e
Merge branch 'main' into datasets_access_types
ThibaudDauce 98d653c
Add reasons to access type form
ThibaudDauce 98b4f50
Reset special reason on category change
ThibaudDauce f6643db
Merge branch 'main' into datasets_access_types
ThibaudDauce 6d9f61e
allow submitting without files if not open
ThibaudDauce c83eb9b
Fix missing default values in datasets creation
ThibaudDauce 65d5c49
Merge branch 'main' into datasets_access_types
ThibaudDauce f3180bf
Remove unused dependency
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| <template> | ||
| <div class="space-y-3"> | ||
| <RadioButtons | ||
| v-model="form.access_type" | ||
| class="!mb-0" | ||
| :label="$t(`Type d'accès`)" | ||
| :options="disallowOpenWithAccount ? [ | ||
| { value: 'open', label: $t('Ouvert') }, | ||
| { value: 'restricted', label: $t('Restreint') }, | ||
| ] : [ | ||
| { value: 'open', label: $t('Ouvert') }, | ||
| { value: 'open_with_account', label: $t('Ouvert avec compte') }, | ||
| { value: 'restricted', label: $t('Restreint') }, | ||
| ]" | ||
| /> | ||
| <SimpleBanner | ||
| v-if="getFirstWarning('access_type')" | ||
| class="mt-2" | ||
| type="warning" | ||
| > | ||
| {{ getFirstWarning("access_type") }} | ||
| </SimpleBanner> | ||
| <template v-if="form.access_type === 'restricted'"> | ||
| <SelectAudiencesTypes | ||
| v-model="form.access_audiences" | ||
| /> | ||
| <SelectGroup | ||
| v-model="form.access_type_reason_category" | ||
| :label="$t('Raison de la restriction')" | ||
| :options="categoriesWithOthers" | ||
| /> | ||
| <InputGroup | ||
| v-if="form.access_type_reason_category === 'other'" | ||
| v-model="form.access_type_reason" | ||
| :label="$t('Veuillez préciser la raison')" | ||
| :has-error="!!getFirstError('access_type_reason')" | ||
| :has-warning="!!getFirstWarning('access_type_reason')" | ||
| :error-text="getFirstError('access_type_reason')" | ||
| /> | ||
| <SimpleBanner | ||
| v-if="getFirstWarning('access_type_reason')" | ||
| type="warning" | ||
| > | ||
| {{ getFirstWarning("access_type_reason") }} | ||
| </SimpleBanner> | ||
| </template> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { SimpleBanner, type AccessTypeForm } from '@datagouv/components-next' | ||
| import SelectGroup from '../Form/SelectGroup/SelectGroup.vue' | ||
|
|
||
| defineProps<{ | ||
| getFirstWarning: (key: string) => string | null | ||
| getFirstError: (key: string) => string | null | ||
| disallowOpenWithAccount?: boolean | ||
| }>() | ||
|
|
||
| const form = defineModel<AccessTypeForm>({ required: true }) | ||
| const { t } = useTranslation() | ||
|
|
||
| const { data: categories } = await useAPI<Array<{ value: string, label: string }>>('/api/1/access_type/reason_categories') | ||
|
|
||
| const categoriesWithOthers = computed(() => { | ||
| return [...(categories.value || []), { value: 'other', label: t('Autre') }] | ||
| }) | ||
|
|
||
| watch(() => form.value.access_type_reason_category, (newValue, oldValue) => { | ||
| if (oldValue === 'other' && newValue !== 'other') { | ||
| form.value.access_type_reason = '' | ||
| } | ||
| }) | ||
| </script> | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| <template> | ||
| <div class="space-y-1"> | ||
| <dt class="text-gray-plain font-bold"> | ||
| {{ $t('Accès') }} | ||
| </dt> | ||
| <dd class="p-0"> | ||
| <AccessTypeBadge | ||
| v-if="object.access_type" | ||
| :access-type="object.access_type" | ||
| /> | ||
| <template v-else> | ||
| {{ $t('Non spécifié') }} | ||
| </template> | ||
| <div | ||
| v-if="object.authorization_request_url" | ||
| class="mt-2.5" | ||
| > | ||
| <a | ||
| :href="object.authorization_request_url" | ||
| rel="ugc nofollow noopener" | ||
| target="_blank" | ||
| class="fr-text--sm fr-link" | ||
| > | ||
| {{ $t("Faire une demande d'habilitation") }} | ||
| </a> | ||
| </div> | ||
| </dd> | ||
| <template v-if="object.access_type === 'restricted'"> | ||
| <dt class="text-gray-plain font-bold mt-2.5"> | ||
| {{ $t('Publics éligibles') }} | ||
| </dt> | ||
| <dd | ||
| class="p-0" | ||
| > | ||
| <ul | ||
| v-if="accessAudiences.length" | ||
| class="list-none p-0 space-y-1 m-0" | ||
| > | ||
| <template | ||
| v-for="audience in accessAudiences" | ||
| :key="audience" | ||
| > | ||
| <DataservicesAccessAudienceCondition | ||
| :condition="audience.condition" | ||
| :audience="audience.role" | ||
| /> | ||
| </template> | ||
| </ul> | ||
| <template v-else> | ||
| {{ $t('Non spécifiés') }} | ||
| </template> | ||
| </dd> | ||
| </template> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import type { AccessAudience, AccessAudienceType, WithAccessType } from '@datagouv/components-next' | ||
| import AccessTypeBadge from './AccessTypeBadge.vue' | ||
|
|
||
| const props = defineProps<{ | ||
| object: WithAccessType | ||
| }>() | ||
|
|
||
| const accessAudiences = computed(() => (['local_authority_and_administration', 'company_and_association', 'private'] as Array<AccessAudienceType>) | ||
| .map(type => props.object.access_audiences.find(a => a.role === type)) | ||
| .filter(Boolean) as Array<AccessAudience>) | ||
| </script> |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.