From 3b49732cbb008b8b9864233d14760c01dc65c73e Mon Sep 17 00:00:00 2001 From: Rishabh Date: Fri, 19 Nov 2021 19:34:17 +0530 Subject: [PATCH] Added first pass of upload cards refs https://github.com/TryGhost/Team/issues/1229 refs https://github.com/TryGhost/Team/issues/1230 refs https://github.com/TryGhost/Team/issues/1231 --- ghost/admin/app/services/feature.js | 3 ++ ghost/admin/app/templates/settings/labs.hbs | 39 ++++++++++++++++++ .../addon/components/koenig-card-audio.hbs | 1 + .../addon/components/koenig-card-audio.js | 4 ++ .../addon/components/koenig-card-file.hbs | 1 + .../addon/components/koenig-card-file.js | 4 ++ .../addon/components/koenig-card-video.hbs | 1 + .../addon/components/koenig-card-video.js | 4 ++ .../lib/koenig-editor/addon/options/cards.js | 40 ++++++++++++++++++- .../app/components/koenig-card-audio.js | 1 + .../app/components/koenig-card-file.js | 1 + .../app/components/koenig-card-video.js | 1 + .../components/koenig-card-audio-test.js | 27 +++++++++++++ .../components/koenig-card-file-test.js | 27 +++++++++++++ .../components/koenig-card-video-test.js | 27 +++++++++++++ 15 files changed, 179 insertions(+), 2 deletions(-) create mode 100644 ghost/admin/lib/koenig-editor/addon/components/koenig-card-audio.hbs create mode 100644 ghost/admin/lib/koenig-editor/addon/components/koenig-card-audio.js create mode 100644 ghost/admin/lib/koenig-editor/addon/components/koenig-card-file.hbs create mode 100644 ghost/admin/lib/koenig-editor/addon/components/koenig-card-file.js create mode 100644 ghost/admin/lib/koenig-editor/addon/components/koenig-card-video.hbs create mode 100644 ghost/admin/lib/koenig-editor/addon/components/koenig-card-video.js create mode 100644 ghost/admin/lib/koenig-editor/app/components/koenig-card-audio.js create mode 100644 ghost/admin/lib/koenig-editor/app/components/koenig-card-file.js create mode 100644 ghost/admin/lib/koenig-editor/app/components/koenig-card-video.js create mode 100644 ghost/admin/tests/integration/components/koenig-card-audio-test.js create mode 100644 ghost/admin/tests/integration/components/koenig-card-file-test.js create mode 100644 ghost/admin/tests/integration/components/koenig-card-video-test.js diff --git a/ghost/admin/app/services/feature.js b/ghost/admin/app/services/feature.js index e26907b639..410829e93a 100644 --- a/ghost/admin/app/services/feature.js +++ b/ghost/admin/app/services/feature.js @@ -65,6 +65,9 @@ export default Service.extend({ nftCard: feature('nftCard', {developer: true}), accordionCard: feature('accordionCard', {developer: true}), gifsCard: feature('gifsCard', {developer: true}), + fileCard: feature('fileCard', {developer: true}), + audioCard: feature('audioCard', {developer: true}), + videoCard: feature('videoCard', {developer: true}), _user: null, diff --git a/ghost/admin/app/templates/settings/labs.hbs b/ghost/admin/app/templates/settings/labs.hbs index 4c4fb28548..6f7e9e4baf 100644 --- a/ghost/admin/app/templates/settings/labs.hbs +++ b/ghost/admin/app/templates/settings/labs.hbs @@ -404,6 +404,45 @@ +
+
+
+

Cardmageddon - File

+

+ Add a generic file +

+
+
+ +
+
+
+
+
+
+

Cardmageddon - Video

+

+ Add a video file +

+
+
+ +
+
+
+
+
+
+

Cardmageddon - Audio

+

+ Add an audio file +

