diff --git a/routes/_components/dialog/AccountProfileOptionsDialog.html b/routes/_components/dialog/components/AccountProfileOptionsDialog.html similarity index 65% rename from routes/_components/dialog/AccountProfileOptionsDialog.html rename to routes/_components/dialog/components/AccountProfileOptionsDialog.html index 9a925a6d..65d68b9b 100644 --- a/routes/_components/dialog/AccountProfileOptionsDialog.html +++ b/routes/_components/dialog/components/AccountProfileOptionsDialog.html @@ -1,20 +1,27 @@ \ No newline at end of file diff --git a/routes/_components/dialog/ComposeDialog.html b/routes/_components/dialog/components/ComposeDialog.html similarity index 55% rename from routes/_components/dialog/ComposeDialog.html rename to routes/_components/dialog/components/ComposeDialog.html index eb947cc2..4b0f466e 100644 --- a/routes/_components/dialog/ComposeDialog.html +++ b/routes/_components/dialog/components/ComposeDialog.html @@ -1,41 +1,37 @@ \ No newline at end of file diff --git a/routes/_components/dialog/ConfirmationDialog.html b/routes/_components/dialog/components/ConfirmationDialog.html similarity index 69% rename from routes/_components/dialog/ConfirmationDialog.html rename to routes/_components/dialog/components/ConfirmationDialog.html index ff72f0d3..f6788783 100644 --- a/routes/_components/dialog/ConfirmationDialog.html +++ b/routes/_components/dialog/components/ConfirmationDialog.html @@ -1,9 +1,7 @@

@@ -36,16 +34,23 @@ \ No newline at end of file diff --git a/routes/_components/dialog/EmojiDialog.html b/routes/_components/dialog/components/EmojiDialog.html similarity index 84% rename from routes/_components/dialog/EmojiDialog.html rename to routes/_components/dialog/components/EmojiDialog.html index e3be736a..e90ef484 100644 --- a/routes/_components/dialog/EmojiDialog.html +++ b/routes/_components/dialog/components/EmojiDialog.html @@ -1,10 +1,8 @@

