From f2fe9edd3b538373dcc74a2058257162a8026018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20D=C3=B6rbandt?= Date: Tue, 22 Aug 2023 14:58:09 +0200 Subject: [PATCH 1/4] Allow hiding archives --- .../views/archives/ArchiveEditView.tsx | 11 +++++ .../src/components/views/start/StartView.tsx | 45 +++++++++++-------- .../bp-gallery/src/graphql/APIConnector.tsx | 7 +++ .../bp-gallery/src/graphql/operation.graphql | 4 +- .../bp-gallery/src/graphql/schema/schema.json | 32 +++++++++++++ .../bp-gallery/src/shared/locales/de.json | 1 + .../src/operations/getAllArchiveTags.ts | 1 + .../bp-graphql/src/operations/getArchive.ts | 1 + .../content-types/archive-tag/schema.json | 10 ++++- 9 files changed, 90 insertions(+), 22 deletions(-) diff --git a/projects/bp-gallery/src/components/views/archives/ArchiveEditView.tsx b/projects/bp-gallery/src/components/views/archives/ArchiveEditView.tsx index 1c9008df8..4b331dd76 100644 --- a/projects/bp-gallery/src/components/views/archives/ArchiveEditView.tsx +++ b/projects/bp-gallery/src/components/views/archives/ArchiveEditView.tsx @@ -40,6 +40,7 @@ interface ArchiveForm { paypalPurpose: string; logo?: File; links: LinkInfo[]; + hidden: boolean; restrictImageDownloading: boolean; dirty: boolean; invalid?: boolean; @@ -82,6 +83,7 @@ const ArchiveEditView = ({ archiveId }: ArchiveEditViewProps) => { paypalDonationText: '', paypalPurpose: '', links: [], + hidden: false, restrictImageDownloading: false, dirty: false, }); @@ -97,6 +99,7 @@ const ArchiveEditView = ({ archiveId }: ArchiveEditViewProps) => { paypalDonationText: archive?.paypalDonationText ?? '', paypalPurpose: archive?.paypalPurpose ?? '', links: archive?.links ?? [], + hidden: archive?.hidden ?? false, restrictImageDownloading: archive?.restrictImageDownloading ?? false, }); }, [archive]); @@ -180,6 +183,7 @@ const ArchiveEditView = ({ archiveId }: ArchiveEditViewProps) => { 'paypalClient', 'paypalDonationText', 'paypalPurpose', + 'hidden', 'restrictImageDownloading', ]), logo, @@ -200,6 +204,7 @@ const ArchiveEditView = ({ archiveId }: ArchiveEditViewProps) => { 'paypalClient', 'paypalDonationText', 'paypalPurpose', + 'hidden', 'restrictImageDownloading', ]), }, @@ -331,6 +336,12 @@ const ArchiveEditView = ({ archiveId }: ArchiveEditViewProps) => { onBlur={value => updateForm({ paypalPurpose: value, dirty: true })} placeholder={t('archives.edit.paypal.purpose-placeholder')} /> + updateForm({ hidden: value, dirty: true })} + /> { fallback: { clientId: '', donationText: '', purposeText: '' }, }); - const archiveCards = archives?.map(archive => { - const sharedProps = { - archiveName: archive.name, - archiveDescription: archive.shortDescription ?? '', - archiveId: archive.id, - archivePictureCount: pictureCounts?.find(pictureCount => pictureCount.id === archive.id) - ?.count, - }; + const archiveCards = useMemo( + () => + archives + ?.filter(archive => isLoggedIn || !archive.hidden) + ?.map(archive => { + const sharedProps = { + archiveName: archive.name, + archiveDescription: archive.shortDescription ?? '', + archiveId: archive.id, + archivePictureCount: pictureCounts?.find(pictureCount => pictureCount.id === archive.id) + ?.count, + }; - return ( -
- {archive.showcasePicture ? ( - - ) : ( - - )} -
- ); - }); + return ( +
+ {archive.showcasePicture ? ( + + ) : ( + + )} +
+ ); + }), + [archives, isLoggedIn, pictureCounts] + ); const showStories = useFlag('showstories'); const tabs: OverviewContainerTab[] = useMemo(() => { diff --git a/projects/bp-gallery/src/graphql/APIConnector.tsx b/projects/bp-gallery/src/graphql/APIConnector.tsx index ca9ee0ec4..0655984a7 100644 --- a/projects/bp-gallery/src/graphql/APIConnector.tsx +++ b/projects/bp-gallery/src/graphql/APIConnector.tsx @@ -42,6 +42,7 @@ export type ArchiveTag = { createdAt?: Maybe; email?: Maybe; exhibitions?: Maybe; + hidden?: Maybe; links?: Maybe; logo?: Maybe; longDescription?: Maybe; @@ -96,6 +97,7 @@ export type ArchiveTagFiltersInput = { createdAt?: InputMaybe; email?: InputMaybe; exhibitions?: InputMaybe; + hidden?: InputMaybe; id?: InputMaybe; links?: InputMaybe; longDescription?: InputMaybe; @@ -116,6 +118,7 @@ export type ArchiveTagFiltersInput = { export type ArchiveTagInput = { email?: InputMaybe; exhibitions?: InputMaybe>>; + hidden?: InputMaybe; links?: InputMaybe>>; logo?: InputMaybe; longDescription?: InputMaybe; @@ -2772,6 +2775,7 @@ export type GetAllArchiveTagsQuery = { attributes?: { name: string; shortDescription?: string | null; + hidden?: boolean | null; showcasePicture?: { data?: { id?: string | null; @@ -2855,6 +2859,7 @@ export type GetArchiveQuery = { paypalClient?: string | null; paypalDonationText?: string | null; paypalPurpose?: string | null; + hidden?: boolean | null; restrictImageDownloading?: boolean | null; logo?: { data?: { @@ -4569,6 +4574,7 @@ export const GetAllArchiveTagsDocument = gql` attributes { name shortDescription + hidden showcasePicture { data { id @@ -4944,6 +4950,7 @@ export const GetArchiveDocument = gql` paypalClient paypalDonationText paypalPurpose + hidden restrictImageDownloading logo { data { diff --git a/projects/bp-gallery/src/graphql/operation.graphql b/projects/bp-gallery/src/graphql/operation.graphql index 8550b2ac5..ca81c6a8c 100644 --- a/projects/bp-gallery/src/graphql/operation.graphql +++ b/projects/bp-gallery/src/graphql/operation.graphql @@ -1,12 +1,12 @@ # NOTE: this file is auto-generated, edit /projects/bp-graphql/operations instead query canRunOperation( $operation: String! $variableSets: [JSON!] $withSomeVariables: Boolean ) { canRunOperation( operation: $operation variableSets: $variableSets withSomeVariables: $withSomeVariables ) } -query getAllArchiveTags($sortBy: [String] = ["createdAt:asc"]) { archiveTags(sort: $sortBy) { data { id attributes { name shortDescription showcasePicture { data { id attributes { media { data { attributes { url updatedAt provider } } } } } } } } } } +query getAllArchiveTags($sortBy: [String] = ["createdAt:asc"]) { archiveTags(sort: $sortBy) { data { id attributes { name shortDescription hidden showcasePicture { data { id attributes { media { data { attributes { url updatedAt provider } } } } } } } } } } query getAllCollections { collections(publicationState: PREVIEW) { data { id attributes { name parent_collections(publicationState: PREVIEW) { data { id attributes { name } } } } } } } query getAllKeywordTags { keywordTags { data { id attributes { name visible synonyms { name } } } } } query getAllLocationTags { getAllLocationTags } query getAllPersonTags { personTags { data { id attributes { name synonyms { name } } } } } query getAllPictureIds { pictures { data { id } } } -query getArchive($archiveId: ID!) { archiveTag(id: $archiveId) { data { id attributes { name shortDescription longDescription email paypalClient paypalDonationText paypalPurpose restrictImageDownloading logo { data { id attributes { width height formats updatedAt provider } } } showcasePicture { data { id attributes { media { data { id attributes { width height formats url updatedAt provider } } } } } } links { data { id attributes { title url } } } } } } } +query getArchive($archiveId: ID!) { archiveTag(id: $archiveId) { data { id attributes { name shortDescription longDescription email paypalClient paypalDonationText paypalPurpose hidden restrictImageDownloading logo { data { id attributes { width height formats updatedAt provider } } } showcasePicture { data { id attributes { media { data { id attributes { width height formats url updatedAt provider } } } } } } links { data { id attributes { title url } } } } } } } query getArchiveNames( $filters: ArchiveTagFiltersInput = {} $sortBy: [String] = ["createdAt:asc"] ) { archiveTags(filters: $filters sort: $sortBy) { data { id attributes { name } } } } query getArchivePictureCounts { archivePictureCounts { data { id attributes { count } } } } query getCollectionInfoById($collectionId: ID!) { collection(id: $collectionId) { data { id attributes { name description child_collections(sort: "name:asc" publicationState: PREVIEW) { data { id attributes { name publishedAt pictures(pagination: { limit: 1 }) { data { id } } child_collections(pagination: { limit: 1 } publicationState: PREVIEW) { data { id } } parent_collections(publicationState: PREVIEW) { data { id attributes { name } } } } } } } } } } diff --git a/projects/bp-gallery/src/graphql/schema/schema.json b/projects/bp-gallery/src/graphql/schema/schema.json index 488fd627f..9feb72f65 100644 --- a/projects/bp-gallery/src/graphql/schema/schema.json +++ b/projects/bp-gallery/src/graphql/schema/schema.json @@ -4987,6 +4987,16 @@ }, "defaultValue": null }, + { + "name": "hidden", + "description": null, + "type": { + "kind": "INPUT_OBJECT", + "name": "BooleanFilterInput", + "ofType": null + }, + "defaultValue": null + }, { "name": "createdAt", "description": null, @@ -5208,6 +5218,16 @@ }, "defaultValue": null }, + { + "name": "hidden", + "description": null, + "type": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + }, + "defaultValue": null + }, { "name": "publishedAt", "description": null, @@ -5513,6 +5533,18 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "hidden", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "createdAt", "description": null, diff --git a/projects/bp-gallery/src/shared/locales/de.json b/projects/bp-gallery/src/shared/locales/de.json index b3cd0719a..154444a07 100755 --- a/projects/bp-gallery/src/shared/locales/de.json +++ b/projects/bp-gallery/src/shared/locales/de.json @@ -530,6 +530,7 @@ "thankyou-label": "Vielen Dank für Ihre Spende von {{amount}}€", "error-label": "Es ist ein Fehler aufgetreten. Es wurde nichts von ihrem Konto abgebucht, bitte versuchen Sie es erneut." }, + "hidden": "Archiv verstecken", "restrictImageDownloading": "Herunterladen von Bildern einschränken" } }, diff --git a/projects/bp-graphql/src/operations/getAllArchiveTags.ts b/projects/bp-graphql/src/operations/getAllArchiveTags.ts index b08eb8fce..cf048db4b 100644 --- a/projects/bp-graphql/src/operations/getAllArchiveTags.ts +++ b/projects/bp-graphql/src/operations/getAllArchiveTags.ts @@ -10,6 +10,7 @@ export default { attributes { name shortDescription + hidden showcasePicture { data { id diff --git a/projects/bp-graphql/src/operations/getArchive.ts b/projects/bp-graphql/src/operations/getArchive.ts index 52ac3dde9..5d13c4dc6 100644 --- a/projects/bp-graphql/src/operations/getArchive.ts +++ b/projects/bp-graphql/src/operations/getArchive.ts @@ -15,6 +15,7 @@ export default { paypalClient paypalDonationText paypalPurpose + hidden restrictImageDownloading logo { data { diff --git a/projects/bp-strapi/src/api/archive-tag/content-types/archive-tag/schema.json b/projects/bp-strapi/src/api/archive-tag/content-types/archive-tag/schema.json index 10ed9ac61..f44304e35 100644 --- a/projects/bp-strapi/src/api/archive-tag/content-types/archive-tag/schema.json +++ b/projects/bp-strapi/src/api/archive-tag/content-types/archive-tag/schema.json @@ -43,7 +43,9 @@ "type": "media", "multiple": false, "required": false, - "allowedTypes": ["images"] + "allowedTypes": [ + "images" + ] }, "paypalClient": { "type": "string" @@ -65,6 +67,10 @@ "relation": "oneToMany", "target": "api::exhibition.exhibition", "mappedBy": "archive_tag" + }, + "hidden": { + "type": "boolean", + "default": false } } -} \ No newline at end of file +} From 62be208efc5ab1edae9935b16100da717fdf96c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20D=C3=B6rbandt?= Date: Sat, 23 Sep 2023 16:16:05 +0200 Subject: [PATCH 2/4] Remove unnecessary className --- projects/bp-gallery/src/components/views/start/StartView.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/projects/bp-gallery/src/components/views/start/StartView.tsx b/projects/bp-gallery/src/components/views/start/StartView.tsx index deaa6e456..48d49b0fd 100644 --- a/projects/bp-gallery/src/components/views/start/StartView.tsx +++ b/projects/bp-gallery/src/components/views/start/StartView.tsx @@ -62,10 +62,7 @@ const StartView = () => { }; return ( -
+
{archive.showcasePicture ? ( ) : ( From e5a51e7ae0fbd805ac3e9561d9655b53425a6d3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20D=C3=B6rbandt?= Date: Sat, 23 Sep 2023 16:24:48 +0200 Subject: [PATCH 3/4] Decrease margin for ArchiveCheckboxField --- .../src/components/views/archives/ArchiveCheckboxField.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/bp-gallery/src/components/views/archives/ArchiveCheckboxField.tsx b/projects/bp-gallery/src/components/views/archives/ArchiveCheckboxField.tsx index eb1478d3c..73b1b3be9 100644 --- a/projects/bp-gallery/src/components/views/archives/ArchiveCheckboxField.tsx +++ b/projects/bp-gallery/src/components/views/archives/ArchiveCheckboxField.tsx @@ -25,7 +25,7 @@ const ArchiveCheckboxField = ({ defaultValue, id, onChange, label }: ArchiveInpu ); return ( -
+