+
+
+ +
+
+
{{/if}} diff --git a/ghost/admin/lib/koenig-editor/addon/components/koenig-card-audio.hbs b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-audio.hbs new file mode 100644 index 0000000000..fb5c4b157d --- /dev/null +++ b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-audio.hbs @@ -0,0 +1 @@ +{{yield}} \ No newline at end of file diff --git a/ghost/admin/lib/koenig-editor/addon/components/koenig-card-audio.js b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-audio.js new file mode 100644 index 0000000000..1cf48e3432 --- /dev/null +++ b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-audio.js @@ -0,0 +1,4 @@ +import Component from '@glimmer/component'; + +export default class KoenigCardAudioComponent extends Component { +} diff --git a/ghost/admin/lib/koenig-editor/addon/components/koenig-card-file.hbs b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-file.hbs new file mode 100644 index 0000000000..fb5c4b157d --- /dev/null +++ b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-file.hbs @@ -0,0 +1 @@ +{{yield}} \ No newline at end of file diff --git a/ghost/admin/lib/koenig-editor/addon/components/koenig-card-file.js b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-file.js new file mode 100644 index 0000000000..20c859184d --- /dev/null +++ b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-file.js @@ -0,0 +1,4 @@ +import Component from '@glimmer/component'; + +export default class KoenigCardFileComponent extends Component { +} diff --git a/ghost/admin/lib/koenig-editor/addon/components/koenig-card-video.hbs b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-video.hbs new file mode 100644 index 0000000000..fb5c4b157d --- /dev/null +++ b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-video.hbs @@ -0,0 +1 @@ +{{yield}} \ No newline at end of file diff --git a/ghost/admin/lib/koenig-editor/addon/components/koenig-card-video.js b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-video.js new file mode 100644 index 0000000000..4044854c1d --- /dev/null +++ b/ghost/admin/lib/koenig-editor/addon/components/koenig-card-video.js @@ -0,0 +1,4 @@ +import Component from '@glimmer/component'; + +export default class KoenigCardVideoComponent extends Component { +} diff --git a/ghost/admin/lib/koenig-editor/addon/options/cards.js b/ghost/admin/lib/koenig-editor/addon/options/cards.js index ea2f5c03b4..ae1925e664 100644 --- a/ghost/admin/lib/koenig-editor/addon/options/cards.js +++ b/ghost/admin/lib/koenig-editor/addon/options/cards.js @@ -17,7 +17,10 @@ export const CARD_COMPONENT_MAP = { nft: 'koenig-card-nft', toggle: 'koenig-card-accordion', 'email-cta': 'koenig-card-email-cta', - paywall: 'koenig-card-paywall' + paywall: 'koenig-card-paywall', + file: 'koenig-card-file', + audio: 'koenig-card-audio', + video: 'koenig-card-video' }; // map card names to generic icons (used for ghost elements when dragging) @@ -37,7 +40,10 @@ export const CARD_ICON_MAP = { nft: 'koenig/kg-card-type-gen-embed', toggle: 'koenig/kg-card-type-accordion', 'email-cta': 'koenig/kg-card-type-gen-embed', - paywall: 'koenig/kg-card-type-divider' + paywall: 'koenig/kg-card-type-divider', + file: 'koenig/kg-card-type-divider', + audio: 'koenig/kg-card-type-divider', + video: 'koenig/kg-card-type-video' }; // TODO: move koenigOptions directly into cards now that card components register @@ -58,6 +64,9 @@ export default [ createComponentCard('callout'), createComponentCard('nft', {hasEditMode: false}), createComponentCard('toggle'), + createComponentCard('file'), + createComponentCard('audio'), + createComponentCard('video'), createComponentCard('paywall', {hasEditMode: false, selectAfterInsert: false}) ]; @@ -189,6 +198,33 @@ export const CARD_MENU = [ type: 'card', replaceArg: 'toggle', isAvailable: 'feature.accordionCard' + }, + { + label: 'File', + icon: 'koenig/kg-card-type-accordion', + desc: 'Add a file', + matches: ['file'], + type: 'card', + replaceArg: 'file', + isAvailable: 'feature.fileCard' + }, + { + label: 'Audio', + icon: 'koenig/kg-card-type-accordion', + desc: 'Add an audio file', + matches: ['audio'], + type: 'card', + replaceArg: 'audio', + isAvailable: 'feature.audioCard' + }, + { + label: 'Video', + icon: 'koenig/kg-card-type-accordion', + desc: 'Add a video file', + matches: ['video'], + type: 'card', + replaceArg: 'video', + isAvailable: 'feature.videoCard' }] }, { diff --git a/ghost/admin/lib/koenig-editor/app/components/koenig-card-audio.js b/ghost/admin/lib/koenig-editor/app/components/koenig-card-audio.js new file mode 100644 index 0000000000..de88d47ad0 --- /dev/null +++ b/ghost/admin/lib/koenig-editor/app/components/koenig-card-audio.js @@ -0,0 +1 @@ +export { default } from 'koenig-editor/components/koenig-card-audio'; \ No newline at end of file diff --git a/ghost/admin/lib/koenig-editor/app/components/koenig-card-file.js b/ghost/admin/lib/koenig-editor/app/components/koenig-card-file.js new file mode 100644 index 0000000000..b6db852e7b --- /dev/null +++ b/ghost/admin/lib/koenig-editor/app/components/koenig-card-file.js @@ -0,0 +1 @@ +export {default} from 'koenig-editor/components/koenig-card-file'; diff --git a/ghost/admin/lib/koenig-editor/app/components/koenig-card-video.js b/ghost/admin/lib/koenig-editor/app/components/koenig-card-video.js new file mode 100644 index 0000000000..add03d9cd5 --- /dev/null +++ b/ghost/admin/lib/koenig-editor/app/components/koenig-card-video.js @@ -0,0 +1 @@ +export { default } from 'koenig-editor/components/koenig-card-video'; \ No newline at end of file diff --git a/ghost/admin/tests/integration/components/koenig-card-audio-test.js b/ghost/admin/tests/integration/components/koenig-card-audio-test.js new file mode 100644 index 0000000000..4ef70e2b13 --- /dev/null +++ b/ghost/admin/tests/integration/components/koenig-card-audio-test.js @@ -0,0 +1,27 @@ +import { expect } from 'chai'; +import { describe, it } from 'mocha'; +import { setupRenderingTest } from 'ember-mocha'; +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +describe('Integration | Component | koenig-card-audio', function() { + setupRenderingTest(); + + it('renders', async function() { + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.set('myAction', function(val) { ... }); + + await render(hbs``); + + expect(this.element.textContent.trim()).to.equal(''); + + // Template block usage: + await render(hbs` + + template block text + + `); + + expect(this.element.textContent.trim()).to.equal('template block text'); + }); +}); diff --git a/ghost/admin/tests/integration/components/koenig-card-file-test.js b/ghost/admin/tests/integration/components/koenig-card-file-test.js new file mode 100644 index 0000000000..3172d5c17f --- /dev/null +++ b/ghost/admin/tests/integration/components/koenig-card-file-test.js @@ -0,0 +1,27 @@ +import { expect } from 'chai'; +import { describe, it } from 'mocha'; +import { setupRenderingTest } from 'ember-mocha'; +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +describe('Integration | Component | koenig-card-file', function() { + setupRenderingTest(); + + it('renders', async function() { + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.set('myAction', function(val) { ... }); + + await render(hbs``); + + expect(this.element.textContent.trim()).to.equal(''); + + // Template block usage: + await render(hbs` + + template block text + + `); + + expect(this.element.textContent.trim()).to.equal('template block text'); + }); +}); diff --git a/ghost/admin/tests/integration/components/koenig-card-video-test.js b/ghost/admin/tests/integration/components/koenig-card-video-test.js new file mode 100644 index 0000000000..d212811077 --- /dev/null +++ b/ghost/admin/tests/integration/components/koenig-card-video-test.js @@ -0,0 +1,27 @@ +import { expect } from 'chai'; +import { describe, it } from 'mocha'; +import { setupRenderingTest } from 'ember-mocha'; +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +describe('Integration | Component | koenig-card-video', function() { + setupRenderingTest(); + + it('renders', async function() { + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.set('myAction', function(val) { ... }); + + await render(hbs``); + + expect(this.element.textContent.trim()).to.equal(''); + + // Template block usage: + await render(hbs` + + template block text + + `); + + expect(this.element.textContent.trim()).to.equal('template block text'); + }); +});