{{#if emojis.length}} @@ -60,10 +58,14 @@ \ No newline at end of file diff --git a/routes/_components/dialog/ModalDialog.html b/routes/_components/dialog/components/ModalDialog.html similarity index 82% rename from routes/_components/dialog/ModalDialog.html rename to routes/_components/dialog/components/ModalDialog.html index 5311a3a1..8702d215 100644 --- a/routes/_components/dialog/ModalDialog.html +++ b/routes/_components/dialog/components/ModalDialog.html @@ -116,10 +116,21 @@ \ No newline at end of file diff --git a/routes/_components/dialog/PostPrivacyDialog.html b/routes/_components/dialog/components/PostPrivacyDialog.html similarity index 75% rename from routes/_components/dialog/PostPrivacyDialog.html rename to routes/_components/dialog/components/PostPrivacyDialog.html index c8a04f76..7c7f724e 100644 --- a/routes/_components/dialog/PostPrivacyDialog.html +++ b/routes/_components/dialog/components/PostPrivacyDialog.html @@ -1,21 +1,23 @@ \ No newline at end of file diff --git a/routes/_components/dialog/showAccountProfileOptionsDialog.js b/routes/_components/dialog/creators/showAccountProfileOptionsDialog.js similarity index 51% rename from routes/_components/dialog/showAccountProfileOptionsDialog.js rename to routes/_components/dialog/creators/showAccountProfileOptionsDialog.js index 8e0593c9..9083201c 100644 --- a/routes/_components/dialog/showAccountProfileOptionsDialog.js +++ b/routes/_components/dialog/creators/showAccountProfileOptionsDialog.js @@ -1,10 +1,12 @@ -import AccountProfileOptionsDialog from './AccountProfileOptionsDialog.html' -import { createDialogElement } from './createDialogElement' +import AccountProfileOptionsDialog from '../components/AccountProfileOptionsDialog.html' +import { createDialogElement } from '../helpers/createDialogElement' +import { createDialogId } from '../helpers/createDialogId' export function showAccountProfileOptionsDialog (account) { let dialog = new AccountProfileOptionsDialog({ target: createDialogElement(), data: { + id: createDialogId(), label: 'Profile options dialog', title: '', account: account diff --git a/routes/_components/dialog/creators/showComposeDialog.js b/routes/_components/dialog/creators/showComposeDialog.js new file mode 100644 index 00000000..ee45775a --- /dev/null +++ b/routes/_components/dialog/creators/showComposeDialog.js @@ -0,0 +1,14 @@ +import ComposeDialog from '../components/ComposeDialog.html' +import { createDialogElement } from '../helpers/createDialogElement' +import { createDialogId } from '../helpers/createDialogId' + +export function showComposeDialog () { + let dialog = new ComposeDialog({ + target: createDialogElement(), + data: { + id: createDialogId(), + label: 'Compose dialog' + } + }) + dialog.show() +} diff --git a/routes/_components/dialog/showConfirmationDialog.js b/routes/_components/dialog/creators/showConfirmationDialog.js similarity index 50% rename from routes/_components/dialog/showConfirmationDialog.js rename to routes/_components/dialog/creators/showConfirmationDialog.js index 1fd6be09..e023e125 100644 --- a/routes/_components/dialog/showConfirmationDialog.js +++ b/routes/_components/dialog/creators/showConfirmationDialog.js @@ -1,10 +1,12 @@ -import ConfirmationDialog from './ConfirmationDialog.html' -import { createDialogElement } from './createDialogElement' +import ConfirmationDialog from '../components/ConfirmationDialog.html' +import { createDialogElement } from '../helpers/createDialogElement' +import { createDialogId } from '../helpers/createDialogId' export function showConfirmationDialog (options) { let dialog = new ConfirmationDialog({ target: createDialogElement(), data: Object.assign({ + id: createDialogId(), label: 'Confirmation dialog' }, options) }) diff --git a/routes/_components/dialog/showEmojiDialog.js b/routes/_components/dialog/creators/showEmojiDialog.js similarity index 52% rename from routes/_components/dialog/showEmojiDialog.js rename to routes/_components/dialog/creators/showEmojiDialog.js index ba56e0d0..7bead1fb 100644 --- a/routes/_components/dialog/showEmojiDialog.js +++ b/routes/_components/dialog/creators/showEmojiDialog.js @@ -1,10 +1,12 @@ -import EmojiDialog from './EmojiDialog.html' -import { createDialogElement } from './createDialogElement' +import EmojiDialog from '../components/EmojiDialog.html' +import { createDialogElement } from '../helpers/createDialogElement' +import { createDialogId } from '../helpers/createDialogId' export function showEmojiDialog (realm) { let emojiDialog = new EmojiDialog({ target: createDialogElement(), data: { + id: createDialogId(), label: 'Emoji dialog', title: 'Custom emoji', realm diff --git a/routes/_components/dialog/showImageDialog.js b/routes/_components/dialog/creators/showImageDialog.js similarity index 59% rename from routes/_components/dialog/showImageDialog.js rename to routes/_components/dialog/creators/showImageDialog.js index 530cda68..4338350e 100644 --- a/routes/_components/dialog/showImageDialog.js +++ b/routes/_components/dialog/creators/showImageDialog.js @@ -1,10 +1,12 @@ -import ImageDialog from './ImageDialog.html' -import { createDialogElement } from './createDialogElement' +import ImageDialog from '../components/ImageDialog.html' +import { createDialogElement } from '../helpers/createDialogElement' +import { createDialogId } from '../helpers/createDialogId' export function showImageDialog (poster, src, type, width, height, description) { let imageDialog = new ImageDialog({ target: createDialogElement(), data: { + id: createDialogId(), label: 'Image dialog', poster, src, diff --git a/routes/_components/dialog/showPostPrivacyDialog.js b/routes/_components/dialog/creators/showPostPrivacyDialog.js similarity index 52% rename from routes/_components/dialog/showPostPrivacyDialog.js rename to routes/_components/dialog/creators/showPostPrivacyDialog.js index 6c38490c..bfeab4d2 100644 --- a/routes/_components/dialog/showPostPrivacyDialog.js +++ b/routes/_components/dialog/creators/showPostPrivacyDialog.js @@ -1,10 +1,12 @@ -import PostPrivacyDialog from './PostPrivacyDialog.html' -import { createDialogElement } from './createDialogElement' +import PostPrivacyDialog from '../components/PostPrivacyDialog.html' +import { createDialogElement } from '../helpers/createDialogElement' +import { createDialogId } from '../helpers/createDialogId' export function showPostPrivacyDialog (realm) { let dialog = new PostPrivacyDialog({ target: createDialogElement(), data: { + id: createDialogId(), label: 'Post privacy dialog', title: 'Post privacy', realm: realm diff --git a/routes/_components/dialog/showStatusOptionsDialog.js b/routes/_components/dialog/creators/showStatusOptionsDialog.js similarity index 52% rename from routes/_components/dialog/showStatusOptionsDialog.js rename to routes/_components/dialog/creators/showStatusOptionsDialog.js index 66e61666..358d134d 100644 --- a/routes/_components/dialog/showStatusOptionsDialog.js +++ b/routes/_components/dialog/creators/showStatusOptionsDialog.js @@ -1,10 +1,12 @@ -import StatusOptionsDialog from './StatusOptionsDialog.html' -import { createDialogElement } from './createDialogElement' +import StatusOptionsDialog from '../components/StatusOptionsDialog.html' +import { createDialogElement } from '../helpers/createDialogElement' +import { createDialogId } from '../helpers/createDialogId' export function showStatusOptionsDialog (statusId) { let dialog = new StatusOptionsDialog({ target: createDialogElement(), data: { + id: createDialogId(), label: 'Status options dialog', title: '', statusId: statusId diff --git a/routes/_components/dialog/showVideoDialog.js b/routes/_components/dialog/creators/showVideoDialog.js similarity index 58% rename from routes/_components/dialog/showVideoDialog.js rename to routes/_components/dialog/creators/showVideoDialog.js index 28a0295c..7e36ec2c 100644 --- a/routes/_components/dialog/showVideoDialog.js +++ b/routes/_components/dialog/creators/showVideoDialog.js @@ -1,10 +1,12 @@ -import VideoDialog from './VideoDialog.html' -import { createDialogElement } from './createDialogElement' +import VideoDialog from '../components/VideoDialog.html' +import { createDialogElement } from '../helpers/createDialogElement' +import { createDialogId } from '../helpers/createDialogId' export function showVideoDialog (poster, src, width, height, description) { let videoDialog = new VideoDialog({ target: createDialogElement(), data: { + id: createDialogId(), label: 'Video dialog', poster, src, diff --git a/routes/_components/dialog/dialogs.js b/routes/_components/dialog/dialogs.js index 691541e1..6bea4455 100644 --- a/routes/_components/dialog/dialogs.js +++ b/routes/_components/dialog/dialogs.js @@ -1,8 +1,8 @@ -export * from './showConfirmationDialog' -export * from './showImageDialog' -export * from './showVideoDialog' -export * from './showEmojiDialog' -export * from './showPostPrivacyDialog' -export * from './showStatusOptionsDialog' -export * from './showComposeDialog' -export * from './showAccountProfileOptionsDialog' +export * from './creators/showConfirmationDialog' +export * from './creators/showImageDialog' +export * from './creators/showVideoDialog' +export * from './creators/showEmojiDialog' +export * from './creators/showPostPrivacyDialog' +export * from './creators/showStatusOptionsDialog' +export * from './creators/showComposeDialog' +export * from './creators/showAccountProfileOptionsDialog' diff --git a/routes/_components/dialog/helpers/closeDialog.js b/routes/_components/dialog/helpers/closeDialog.js new file mode 100644 index 00000000..351d1c09 --- /dev/null +++ b/routes/_components/dialog/helpers/closeDialog.js @@ -0,0 +1,6 @@ +import { emit } from '../../../_utils/eventBus' + +export function close () { + let id = this.get('id') + emit('closeDialog', id) +} diff --git a/routes/_components/dialog/createDialogElement.js b/routes/_components/dialog/helpers/createDialogElement.js similarity index 100% rename from routes/_components/dialog/createDialogElement.js rename to routes/_components/dialog/helpers/createDialogElement.js diff --git a/routes/_components/dialog/helpers/createDialogId.js b/routes/_components/dialog/helpers/createDialogId.js new file mode 100644 index 00000000..12f63daf --- /dev/null +++ b/routes/_components/dialog/helpers/createDialogId.js @@ -0,0 +1,5 @@ +let count = -1 + +export function createDialogId () { + return ++count +} \ No newline at end of file diff --git a/routes/_components/dialog/helpers/onCreateDialog.js b/routes/_components/dialog/helpers/onCreateDialog.js new file mode 100644 index 00000000..6a04a06f --- /dev/null +++ b/routes/_components/dialog/helpers/onCreateDialog.js @@ -0,0 +1,12 @@ +import { on } from '../../../_utils/eventBus' + +function onDestroy (id) { + if (this.get('id') !== id) { + return + } + this.destroy() +} + +export function oncreate () { + on('destroyDialog', this, onDestroy) +} diff --git a/routes/_components/dialog/helpers/showDialog.js b/routes/_components/dialog/helpers/showDialog.js new file mode 100644 index 00000000..651a7853 --- /dev/null +++ b/routes/_components/dialog/helpers/showDialog.js @@ -0,0 +1,6 @@ +import { emit } from '../../../_utils/eventBus' + +export function show () { + let id = this.get('id') + emit('showDialog', id) +} diff --git a/routes/_components/dialog/showComposeDialog.js b/routes/_components/dialog/showComposeDialog.js deleted file mode 100644 index bd4612cb..00000000 --- a/routes/_components/dialog/showComposeDialog.js +++ /dev/null @@ -1,12 +0,0 @@ -import ComposeDialog from './ComposeDialog.html' -import { createDialogElement } from './createDialogElement' - -export function showComposeDialog () { - let dialog = new ComposeDialog({ - target: createDialogElement(), - data: { - label: 'Compose dialog' - } - }) - dialog.show() -} diff --git a/tests/spec/108-compose-dialog.js b/tests/spec/108-compose-dialog.js index 516de283..0218a885 100644 --- a/tests/spec/108-compose-dialog.js +++ b/tests/spec/108-compose-dialog.js @@ -3,6 +3,7 @@ import { scrollContainerToTop } from '../utils' import { foobarRole } from '../roles' +import { Selector as $ } from 'testcafe' fixture`108-compose-dialog.js` .page`http://localhost:4002` @@ -27,3 +28,24 @@ test('can compose using a dialog', async t => { .click(showMoreButton) await t.expect(getNthStatus(0).innerText).contains('hello from the modal', {timeout: 20000}) }) + +test('can use emoji dialog within compose dialog', async t => { + await t.useRole(foobarRole) + await scrollToStatus(t, 15) + await t.expect(composeButton.getAttribute('aria-label')).eql('Compose') + await sleep(2000) + await t.click(composeButton) + .click(modalDialog.find('.compose-box-toolbar button:nth-child(1)')) + .click($('button img[title=":blobpats:"]')) + .expect(modalDialog.find('.compose-box-input').value).eql(':blobpats: ') + .click(modalDialog.find('.compose-box-button-compose')) + .expect(modalDialog.exists).notOk() + await sleep(5000) + await scrollToTopOfTimeline(t) + await t.hover(getNthStatus(0)) + await scrollContainerToTop() + await t + .expect(showMoreButton.innerText).contains('Show 1 more') + .click(showMoreButton) + await t.expect(getNthStatus(0).find('img[alt=":blobpats:"]').exists).ok({timeout: 20000}) +}) \ No newline at end of file