diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-12-03 19:44:03 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-12-03 19:44:03 +0900 |
| commit | 1c86a4bc26720682f0e75cdffaeb082e30016915 (patch) | |
| tree | ce25d2a82be7ac5aa43ce2b3f85983cfc6e44425 /src/client | |
| parent | 10.60.3 (diff) | |
| download | sharkey-1c86a4bc26720682f0e75cdffaeb082e30016915.tar.gz sharkey-1c86a4bc26720682f0e75cdffaeb082e30016915.tar.bz2 sharkey-1c86a4bc26720682f0e75cdffaeb082e30016915.zip | |
Refactor
Diffstat (limited to 'src/client')
6 files changed, 103 insertions, 259 deletions
diff --git a/src/client/app/common/views/components/discord-setting.vue b/src/client/app/common/views/components/discord-setting.vue deleted file mode 100644 index 113df9b0ae..0000000000 --- a/src/client/app/common/views/components/discord-setting.vue +++ /dev/null @@ -1,64 +0,0 @@ -<template> -<div class="mk-discord-setting"> - <p>{{ $t('description') }}</p> - <p class="account" v-if="$store.state.i.discord" :title="`Discord ID: ${$store.state.i.discord.id}`">{{ $t('connected-to') }}: <a :href="`https://discordapp.com/users/${$store.state.i.discord.id}`" target="_blank">@{{ $store.state.i.discord.username }}#{{ $store.state.i.discord.discriminator }}</a></p> - <p> - <a :href="`${apiUrl}/connect/discord`" target="_blank" @click.prevent="connect">{{ $store.state.i.discord ? this.$t('reconnect') : this.$t('connect') }}</a> - <span v-if="$store.state.i.discord"> or </span> - <a :href="`${apiUrl}/disconnect/discord`" target="_blank" v-if="$store.state.i.discord" @click.prevent="disconnect">{{ $t('disconnect') }}</a> - </p> - <p class="id" v-if="$store.state.i.discord">Discord ID: {{ $store.state.i.discord.id }}</p> -</div> -</template> - -<script lang="ts"> -import Vue from 'vue'; -import i18n from '../../../i18n'; -import { apiUrl } from '../../../config'; - -export default Vue.extend({ - i18n: i18n('common/views/components/discord-setting.vue'), - data() { - return { - form: null, - apiUrl - }; - }, - mounted() { - this.$watch('$store.state.i', () => { - if (this.$store.state.i.discord && this.form) - this.form.close(); - }, { - deep: true - }); - }, - methods: { - connect() { - this.form = window.open(apiUrl + '/connect/discord', - 'discord_connect_window', - 'height=570, width=520'); - }, - - disconnect() { - window.open(apiUrl + '/disconnect/discord', - 'discord_disconnect_window', - 'height=570, width=520'); - } - } -}); -</script> - -<style lang="stylus" scoped> -.mk-discord-setting - .account - border solid 1px #e1e8ed - border-radius 4px - padding 16px - - a - font-weight bold - color inherit - - .id - color #8899a6 -</style> diff --git a/src/client/app/common/views/components/github-setting.vue b/src/client/app/common/views/components/github-setting.vue deleted file mode 100644 index 93d7f406f8..0000000000 --- a/src/client/app/common/views/components/github-setting.vue +++ /dev/null @@ -1,64 +0,0 @@ -<template> -<div class="mk-github-setting"> - <p>{{ $t('description') }}</p> - <p class="account" v-if="$store.state.i.github" :title="`GitHub ID: ${$store.state.i.github.id}`">{{ $t('connected-to') }}: <a :href="`https://github.com/${$store.state.i.github.login}`" target="_blank">@{{ $store.state.i.github.login }}</a></p> - <p> - <a :href="`${apiUrl}/connect/github`" target="_blank" @click.prevent="connect">{{ $store.state.i.github ? this.$t('reconnect') : this.$t('connect') }}</a> - <span v-if="$store.state.i.github"> or </span> - <a :href="`${apiUrl}/disconnect/github`" target="_blank" v-if="$store.state.i.github" @click.prevent="disconnect">{{ $t('disconnect') }}</a> - </p> - <p class="id" v-if="$store.state.i.github">GitHub ID: {{ $store.state.i.github.id }}</p> -</div> -</template> - -<script lang="ts"> -import Vue from 'vue'; -import i18n from '../../../i18n'; -import { apiUrl } from '../../../config'; - -export default Vue.extend({ - i18n: i18n('common/views/components/github-setting.vue'), - data() { - return { - form: null, - apiUrl - }; - }, - mounted() { - this.$watch('$store.state.i', () => { - if (this.$store.state.i.github && this.form) - this.form.close(); - }, { - deep: true - }); - }, - methods: { - connect() { - this.form = window.open(apiUrl + '/connect/github', - 'github_connect_window', - 'height=570, width=520'); - }, - - disconnect() { - window.open(apiUrl + '/disconnect/github', - 'github_disconnect_window', - 'height=570, width=520'); - } - } -}); -</script> - -<style lang="stylus" scoped> -.mk-github-setting - .account - border solid 1px #e1e8ed - border-radius 4px - padding 16px - - a - font-weight bold - color inherit - - .id - color #8899a6 -</style> diff --git a/src/client/app/common/views/components/integration-settings.vue b/src/client/app/common/views/components/integration-settings.vue new file mode 100644 index 0000000000..1a0af799a0 --- /dev/null +++ b/src/client/app/common/views/components/integration-settings.vue @@ -0,0 +1,96 @@ +<template> +<ui-card> + <div slot="title"><fa icon="share-alt"/> {{ $t('title') }}</div> + + <section> + <header><fa :icon="['fab', 'twitter']"/> Twitter</header> + <p v-if="$store.state.i.twitter">{{ $t('connected-to') }}: <a :href="`https://twitter.com/${$store.state.i.twitter.screenName}`" target="_blank">@{{ $store.state.i.twitter.screenName }}</a></p> + <ui-button v-if="$store.state.i.twitter" @click="disconnectTwitter">{{ $t('disconnect') }}</ui-button> + <ui-button v-else @click="connectTwitter">{{ $t('connect') }}</ui-button> + </section> + + <section> + <header><fa :icon="['fab', 'discord']"/> Discord</header> + <p v-if="$store.state.i.discord">{{ $t('connected-to') }}: <a :href="`https://discord.com/${$store.state.i.discord.screenName}`" target="_blank">@{{ $store.state.i.discord.screenName }}</a></p> + <ui-button v-if="$store.state.i.discord" @click="disconnectDiscord">{{ $t('disconnect') }}</ui-button> + <ui-button v-else @click="connectDiscord">{{ $t('connect') }}</ui-button> + </section> + + <section> + <header><fa :icon="['fab', 'github']"/> GitHub</header> + <p v-if="$store.state.i.github">{{ $t('connected-to') }}: <a :href="`https://github.com/${$store.state.i.github.screenName}`" target="_blank">@{{ $store.state.i.github.screenName }}</a></p> + <ui-button v-if="$store.state.i.github" @click="disconnectGithub">{{ $t('disconnect') }}</ui-button> + <ui-button v-else @click="connectGithub">{{ $t('connect') }}</ui-button> + </section> +</ui-card> +</template> + +<script lang="ts"> +import Vue from 'vue'; +import i18n from '../../../i18n'; +import { apiUrl } from '../../../config'; + +export default Vue.extend({ + i18n: i18n('common/views/components/integration-settings.vue'), + + data() { + return { + apiUrl, + twitterForm: null, + discordForm: null, + githubForm: null, + }; + }, + + mounted() { + this.$watch('$store.state.i', () => { + if (this.$store.state.i.twitter) { + if (this.twitterForm) this.twitterForm.close(); + } + }, { + deep: true + }); + }, + + methods: { + connectTwitter() { + this.twitterForm = window.open(apiUrl + '/connect/twitter', + 'twitter_connect_window', + 'height=570, width=520'); + }, + + disconnectTwitter() { + window.open(apiUrl + '/disconnect/twitter', + 'twitter_disconnect_window', + 'height=570, width=520'); + }, + + connectDiscord() { + this.discordForm = window.open(apiUrl + '/connect/discord', + 'discord_connect_window', + 'height=570, width=520'); + }, + + disconnectDiscord() { + window.open(apiUrl + '/disconnect/discord', + 'discord_disconnect_window', + 'height=570, width=520'); + }, + + connectGithub() { + this.githubForm = window.open(apiUrl + '/connect/github', + 'github_connect_window', + 'height=570, width=520'); + }, + + disconnectGithub() { + window.open(apiUrl + '/disconnect/github', + 'github_disconnect_window', + 'height=570, width=520'); + }, + } +}); +</script> + +<style lang="stylus" scoped> +</style> diff --git a/src/client/app/common/views/components/twitter-setting.vue b/src/client/app/common/views/components/twitter-setting.vue deleted file mode 100644 index f75bbb7fbf..0000000000 --- a/src/client/app/common/views/components/twitter-setting.vue +++ /dev/null @@ -1,65 +0,0 @@ -<template> -<div class="mk-twitter-setting"> - <p>{{ $t('description') }}</p> - <p class="account" v-if="$store.state.i.twitter" :title="`Twitter ID: ${$store.state.i.twitter.userId}`">{{ $t('connected-to') }}: <a :href="`https://twitter.com/${$store.state.i.twitter.screenName}`" target="_blank">@{{ $store.state.i.twitter.screenName }}</a></p> - <p> - <a :href="`${apiUrl}/connect/twitter`" target="_blank" @click.prevent="connect">{{ $store.state.i.twitter ? this.$t('reconnect') : this.$t('connect') }}</a> - <span v-if="$store.state.i.twitter"> or </span> - <a :href="`${apiUrl}/disconnect/twitter`" target="_blank" v-if="$store.state.i.twitter" @click.prevent="disconnect">{{ $t('disconnect') }}</a> - </p> - <p class="id" v-if="$store.state.i.twitter">Twitter ID: {{ $store.state.i.twitter.userId }}</p> -</div> -</template> - -<script lang="ts"> -import Vue from 'vue'; -import i18n from '../../../i18n'; -import { apiUrl } from '../../../config'; - -export default Vue.extend({ - i18n: i18n('common/views/components/twitter-setting.vue'), - data() { - return { - form: null, - apiUrl - }; - }, - mounted() { - this.$watch('$store.state.i', () => { - if (this.$store.state.i.twitter) { - if (this.form) this.form.close(); - } - }, { - deep: true - }); - }, - methods: { - connect() { - this.form = window.open(apiUrl + '/connect/twitter', - 'twitter_connect_window', - 'height=570, width=520'); - }, - - disconnect() { - window.open(apiUrl + '/disconnect/twitter', - 'twitter_disconnect_window', - 'height=570, width=520'); - } - } -}); -</script> - -<style lang="stylus" scoped> -.mk-twitter-setting - .account - border solid 1px #e1e8ed - border-radius 4px - padding 16px - - a - font-weight bold - color inherit - - .id - color #8899a6 -</style> diff --git a/src/client/app/desktop/views/components/settings.vue b/src/client/app/desktop/views/components/settings.vue index a89982eea4..9cb28eb860 100644 --- a/src/client/app/desktop/views/components/settings.vue +++ b/src/client/app/desktop/views/components/settings.vue @@ -16,27 +16,7 @@ <div class="pages"> <div class="profile" v-show="page == 'profile'"> <x-profile-editor/> - - <ui-card> - <div slot="title"><fa :icon="['fab', 'twitter']"/> {{ $t('twitter') }}</div> - <section> - <x-twitter-setting/> - </section> - </ui-card> - - <ui-card> - <div slot="title"><fa :icon="['fab', 'github']"/> {{ $t('github') }}</div> - <section> - <x-github-setting/> - </section> - </ui-card> - - <ui-card> - <div slot="title"><fa :icon="['fab', 'discord']"/> {{ $t('discord') }}</div> - <section> - <x-discord-setting/> - </section> - </ui-card> + <x-integration-settings/> </div> <ui-card class="theme" v-show="page == 'theme'"> @@ -169,7 +149,7 @@ </section> </ui-card> - <x-language-settings/> + <x-language-settings v-show="page == 'web'"/> <ui-card class="web" v-show="page == 'web'"> <div slot="title"><fa :icon="['far', 'trash-alt']"/> {{ $t('cache') }}</div> @@ -292,9 +272,7 @@ import X2fa from './settings.2fa.vue'; import XApps from './settings.apps.vue'; import XSignins from './settings.signins.vue'; import XTags from './settings.tags.vue'; -import XTwitterSetting from '../../../common/views/components/twitter-setting.vue'; -import XGithubSetting from '../../../common/views/components/github-setting.vue'; -import XDiscordSetting from '../../../common/views/components/discord-setting.vue'; +import XIntegrationSettings from '../../../common/views/components/integration-settings.vue'; import XTheme from '../../../common/views/components/theme.vue'; import XDriveSettings from '../../../common/views/components/drive-settings.vue'; import XMuteAndBlock from '../../../common/views/components/mute-and-block.vue'; @@ -313,9 +291,7 @@ export default Vue.extend({ XApps, XSignins, XTags, - XTwitterSetting, - XGithubSetting, - XDiscordSetting, + XIntegrationSettings, XTheme, XDriveSettings, XMuteAndBlock, diff --git a/src/client/app/mobile/views/pages/settings.vue b/src/client/app/mobile/views/pages/settings.vue index de881af3ba..3e048a1989 100644 --- a/src/client/app/mobile/views/pages/settings.vue +++ b/src/client/app/mobile/views/pages/settings.vue @@ -107,44 +107,7 @@ <x-language-settings/> - <ui-card> - <div slot="title"><fa :icon="['fab', 'twitter']"/> {{ $t('twitter') }}</div> - - <section> - <p class="account" v-if="$store.state.i.twitter"><a :href="`https://twitter.com/${$store.state.i.twitter.screenName}`" target="_blank">@{{ $store.state.i.twitter.screenName }}</a></p> - <p> - <a :href="`${apiUrl}/connect/twitter`" target="_blank">{{ $store.state.i.twitter ? this.$t('twitter-reconnect') : this.$t('twitter-connect') }}</a> - <span v-if="$store.state.i.twitter"> or </span> - <a :href="`${apiUrl}/disconnect/twitter`" target="_blank" v-if="$store.state.i.twitter">{{ $t('twitter-disconnect') }}</a> - </p> - </section> - </ui-card> - - <ui-card> - <div slot="title"><fa :icon="['fab', 'github']"/> {{ $t('github') }}</div> - - <section> - <p class="account" v-if="$store.state.i.github"><a :href="`https://github.com/${$store.state.i.github.login}`" target="_blank">@{{ $store.state.i.github.login }}</a></p> - <p> - <a :href="`${apiUrl}/connect/github`" target="_blank">{{ $store.state.i.github ? this.$t('github-reconnect') : this.$t('github-connect') }}</a> - <span v-if="$store.state.i.github"> or </span> - <a :href="`${apiUrl}/disconnect/github`" target="_blank" v-if="$store.state.i.github">{{ $t('github-disconnect') }}</a> - </p> - </section> - </ui-card> - - <ui-card> - <div slot="title"><fa :icon="['fab', 'discord']"/> {{ $t('discord') }}</div> - - <section> - <p class="account" v-if="$store.state.i.discord"><a :href="`https://discordapp.com/users/${$store.state.i.discord.id}`" target="_blank">@{{ $store.state.i.discord.username }}#{{ $store.state.i.discord.discriminator }}</a></p> - <p> - <a :href="`${apiUrl}/connect/discord`" target="_blank">{{ $store.state.i.discord ? this.$t('discord-reconnect') : this.$t('discord-connect') }}</a> - <span v-if="$store.state.i.discord"> or </span> - <a :href="`${apiUrl}/disconnect/discord`" target="_blank" v-if="$store.state.i.discord">{{ $t('discord-disconnect') }}</a> - </p> - </section> - </ui-card> + <x-integration-settings/> <x-api-settings /> @@ -192,6 +155,7 @@ import XPasswordSettings from '../../../common/views/components/password-setting import XProfileEditor from '../../../common/views/components/profile-editor.vue'; import XApiSettings from '../../../common/views/components/api-settings.vue'; import XLanguageSettings from '../../../common/views/components/language-settings.vue'; +import XIntegrationSettings from '../../../common/views/components/integration-settings.vue'; export default Vue.extend({ i18n: i18n('mobile/views/pages/settings.vue'), @@ -204,6 +168,7 @@ export default Vue.extend({ XProfileEditor, XApiSettings, XLanguageSettings, + XIntegrationSettings, }, data() { |