2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2020-01-30 03:10:42 +01:00
|
|
|
<section class="_card" v-if="enableTwitterIntegration || enableDiscordIntegration || enableGithubIntegration">
|
2020-01-29 20:37:25 +01:00
|
|
|
<div class="_title"><fa :icon="faShareAlt"/> {{ $t('integration') }}</div>
|
2020-01-31 23:16:52 +01:00
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
<div class="_content" v-if="enableTwitterIntegration">
|
|
|
|
<header><fa :icon="faTwitter"/> Twitter</header>
|
2020-01-31 23:16:52 +01:00
|
|
|
<p v-if="integrations.twitter">{{ $t('connectedTo') }}: <a :href="`https://twitter.com/${integrations.twitter.screenName}`" rel="nofollow noopener" target="_blank">@{{ integrations.twitter.screenName }}</a></p>
|
2020-07-24 18:36:39 +02:00
|
|
|
<mk-button v-if="integrations.twitter" @click="disconnectTwitter" v-t="'disconnectSerice'"></mk-button>
|
|
|
|
<mk-button v-else @click="connectTwitter" v-t="'connectSerice'"></mk-button>
|
2020-01-29 20:37:25 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="_content" v-if="enableDiscordIntegration">
|
|
|
|
<header><fa :icon="faDiscord"/> Discord</header>
|
2020-01-31 23:16:52 +01:00
|
|
|
<p v-if="integrations.discord">{{ $t('connectedTo') }}: <a :href="`https://discordapp.com/users/${integrations.discord.id}`" rel="nofollow noopener" target="_blank">@{{ integrations.discord.username }}#{{ integrations.discord.discriminator }}</a></p>
|
2020-07-24 18:36:39 +02:00
|
|
|
<mk-button v-if="integrations.discord" @click="disconnectDiscord" v-t="'disconnectSerice'"></mk-button>
|
|
|
|
<mk-button v-else @click="connectDiscord" v-t="'connectSerice'"></mk-button>
|
2020-01-29 20:37:25 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="_content" v-if="enableGithubIntegration">
|
|
|
|
<header><fa :icon="faGithub"/> GitHub</header>
|
2020-01-31 23:16:52 +01:00
|
|
|
<p v-if="integrations.github">{{ $t('connectedTo') }}: <a :href="`https://github.com/${integrations.github.login}`" rel="nofollow noopener" target="_blank">@{{ integrations.github.login }}</a></p>
|
2020-07-24 18:36:39 +02:00
|
|
|
<mk-button v-if="integrations.github" @click="disconnectGithub" v-t="'disconnectSerice'"></mk-button>
|
|
|
|
<mk-button v-else @click="connectGithub" v-t="'connectSerice'"></mk-button>
|
2020-01-29 20:37:25 +01:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import { faShareAlt } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import { faTwitter, faDiscord, faGithub } from '@fortawesome/free-brands-svg-icons';
|
|
|
|
import { apiUrl } from '../../config';
|
|
|
|
import MkButton from '../../components/ui/button.vue';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
components: {
|
|
|
|
MkButton
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
apiUrl,
|
|
|
|
twitterForm: null,
|
|
|
|
discordForm: null,
|
|
|
|
githubForm: null,
|
|
|
|
enableTwitterIntegration: false,
|
|
|
|
enableDiscordIntegration: false,
|
|
|
|
enableGithubIntegration: false,
|
|
|
|
faShareAlt, faTwitter, faDiscord, faGithub
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2020-01-31 23:16:52 +01:00
|
|
|
computed: {
|
|
|
|
integrations() {
|
|
|
|
return this.$store.state.i.integrations;
|
2020-02-10 15:17:42 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
meta() {
|
|
|
|
return this.$store.state.instance.meta;
|
|
|
|
},
|
2020-01-31 23:16:52 +01:00
|
|
|
},
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
created() {
|
2020-02-10 15:17:42 +01:00
|
|
|
this.enableTwitterIntegration = this.meta.enableTwitterIntegration;
|
|
|
|
this.enableDiscordIntegration = this.meta.enableDiscordIntegration;
|
|
|
|
this.enableGithubIntegration = this.meta.enableGithubIntegration;
|
2020-01-29 20:37:25 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
2020-03-20 05:56:22 +01:00
|
|
|
document.cookie = `igi=${this.$store.state.i.token}; path=/;` +
|
|
|
|
` max-age=31536000;` +
|
2020-01-29 20:37:25 +01:00
|
|
|
(document.location.protocol.startsWith('https') ? ' secure' : '');
|
2020-03-20 05:56:22 +01:00
|
|
|
|
2020-01-31 23:16:52 +01:00
|
|
|
this.$watch('integrations', () => {
|
|
|
|
if (this.integrations.twitter) {
|
2020-01-29 20:37:25 +01:00
|
|
|
if (this.twitterForm) this.twitterForm.close();
|
|
|
|
}
|
2020-01-31 23:16:52 +01:00
|
|
|
if (this.integrations.discord) {
|
2020-01-29 20:37:25 +01:00
|
|
|
if (this.discordForm) this.discordForm.close();
|
|
|
|
}
|
2020-01-31 23:16:52 +01:00
|
|
|
if (this.integrations.github) {
|
2020-01-29 20:37:25 +01:00
|
|
|
if (this.githubForm) this.githubForm.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>
|