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

Allow hiding archives #635

Merged
merged 5 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions projects/bp-gallery/cypress/e2e/start.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ describe('Start view', () => {

it('shows the archive cards and browse view', () => {
cy.get('.archives').should('exist');
cy.get('.archive').should('exist');
cy.get('[data-testid="archive"]').should('exist');
cy.get('.browse-container').should('exist');
});

it('shows the picture count for the archive cards', () => {
cy.contains('.archive', 'Herbert-Ahrens-Bilderarchiv').contains('5 Bilder');
cy.contains('[data-testid="archive"]', 'Herbert-Ahrens-Bilderarchiv').contains('5 Bilder');
});

it('should have a visible navigation bar', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const ArchiveCheckboxField = ({ defaultValue, id, onChange, label }: ArchiveInpu
);

return (
<div className='archive-form-div'>
<div className='archive-form-div my-2'>
<label className='archive-form-label' htmlFor={`archive-form-${id}`} />
<FormControlLabel
label={label}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ interface ArchiveForm {
paypalPurpose: string;
logo?: File;
links: LinkInfo[];
hidden: boolean;
restrictImageDownloading: boolean;
dirty: boolean;
invalid?: boolean;
Expand Down Expand Up @@ -82,6 +83,7 @@ const ArchiveEditView = ({ archiveId }: ArchiveEditViewProps) => {
paypalDonationText: '',
paypalPurpose: '',
links: [],
hidden: false,
restrictImageDownloading: false,
dirty: false,
});
Expand All @@ -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]);
Expand Down Expand Up @@ -180,6 +183,7 @@ const ArchiveEditView = ({ archiveId }: ArchiveEditViewProps) => {
'paypalClient',
'paypalDonationText',
'paypalPurpose',
'hidden',
'restrictImageDownloading',
]),
logo,
Expand All @@ -200,6 +204,7 @@ const ArchiveEditView = ({ archiveId }: ArchiveEditViewProps) => {
'paypalClient',
'paypalDonationText',
'paypalPurpose',
'hidden',
'restrictImageDownloading',
]),
},
Expand Down Expand Up @@ -331,6 +336,12 @@ const ArchiveEditView = ({ archiveId }: ArchiveEditViewProps) => {
onBlur={value => updateForm({ paypalPurpose: value, dirty: true })}
placeholder={t('archives.edit.paypal.purpose-placeholder')}
/>
<ArchiveCheckboxField
defaultValue={archive.hidden ?? false}
label={t('archives.edit.hidden')}
id='hidden'
onChange={value => updateForm({ hidden: value, dirty: true })}
/>
<ArchiveCheckboxField
defaultValue={archive.restrictImageDownloading ?? false}
label={t('archives.edit.restrictImageDownloading')}
Expand Down
46 changes: 28 additions & 18 deletions projects/bp-gallery/src/components/views/start/StartView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,35 @@ const StartView = () => {
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 (
<div className='archive' key={archive.id}>
{archive.showcasePicture ? (
<ArchiveCard picture={archive.showcasePicture} {...sharedProps} />
) : (
<ArchiveCardWithoutPicture {...sharedProps} />
)}
</div>
);
});
return (
<div
className={archive.hidden ? 'brightness-90 opacity-50' : ''}
key={archive.id}
data-testid='archive'
>
{archive.showcasePicture ? (
<ArchiveCard picture={archive.showcasePicture} {...sharedProps} />
) : (
<ArchiveCardWithoutPicture {...sharedProps} />
)}
</div>
);
}),
[archives, isLoggedIn, pictureCounts]
);

