refactor: refactor dialogs (#1015)
This commit is contained in:
parent
bfdb977f22
commit
d665134d66
|
@ -1,18 +1,12 @@
|
||||||
import AccountProfileOptionsDialog from '../components/AccountProfileOptionsDialog.html'
|
import AccountProfileOptionsDialog from '../components/AccountProfileOptionsDialog.html'
|
||||||
import { createDialogElement } from '../helpers/createDialogElement'
|
import { showDialog } from './showDialog'
|
||||||
import { createDialogId } from '../helpers/createDialogId'
|
|
||||||
|
|
||||||
export default function showAccountProfileOptionsDialog (account, relationship, verifyCredentials) {
|
export default function showAccountProfileOptionsDialog (account, relationship, verifyCredentials) {
|
||||||
let dialog = new AccountProfileOptionsDialog({
|
return showDialog(AccountProfileOptionsDialog, {
|
||||||
target: createDialogElement(),
|
label: 'Profile options dialog',
|
||||||
data: {
|
title: '',
|
||||||
id: createDialogId(),
|
account: account,
|
||||||
label: 'Profile options dialog',
|
relationship: relationship,
|
||||||
title: '',
|
verifyCredentials: verifyCredentials
|
||||||
account: account,
|
|
||||||
relationship: relationship,
|
|
||||||
verifyCredentials: verifyCredentials
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
dialog.show()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,6 @@
|
||||||
import ComposeDialog from '../components/ComposeDialog.html'
|
import ComposeDialog from '../components/ComposeDialog.html'
|
||||||
import { createDialogElement } from '../helpers/createDialogElement'
|
import { showDialog } from './showDialog'
|
||||||
import { createDialogId } from '../helpers/createDialogId'
|
|
||||||
|
|
||||||
export default function showComposeDialog () {
|
export default function showComposeDialog () {
|
||||||
let dialog = new ComposeDialog({
|
return showDialog(ComposeDialog, { label: 'Compose dialog' })
|
||||||
target: createDialogElement(),
|
|
||||||
data: {
|
|
||||||
id: createDialogId(),
|
|
||||||
label: 'Compose dialog'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
dialog.show()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,10 @@
|
||||||
import CopyDialog from '../components/CopyDialog.html'
|
import CopyDialog from '../components/CopyDialog.html'
|
||||||
import { createDialogElement } from '../helpers/createDialogElement'
|
import { showDialog } from './showDialog'
|
||||||
import { createDialogId } from '../helpers/createDialogId'
|
|
||||||
|
|
||||||
export default function showCopyDialog (text) {
|
export default function showCopyDialog (text) {
|
||||||
let dialog = new CopyDialog({
|
return showDialog(CopyDialog, {
|
||||||
target: createDialogElement(),
|
label: 'Copy dialog',
|
||||||
data: {
|
title: 'Copy link',
|
||||||
id: createDialogId(),
|
text
|
||||||
label: 'Copy dialog',
|
|
||||||
title: 'Copy link',
|
|
||||||
text
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
dialog.show()
|
|
||||||
}
|
}
|
||||||
|
|
13
src/routes/_components/dialog/creators/showDialog.js
Normal file
13
src/routes/_components/dialog/creators/showDialog.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import { createDialogElement } from '../helpers/createDialogElement'
|
||||||
|
import { createDialogId } from '../helpers/createDialogId'
|
||||||
|
|
||||||
|
export function showDialog (Dialog, data) {
|
||||||
|
let dialog = new Dialog({
|
||||||
|
target: createDialogElement(),
|
||||||
|
data: Object.assign({
|
||||||
|
id: createDialogId()
|
||||||
|
}, data)
|
||||||
|
})
|
||||||
|
dialog.show()
|
||||||
|
return dialog
|
||||||
|
}
|
|
@ -1,16 +1,10 @@
|
||||||
import EmojiDialog from '../components/EmojiDialog.html'
|
import EmojiDialog from '../components/EmojiDialog.html'
|
||||||
import { createDialogElement } from '../helpers/createDialogElement'
|
import { showDialog } from './showDialog'
|
||||||
import { createDialogId } from '../helpers/createDialogId'
|
|
||||||
|
|
||||||
export default function showEmojiDialog (realm) {
|
export default function showEmojiDialog (realm) {
|
||||||
let emojiDialog = new EmojiDialog({
|
return showDialog(EmojiDialog, {
|
||||||
target: createDialogElement(),
|
label: 'Emoji dialog',
|
||||||
data: {
|
title: 'Emoji',
|
||||||
id: createDialogId(),
|
realm
|
||||||
label: 'Emoji dialog',
|
|
||||||
title: 'Emoji',
|
|
||||||
realm
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
emojiDialog.show()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,10 @@
|
||||||
import MediaDialog from '../components/MediaDialog.html'
|
import MediaDialog from '../components/MediaDialog.html'
|
||||||
import { createDialogElement } from '../helpers/createDialogElement'
|
import { showDialog } from './showDialog'
|
||||||
import { createDialogId } from '../helpers/createDialogId'
|
|
||||||
|
|
||||||
export default function showMediaDialog (mediaItems, scrolledItem) {
|
export default function showMediaDialog (mediaItems, scrolledItem) {
|
||||||
let dialog = new MediaDialog({
|
return showDialog(MediaDialog, {
|
||||||
target: createDialogElement(),
|
label: 'Media dialog',
|
||||||
data: {
|
mediaItems,
|
||||||
id: createDialogId(),
|
scrolledItem
|
||||||
label: 'Media dialog',
|
|
||||||
mediaItems,
|
|
||||||
scrolledItem
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
dialog.show()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,9 @@
|
||||||
import MuteDialog from '../components/MuteDialog.html'
|
import MuteDialog from '../components/MuteDialog.html'
|
||||||
import { createDialogElement } from '../helpers/createDialogElement'
|
import { showDialog } from './showDialog'
|
||||||
import { createDialogId } from '../helpers/createDialogId'
|
|
||||||
|
|
||||||
export default function showMuteDialog (account) {
|
export default function showMuteDialog (account) {
|
||||||
let dialog = new MuteDialog({
|
return showDialog(MuteDialog, {
|
||||||
target: createDialogElement(),
|
label: 'Mute dialog',
|
||||||
data: {
|
account
|
||||||
id: createDialogId(),
|
|
||||||
label: 'Mute dialog',
|
|
||||||
account
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
dialog.show()
|
|
||||||
return dialog
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,10 @@
|
||||||
import PostPrivacyDialog from '../components/PostPrivacyDialog.html'
|
import PostPrivacyDialog from '../components/PostPrivacyDialog.html'
|
||||||
import { createDialogElement } from '../helpers/createDialogElement'
|
import { showDialog } from './showDialog'
|
||||||
import { createDialogId } from '../helpers/createDialogId'
|
|
||||||
|
|
||||||
export default function showPostPrivacyDialog (realm) {
|
export default function showPostPrivacyDialog (realm) {
|
||||||
let dialog = new PostPrivacyDialog({
|
return showDialog(PostPrivacyDialog, {
|
||||||
target: createDialogElement(),
|
label: 'Post privacy dialog',
|
||||||
data: {
|
title: 'Post privacy',
|
||||||
id: createDialogId(),
|
realm: realm
|
||||||
label: 'Post privacy dialog',
|
|
||||||
title: 'Post privacy',
|
|
||||||
realm: realm
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
dialog.show()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,8 @@
|
||||||
import ShortcutHelpDialog from '../components/ShortcutHelpDialog.html'
|
import ShortcutHelpDialog from '../components/ShortcutHelpDialog.html'
|
||||||
import { createDialogElement } from '../helpers/createDialogElement'
|
import { showDialog } from './showDialog'
|
||||||
import { createDialogId } from '../helpers/createDialogId'
|
|
||||||
|
|
||||||
export default function showShortcutHelpDialog (options) {
|
export default function showShortcutHelpDialog (options) {
|
||||||
let dialog = new ShortcutHelpDialog({
|
return showDialog(ShortcutHelpDialog, Object.assign({
|
||||||
target: createDialogElement(),
|
label: 'shortcut help dialog'
|
||||||
data: Object.assign({
|
}, options))
|
||||||
id: createDialogId(),
|
|
||||||
label: 'shortcut help dialog'
|
|
||||||
}, options)
|
|
||||||
})
|
|
||||||
dialog.show()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,10 @@
|
||||||
import StatusOptionsDialog from '../components/StatusOptionsDialog.html'
|
import StatusOptionsDialog from '../components/StatusOptionsDialog.html'
|
||||||
import { createDialogElement } from '../helpers/createDialogElement'
|
import { showDialog } from './showDialog'
|
||||||
import { createDialogId } from '../helpers/createDialogId'
|
|
||||||
|
|
||||||
export default function showStatusOptionsDialog (status) {
|
export default function showStatusOptionsDialog (status) {
|
||||||
let dialog = new StatusOptionsDialog({
|
return showDialog(StatusOptionsDialog, {
|
||||||
target: createDialogElement(),
|
label: 'Status options dialog',
|
||||||
data: {
|
title: '',
|
||||||
id: createDialogId(),
|
status: status
|
||||||
label: 'Status options dialog',
|
|
||||||
title: '',
|
|
||||||
status: status
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
dialog.show()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,8 @@
|
||||||
import TextConfirmationDialog from '../components/TextConfirmationDialog.html'
|
import TextConfirmationDialog from '../components/TextConfirmationDialog.html'
|
||||||
import { createDialogElement } from '../helpers/createDialogElement'
|
import { showDialog } from './showDialog'
|
||||||
import { createDialogId } from '../helpers/createDialogId'
|
|
||||||
|
|
||||||
export default function showTextConfirmationDialog (options) {
|
export default function showTextConfirmationDialog (options) {
|
||||||
let dialog = new TextConfirmationDialog({
|
return showDialog(TextConfirmationDialog, Object.assign({
|
||||||
target: createDialogElement(),
|
label: 'Confirmation dialog'
|
||||||
data: Object.assign({
|
}, options))
|
||||||
id: createDialogId(),
|
|
||||||
label: 'Confirmation dialog'
|
|
||||||
}, options)
|
|
||||||
})
|
|
||||||
dialog.show()
|
|
||||||
return dialog
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue