diff --git a/entry_types/scrolled/package/spec/support/__spec__/stories-spec.js b/entry_types/scrolled/package/spec/support/__spec__/stories-spec.js index 71d5477e7..4c875a3b6 100644 --- a/entry_types/scrolled/package/spec/support/__spec__/stories-spec.js +++ b/entry_types/scrolled/package/spec/support/__spec__/stories-spec.js @@ -145,6 +145,42 @@ describe('exampleStories', () => { }) })); }); + + it('supports adding story for inline file rights', () => { + stubSeedFixture(normalizeSeed({ + imageFiles: [ + {id: 10, permaId: 1} + ] + })); + + const stories = exampleStories({ + typeName: 'test', + inlineFileRights: true, + baseConfiguration: {} + }); + + expect(stories).toContainEqual(expect.objectContaining({ + title: 'Inline File Rights - Icon', + seed: expect.objectContaining({ + collections: expect.objectContaining({ + imageFiles: expect.arrayContaining([ + expect.objectContaining({ + configuration: expect.objectContaining({rights_display: 'inline'}) + }) + ]), + widgets: [ + expect.objectContaining({ + role: 'inlineFileRights', + typeName: 'iconInlineFileRights' + }) + ], + contentElements: expect.arrayContaining([ + expect.objectContaining({id: 1000}) + ]) + }) + }) + })); + }); }); describe('filePermaId', () => { @@ -187,4 +223,22 @@ describe('normalizeAndMergeFixture', () => { widgetPrimaryColor: '#f00' }) }); + + it('supports inline file rights', () => { + stubSeedFixture(normalizeSeed({ + imageFiles: [ + {id: 10, permaId: 1} + ] + })); + + const seed = normalizeAndMergeFixture({inlineFileRightsFor: ['imageFiles']}); + + expect(seed.collections.imageFiles[0]).toMatchObject({ + rights: 'Jane Doe', + configuration: { + rights_display: 'inline', + source_url: 'https://example.com/jane-doe/image' + } + }) + }); }) diff --git a/entry_types/scrolled/package/spec/support/stories.js b/entry_types/scrolled/package/spec/support/stories.js index 63047a610..84f63c76d 100644 --- a/entry_types/scrolled/package/spec/support/stories.js +++ b/entry_types/scrolled/package/spec/support/stories.js @@ -8,6 +8,9 @@ import { } from 'pageflow-scrolled/frontend'; import {browser, Consent} from 'pageflow/frontend'; +import '../../src/widgets/iconInlineFileRights'; +import '../../src/widgets/textInlineFileRights'; + import {normalizeSeed} from 'pageflow-scrolled/testHelpers'; import {storiesOf} from '@storybook/react'; @@ -164,7 +167,8 @@ export function exampleStories(options) { ...variantsExampleStories(options), ...layoutExampleStories(options), ...mobileExampleStories(options), - ...consentOptInStories(options) + ...consentOptInStories(options), + ...inlineFileRightsStories(options) ]; } @@ -263,7 +267,35 @@ function consentOptInStories({typeName, consent, baseConfiguration}) { }); } -function exampleStoryGroup({name, typeName, examples, parameters, consentVendors}) { +function inlineFileRightsStories({typeName, inlineFileRights, baseConfiguration}) { + if (!inlineFileRights) { + return []; + } + + return exampleStoryGroup({ + typeName, + name: 'Inline File Rights', + inlineFileRightsFor: ['audioFiles', 'imageFiles', 'videoFiles'], + examples: [ + ['Icon', 'iconInlineFileRights'], ['Text', 'textInlineFileRights'] + ].map(([name, typeName]) => ( + { + name, + widgets: [{ + role: 'inlineFileRights', + typeName + }], + contentElementConfiguration: { + ...baseConfiguration + } + } + )) + }); +} + +function exampleStoryGroup({ + name, typeName, examples, parameters, consentVendors, inlineFileRightsFor, widgets +}) { const defaultSectionConfiguration = {transition: 'scroll', backdrop: {image: '#000'}, fullHeight: false}; const sections = examples.map((example, index) => ({ @@ -287,8 +319,10 @@ function exampleStoryGroup({name, typeName, examples, parameters, consentVendors seed: normalizeAndMergeFixture({ sections: [section], contentElements: contentElements, + widgets: examples[index].widgets, themeOptions: examples[index].themeOptions, consentVendors, + inlineFileRightsFor, contentElementConsentVendors: consentVendors && contentElements .filter(({id}) => id) @@ -322,7 +356,7 @@ function dasherize(text) { ); } -export function normalizeAndMergeFixture(options = {}) { +export function normalizeAndMergeFixture({inlineFileRightsFor = [], ...options} = {}) { const seed = normalizeSeed(options); return { @@ -339,6 +373,10 @@ export function normalizeAndMergeFixture(options = {}) { ), collections: { ...seedFixture.collections, + ...inlineFileRightsFor.reduce((memo, collectionName) => ({ + ...memo, + [collectionName]: applyInlineFileRights(seedFixture.collections[collectionName]) + }), {}), chapters: seed.collections.chapters, sections: seed.collections.sections, contentElements: seed.collections.contentElements, @@ -347,6 +385,18 @@ export function normalizeAndMergeFixture(options = {}) { }; } +function applyInlineFileRights(files) { + return files.map(file => ({ + ...file, + rights: 'Jane Doe', + configuration: { + ...file.configuration, + rights_display: 'inline', + source_url: 'https://example.com/jane-doe/image' + } + })); +} + export function exampleHeading({sectionId, text, position, width}) { return { sectionId, diff --git a/entry_types/scrolled/package/src/contentElements/imageGallery/stories.js b/entry_types/scrolled/package/src/contentElements/imageGallery/stories.js index aa7caa24c..a7550fec2 100644 --- a/entry_types/scrolled/package/src/contentElements/imageGallery/stories.js +++ b/entry_types/scrolled/package/src/contentElements/imageGallery/stories.js @@ -54,5 +54,6 @@ storiesOfContentElement(module, { image: filePermaId('imageFiles', 'churchAfter') } ] - } + }, + inlineFileRights: true }); diff --git a/entry_types/scrolled/package/src/contentElements/inlineAudio/stories.js b/entry_types/scrolled/package/src/contentElements/inlineAudio/stories.js index 0e83406b3..988107113 100644 --- a/entry_types/scrolled/package/src/contentElements/inlineAudio/stories.js +++ b/entry_types/scrolled/package/src/contentElements/inlineAudio/stories.js @@ -63,5 +63,6 @@ storiesOfContentElement(module, { caption: 'Some caption' } } - ] + ], + inlineFileRights: true }); diff --git a/entry_types/scrolled/package/src/contentElements/inlineBeforeAfter/stories.js b/entry_types/scrolled/package/src/contentElements/inlineBeforeAfter/stories.js index bc261310c..8cf3041c5 100644 --- a/entry_types/scrolled/package/src/contentElements/inlineBeforeAfter/stories.js +++ b/entry_types/scrolled/package/src/contentElements/inlineBeforeAfter/stories.js @@ -53,5 +53,6 @@ storiesOfContentElement(module, { caption: 'Some text here' } }, - ] + ], + inlineFileRights: true }); diff --git a/entry_types/scrolled/package/src/contentElements/inlineImage/stories.js b/entry_types/scrolled/package/src/contentElements/inlineImage/stories.js index cc20eae07..369f127f9 100644 --- a/entry_types/scrolled/package/src/contentElements/inlineImage/stories.js +++ b/entry_types/scrolled/package/src/contentElements/inlineImage/stories.js @@ -11,5 +11,6 @@ storiesOfContentElement(module, { name: 'With Caption', configuration: {caption: 'Some text here'} } - ] + ], + inlineFileRights: true }); diff --git a/entry_types/scrolled/package/src/contentElements/inlineVideo/stories.js b/entry_types/scrolled/package/src/contentElements/inlineVideo/stories.js index 8748256fa..b7df3eea1 100644 --- a/entry_types/scrolled/package/src/contentElements/inlineVideo/stories.js +++ b/entry_types/scrolled/package/src/contentElements/inlineVideo/stories.js @@ -15,5 +15,6 @@ storiesOfContentElement(module, { posterId: filePermaId('imageFiles', 'turtle') } } - ] + ], + inlineFileRights: true }); diff --git a/entry_types/scrolled/package/src/contentElements/vrImage/stories.js b/entry_types/scrolled/package/src/contentElements/vrImage/stories.js index 7a2b6503b..1e6b52ffa 100644 --- a/entry_types/scrolled/package/src/contentElements/vrImage/stories.js +++ b/entry_types/scrolled/package/src/contentElements/vrImage/stories.js @@ -35,5 +35,6 @@ storiesOfContentElement(module, { caption: 'Some text here' } }, - ] + ], + inlineFileRights: true });