Skip to content
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

Feat/add reuse publishing #373

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
3ba67a5
feat: :sparkles: create first step of the reuse publishing form
Jorek57 Feb 28, 2024
41ce5cc
feat: add types to reuse multiselect
Jorek57 Feb 29, 2024
1f85b96
feat: add topics and tags to multiselects
Jorek57 Feb 29, 2024
160509f
add proper texts for accordion
Jorek57 Feb 29, 2024
42aa2e5
feat: create reuseLoader and Step3 of reuse publishing form
Jorek57 Mar 4, 2024
1280efd
feat: create new design for ReuseLoader
Jorek57 Mar 4, 2024
218f98e
feat: add specific stepper for reuse form
Jorek57 Mar 4, 2024
01c1925
feat: add dataset choice
Jorek57 Mar 5, 2024
d672886
fix: add missing text to step 1
Jorek57 Mar 6, 2024
72c523c
wip: changing so script setup lang="ts"
Jorek57 Mar 6, 2024
0048e8b
wip: remove jsdoc and pass to ts
Jorek57 Mar 8, 2024
4d1b0fe
wip: start to work on upload logic
Jorek57 Mar 8, 2024
abe1e62
feat: integrate the components in app + functionnal api calls
Jorek57 Mar 11, 2024
fe665ff
FIX: CHANGE LOADERS BACKGROUND COLOR
Jorek57 Mar 12, 2024
b2879fa
feat: created CardSm for associated datasets
Jorek57 Mar 12, 2024
c701777
fix: add check on dataset add to reuse
Jorek57 Mar 12, 2024
b890cea
fix: correct validator on image upload
Jorek57 Mar 12, 2024
0abf0ba
wip: edit storybook stories
Jorek57 Mar 12, 2024
f0bec27
fix: correct CardSM css + add content to stories
Jorek57 Mar 12, 2024
eb64f15
wip: fixing alert not appearing
Jorek57 Mar 13, 2024
8b9ea11
fix: alert appearing on api error
Jorek57 Mar 13, 2024
eb4ae31
fix: corrected validator on image upload
Jorek57 Mar 13, 2024
c7e2703
feat: turned stories to ts
Jorek57 Mar 13, 2024
39c6f49
feat: added search for dataset link
Jorek57 Mar 13, 2024
a4c9b1f
wip: adding types
Jorek57 Mar 14, 2024
36c284b
wip: advancing on ts types
Jorek57 Mar 14, 2024
87dc930
wip: fixing type upload error
Jorek57 Mar 20, 2024
78464eb
fix: remove duplicate function name
Jorek57 Mar 24, 2024
4dd1295
Merge branch 'master' into feat/add-reuse-publishing
Jorek57 May 15, 2024
079cb39
refactor: edit import of some components from the new ones in datagou…
Jorek57 May 16, 2024
4e50e2d
fix: edit spacing for CI in reuse.py
Jorek57 May 21, 2024
df51165
feat: edit storybook msw to handle the user
Jorek57 May 22, 2024
18ebe11
feat: wip: add user to list of organizations to allow choice in Step 1
Jorek57 May 22, 2024
9c28cf5
wip: edit css and templating
Jorek57 May 22, 2024
51b9d9f
fix: remove Stepper from individual pages and adjust storybook
Jorek57 May 22, 2024
0fc254b
fix: add proper label for imageUpload
Jorek57 May 22, 2024
c0bad9d
fix blank space for CI
Jorek57 May 22, 2024
e5c951f
feat: add new svg for step 1
Jorek57 May 23, 2024
400690a
fix: remove Sidemenu in Step 2 + edit storybook
Jorek57 May 23, 2024
d986335
fix: correct values for changing reuse privacy in step 3
Jorek57 May 23, 2024
e12d9cb
fix: minor fixes
Jorek57 May 23, 2024
d6e8292
feat: add toast if no dataset provided in Step 2
Jorek57 May 23, 2024
b0634e3
feat: add all organizations choice if user is admin
Jorek57 May 30, 2024
28985d4
fix: remove console.log
Jorek57 May 30, 2024
ad86734
fix: various syntax fixes
Jorek57 Jun 11, 2024
abf722f
feat: add markdown editor
Jorek57 Jul 3, 2024
694b14e
Merge branch 'master' into feat/add-reuse-publishing
Jorek57 Jul 11, 2024
eb2eed5
wip: add ProducerSelector to ReusePublishingForm
Jorek57 Jul 12, 2024
762ff61
wip: improve code quality
Jorek57 Jul 15, 2024
8af321a
fix: various types and syntax fixes
Jorek57 Jul 15, 2024
92cc5a3
fix: more types fixes
Jorek57 Jul 15, 2024
6684a48
fix: edit wrong const in uploadLogo
Jorek57 Jul 15, 2024
94cda25
fix: modify datasets types for Reuse
Jorek57 Jul 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion udata_front/theme/gouvfr/assets/js/api/reuses.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getLocalizedUrl } from "../i18n";
import { toValue } from "vue";
import { api } from "../plugins/api";
import { Reuse } from "../types";
import type { Reuse, NewReuse } from "../types";

