Hide unavailable integration settings (#3604)

This commit is contained in:
MeiMei 2018-12-12 23:21:02 +09:00 committed by syuilo
parent f3ee63fcbe
commit c1a7a21746
1 changed files with 15 additions and 4 deletions

View File

@ -1,22 +1,22 @@
<template> <template>
<ui-card> <ui-card v-if="enableTwitterIntegration || enableDiscordIntegration || enableGithubIntegration">
<div slot="title"><fa icon="share-alt"/> {{ $t('title') }}</div> <div slot="title"><fa icon="share-alt"/> {{ $t('title') }}</div>
<section> <section v-if="enableTwitterIntegration">
<header><fa :icon="['fab', 'twitter']"/> Twitter</header> <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> <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-if="$store.state.i.twitter" @click="disconnectTwitter">{{ $t('disconnect') }}</ui-button>
<ui-button v-else @click="connectTwitter">{{ $t('connect') }}</ui-button> <ui-button v-else @click="connectTwitter">{{ $t('connect') }}</ui-button>
</section> </section>
<section> <section v-if="enableDiscordIntegration">
<header><fa :icon="['fab', 'discord']"/> Discord</header> <header><fa :icon="['fab', 'discord']"/> Discord</header>
<p v-if="$store.state.i.discord">{{ $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 v-if="$store.state.i.discord">{{ $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>
<ui-button v-if="$store.state.i.discord" @click="disconnectDiscord">{{ $t('disconnect') }}</ui-button> <ui-button v-if="$store.state.i.discord" @click="disconnectDiscord">{{ $t('disconnect') }}</ui-button>
<ui-button v-else @click="connectDiscord">{{ $t('connect') }}</ui-button> <ui-button v-else @click="connectDiscord">{{ $t('connect') }}</ui-button>
</section> </section>
<section> <section v-if="enableGithubIntegration">
<header><fa :icon="['fab', 'github']"/> GitHub</header> <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.login}`" target="_blank">@{{ $store.state.i.github.login }}</a></p> <p v-if="$store.state.i.github">{{ $t('connected-to') }}: <a :href="`https://github.com/${$store.state.i.github.login}`" target="_blank">@{{ $store.state.i.github.login }}</a></p>
<ui-button v-if="$store.state.i.github" @click="disconnectGithub">{{ $t('disconnect') }}</ui-button> <ui-button v-if="$store.state.i.github" @click="disconnectGithub">{{ $t('disconnect') }}</ui-button>
@ -39,9 +39,20 @@ export default Vue.extend({
twitterForm: null, twitterForm: null,
discordForm: null, discordForm: null,
githubForm: null, githubForm: null,
enableTwitterIntegration: false,
enableDiscordIntegration: false,
enableGithubIntegration: false,
}; };
}, },
created() {
this.$root.getMeta().then(meta => {
this.enableTwitterIntegration = meta.enableTwitterIntegration;
this.enableDiscordIntegration = meta.enableDiscordIntegration;
this.enableGithubIntegration = meta.enableGithubIntegration;
});
},
mounted() { mounted() {
document.cookie = `i=${this.$store.state.i.token}`; document.cookie = `i=${this.$store.state.i.token}`;
this.$watch('$store.state.i', () => { this.$watch('$store.state.i', () => {