const showStories = useFlag('showstories');
const tabs: OverviewContainerTab[] = useMemo(() => {
Expand Down
7 changes: 7 additions & 0 deletions projects/bp-gallery/src/graphql/APIConnector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export type ArchiveTag = {
createdAt?: Maybe<Scalars['DateTime']>;
email?: Maybe<Scalars['String']>;
exhibitions?: Maybe<ExhibitionRelationResponseCollection>;
hidden?: Maybe<Scalars['Boolean']>;
links?: Maybe<LinkRelationResponseCollection>;
logo?: Maybe<UploadFileEntityResponse>;
longDescription?: Maybe<Scalars['String']>;
Expand Down Expand Up @@ -96,6 +97,7 @@ export type ArchiveTagFiltersInput = {
createdAt?: InputMaybe<DateTimeFilterInput>;
email?: InputMaybe<StringFilterInput>;
exhibitions?: InputMaybe<ExhibitionFiltersInput>;
hidden?: InputMaybe<BooleanFilterInput>;
id?: InputMaybe<IdFilterInput>;
links?: InputMaybe<LinkFiltersInput>;
longDescription?: InputMaybe<StringFilterInput>;
Expand All @@ -116,6 +118,7 @@ export type ArchiveTagFiltersInput = {
export type ArchiveTagInput = {
email?: InputMaybe<Scalars['String']>;
exhibitions?: InputMaybe<Array<InputMaybe<Scalars['ID']>>>;
hidden?: InputMaybe<Scalars['Boolean']>;
links?: InputMaybe<Array<InputMaybe<Scalars['ID']>>>;
logo?: InputMaybe<Scalars['ID']>;
longDescription?: InputMaybe<Scalars['String']>;
Expand Down Expand Up @@ -2772,6 +2775,7 @@ export type GetAllArchiveTagsQuery = {
attributes?: {
name: string;
shortDescription?: string | null;
hidden?: boolean | null;
showcasePicture?: {
data?: {
id?: string | null;
Expand Down Expand Up @@ -2855,6 +2859,7 @@ export type GetArchiveQuery = {
paypalClient?: string | null;
paypalDonationText?: string | null;
paypalPurpose?: string | null;
hidden?: boolean | null;
restrictImageDownloading?: boolean | null;
logo?: {
data?: {
Expand Down Expand Up @@ -4569,6 +4574,7 @@ export const GetAllArchiveTagsDocument = gql`
attributes {
name
shortDescription
hidden
showcasePicture {
data {
id
Expand Down Expand Up @@ -4944,6 +4950,7 @@ export const GetArchiveDocument = gql`
paypalClient
paypalDonationText
paypalPurpose
hidden
restrictImageDownloading
logo {
data {
Expand Down
4 changes: 2 additions & 2 deletions projects/bp-gallery/src/graphql/operation.graphql
Original file line number Diff line number Diff line change
@@ -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 } } } } } } } } } }
Expand Down
32 changes: 32 additions & 0 deletions projects/bp-gallery/src/graphql/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4987,6 +4987,16 @@
},
"defaultValue": null
},
{
"name": "hidden",
"description": null,
"type": {
"kind": "INPUT_OBJECT",
"name": "BooleanFilterInput",
"ofType": null
},
"defaultValue": null
},
{
"name": "createdAt",
"description": null,
Expand Down Expand Up @@ -5208,6 +5218,16 @@
},
"defaultValue": null
},
{
"name": "hidden",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"defaultValue": null
},
{
"name": "publishedAt",
"description": null,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions projects/bp-gallery/src/shared/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
Expand Down
1 change: 1 addition & 0 deletions projects/bp-graphql/src/operations/getAllArchiveTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default {
attributes {
name
shortDescription
hidden
showcasePicture {
data {
id
Expand Down
1 change: 1 addition & 0 deletions projects/bp-graphql/src/operations/getArchive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default {
paypalClient
paypalDonationText
paypalPurpose
hidden
restrictImageDownloading
logo {
data {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": ["images"]
"allowedTypes": [
"images"
]
},
"paypalClient": {
"type": "string"
Expand All @@ -65,6 +67,10 @@
"relation": "oneToMany",
"target": "api::exhibition.exhibition",
"mappedBy": "archive_tag"
},
"hidden": {
"type": "boolean",
"default": false
}
}
}
}
Loading