let reuseTypesRequest: Promise<Array<ReuseType>> | null = null;

Expand All @@ -9,10 +10,19 @@ export type ReuseType = {
label: string,
};

type UploadLogoResponse = {
image: string;
success: boolean;
};

export function getReuseTypesUrl() {
return getLocalizedUrl("reuses/types/");
}

export function getReuseTopicsUrl() {
return getLocalizedUrl("reuses/topics/");
}

export function fetchReuseTypes() {
if (reuseTypesRequest) {
return reuseTypesRequest;
Expand All @@ -25,3 +35,21 @@ export function getType(types: Array<ReuseType>, id: string): string {
const type = types.find(t => t.id === id);
return type ? type.label : "";
}

export function createReuse(reuse: NewReuse) {
return api.post<Reuse>("reuses/", {
...toValue(reuse),
}).then(resp => resp.data);
}

export function updateReuse(reuse: Reuse) {
return api.put<Reuse>(`reuses/${reuse.id}`, {
...toValue(reuse),
}).then(resp => resp.data);
}

export function uploadLogo(reuseId: string, file: File) {
return api.postForm<UploadLogoResponse>(`reuses/${reuseId}/image`, {
file: file
});
}
6 changes: 6 additions & 0 deletions udata_front/theme/gouvfr/assets/js/api/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { api } from "../plugins/api";

export async function getUser() {
const resp = await api.get('me/');
return resp.data;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import Stepper from './Stepper.vue';

export default {
title: 'Components/StepperReuse',
component: Stepper,
};

const args = {
steps: ["Describe your reuse", "Add datasets", "Complete your publishing"],
currentStep: 0,
};

export const StepperOnFirstStep = {
render: (args) => ({
components: { Stepper },
setup() {
return { args };
},
template: '<Stepper v-bind="args" />',
}),
args,
};

export const StepperOnSecondStep = {
render: (args) => ({
components: { Stepper },
setup() {
return { args };
},
template: '<Stepper v-bind="args" />',
}),
args: {
...args,
currentStep: 1,
},
};

export const StepperOnThirdStep = {
render: (args) => ({
components: { Stepper },
setup() {
return { args };
},
template: '<Stepper v-bind="args" />',
}),
args: {
...args,
currentStep: 2,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<MultiSelect
:required="true"
:minimumCharacterBeforeSuggest="2"
:placeholder="$t('Check the identity with which you want to publish')"
:searchPlaceholder="$t('Select an organization')"
:placeholder="t('Check the identity with which you want to publish')"
:searchPlaceholder="t('Select an organization')"
suggestUrl="/organizations/suggest/"
:initialOptions="organizations"
:values="userOrganization"
Expand All @@ -17,8 +17,8 @@
<MultiSelect
:required="true"
:minimumCharacterBeforeSuggest="2"
:placeholder="$t('Check the identity with which you want to publish')"
:searchPlaceholder="$t('Select an organization')"
:placeholder="t('Check the identity with which you want to publish')"
:searchPlaceholder="t('Select an organization')"
:initialOptions="organizations"
:values="userOrganization"
@change="updateOrganization"
Expand All @@ -34,12 +34,12 @@
<div class="fr-grid-row fr-grid-row--middle fr-pb-3v">
<div class="fr-col-6">
<a class="fr-btn fr-btn--secondary fr-btn--secondary-grey-500" :href="organization_url">
{{ $t("Join an organization") }}
{{ t("Join an organization") }}
</a>
</div>
<div class="fr-col-6">
<a class="fr-btn" :href="createOrganizationUrl">
{{ $t("Create an organization") }}
{{ t("Create an organization") }}
</a>
</div>
</div>
Expand Down Expand Up @@ -67,6 +67,7 @@ const props = defineProps<{
const createOrganizationUrl = `${organization_url}publishing-form/`;

const userOrganization = ref<Organization>();
console.log(props.user)
const owned = ref<OwnedWithId>({
organization: null,
owner: props.user.id,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<ContentLoader
viewBox="0 0 350 350"
:speed="2"
primaryColor="#eeeeee"
secondaryColor="#ecebeb"
>
<rect x="1" y="-7" rx="0" ry="0" width="375" height="328" />
<rect x="16" y="341" rx="0" ry="0" width="261" height="16" />
<rect x="16" y="365" rx="0" ry="0" width="206" height="16" />
<rect x="16" y="389" rx="0" ry="0" width="157" height="16" />
</ContentLoader>
</template>

<script>
import { ContentLoader } from "vue-content-loader";

export default {
components: {
ContentLoader,
},
};
</script>

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<ContentLoader
viewBox="0 0 350 350"
:speed="2"
primaryColor="#EEEEEE"
secondaryColor="#ecebeb"
>
<rect x="0" y="0" rx="0" ry="0" width="350" height="200" />
<rect x="10" y="240" rx="0" ry="0" width="240" height="15" />
<rect x="10" y="280" rx="0" ry="0" width="325" height="12" />
<rect x="10" y="320" rx="0" ry="0" width="325" height="12" />
</ContentLoader>
</template>

<script>
import { ContentLoader } from "vue-content-loader";

export default {
components: {
ContentLoader,
},
};
</script>

129 changes: 129 additions & 0 deletions udata_front/theme/gouvfr/assets/js/components/dataset/CardSM.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<template>
<article class="fr-my-2w fr-p-2w border border-default-grey fr-enlarge-link" :style="style">
<div class="absolute top-0 fr-grid-row fr-grid-row--middle fr-mt-n3v" v-if="dataset.private || dataset.archived">
<p class="fr-badge fr-badge--mention-grey fr-mr-1w" v-if="dataset.private">
<span class="fr-icon-lock-line" aria-hidden="true"></span>
{{ t('Private') }}
</p>
<p class="fr-badge fr-badge--mention-grey" v-if="dataset.archived">
<span class="fr-icon-archive-line" aria-hidden="true"></span>
{{ t('Archived') }}
</p>
</div>
<div class="fr-grid-row fr-grid-row--gutters fr-grid-row--top">
<div class="fr-col-auto">
<div class="logo">
<Placeholder
v-if="dataset.organization"
type="dataset"
:src="dataset.organization.logo_thumbnail"
alt=""
:size="60"
/>
<Avatar
v-else-if="dataset.owner"
:user="dataset.owner"
:size="60"
/>
<Placeholder
v-else
type="dataset"
:size="60"
/>
</div>
</div>
<div class="fr-col">
<h4 class="fr-mb-1v fr-grid-row">
<a :href="dataset.page" class="text-grey-500">
{{ dataset.title }}
<small v-if="dataset.acronym">{{ dataset.acronym }}</small>
</a>
</h4>
<p class="fr-my-0 fr-text--xs " v-if="dataset.organization || dataset.owner">
<span class="not-enlarged fr-mr-1v" v-if="dataset.organization">
<a class="fr-link fr-text--xs" :href="dataset.organization.page">
<OrganizationNameWithCertificate :organization="dataset.organization" />
</a>
</span>
<span class="not-enlarged fr-mr-1v" v-else-if="dataset.owner">
<a class="fr-link fr-text--xs" :href="dataset.owner.page">
{{ ownerName }}
</a>
</span>
<span class="text-mention-grey">{{ $t('Updated {date}', {date: formatRelativeIfRecentDate(dataset.last_update)}) }}</span>
</p>
<div class="fr-mx-0 fr-mt-n2v fr-grid-row fr-grid-row--middle fr-text--sm text-mention-grey">
<div class="fr-grid-row fr-grid-row--middle fr-hidden flex-sm dash-after text-grey-500 not-enlarged">
<p class="fr-m-0 fr-mr-1v text-mention-grey fr-text--sm" :id="id">
{{$t('Metadata quality:')}}
</p>
<div class="fr-grid-row fr-grid-row--middle fr-mr-1v">
<QualityScore :score="dataset.quality.score"/>
</div>
</div>
<div class="fr-grid-row fr-grid-row--middle fr-mr-1v">
<p class="fr-text--xs"><span class="fr-icon-download-line fr-px-1v" aria-hidden="true"></span>{{ dataset.metrics.discussions }}</p>
<p class="fr-text--xs"><span class="fr-icon-star-line fr-px-1v" aria-hidden="true"></span>{{ dataset.metrics.followers }}</p>
<p class="fr-text--xs"><span class="fr-icon-line-chart-line fr-px-1v" aria-hidden="true"></span>{{ dataset.metrics.views }}</p>
</div>
</div>
</div>
</div>
</article>
</template>

<script lang="ts">
import { defineComponent, PropType } from "vue";
import { useI18n } from "vue-i18n";
import useLicense from "../../composables/useLicense";
import { OrganizationNameWithCertificate, useOwnerName, formatRelativeIfRecentDate} from "@etalab/data.gouv.fr-components";
import useUid from "../../composables/useUid";
import Avatar from "../discussions/Avatar/Avatar.vue";
import Placeholder from "../utils/placeholder.vue";
import { QualityItem, QualityScore, Toggletip } from '@etalab/data.gouv.fr-components';
import { excerpt } from "../../helpers";
import { guides_quality_url } from "../../config";
import type { Dataset } from "../../types";

export default defineComponent({
components: {
Avatar,
OrganizationNameWithCertificate,
Placeholder,
QualityScore,
Toggletip,
QualityItem,
},
inheritAttrs: false,
props: {
dataset: {
type: Object as PropType<Dataset>,
required: true,
},
style: {
type: Object,
default: () => ({})
},
showMetrics: {
type: Boolean,
default: true,
},
},
setup(props) {
const { t } = useI18n();
const { id } = useUid("metadata-quality");
const ownerName = useOwnerName(props.dataset);
const license = useLicense(props.dataset.license);
return {
excerpt,
formatRelativeIfRecentDate,
guides_quality_url,
license,
id,
ownerName,
t,
};
}
});
</script>

2 changes: 2 additions & 0 deletions udata_front/theme/gouvfr/assets/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Captcha from "./components/utils/captcha.vue";
import UserDatasetList from "./components/UserDatasetList/UserDatasetList.vue";
import UserReuseList from "./components/UserReuseList/UserReuseList.vue";
import PublishingForm from "./pages/PublishingForm/PublishingForm.vue";
import ReusePublishingForm from "./pages/ReusePublishingForm/ReusePublishingForm.vue";
import OrganizationPublishingForm from "./pages/OrganizationPublishingForm/OrganizationPublishingForm.vue";
import { ReadMore, Toggletip } from "@etalab/data.gouv.fr-components";

Expand Down Expand Up @@ -78,6 +79,7 @@ const configAndMountApp = (el: HTMLElement) => {
app.component("toggletip", Toggletip);
app.component("publishing-form", PublishingForm);
app.component("organization-publishing-form", OrganizationPublishingForm);
app.component("reuse-publishing-form", ReusePublishingForm);
app.component("user-dataset-list", UserDatasetList);
app.component("user-reuse-list", UserReuseList);

Expand Down
Loading