2020-01-29 12:37:25 -07:00
|
|
|
<template>
|
2022-01-04 02:21:00 -07:00
|
|
|
<div class="_formRoot">
|
2022-04-30 20:23:12 -06:00
|
|
|
<FormSection v-if="instance.enableTwitterIntegration">
|
2022-01-04 02:21:00 -07:00
|
|
|
<template #label><i class="fab fa-twitter"></i> Twitter</template>
|
2022-04-30 20:23:12 -06:00
|
|
|
<p v-if="integrations.twitter">{{ i18n.ts.connectedTo }}: <a :href="`https://twitter.com/${integrations.twitter.screenName}`" rel="nofollow noopener" target="_blank">@{{ integrations.twitter.screenName }}</a></p>
|
|
|
|
<MkButton v-if="integrations.twitter" danger @click="disconnectTwitter">{{ i18n.ts.disconnectService }}</MkButton>
|
|
|
|
<MkButton v-else primary @click="connectTwitter">{{ i18n.ts.connectService }}</MkButton>
|
2022-01-04 02:21:00 -07:00
|
|
|
</FormSection>
|
2020-01-29 12:37:25 -07:00
|
|
|
|
2022-04-30 20:23:12 -06:00
|
|
|
<FormSection v-if="instance.enableDiscordIntegration">
|
2022-01-04 02:21:00 -07:00
|
|
|
<template #label><i class="fab fa-discord"></i> Discord</template>
|
2022-04-30 20:23:12 -06:00
|
|
|
<p v-if="integrations.discord">{{ i18n.ts.connectedTo }}: <a :href="`https://discord.com/users/${integrations.discord.id}`" rel="nofollow noopener" target="_blank">@{{ integrations.discord.username }}#{{ integrations.discord.discriminator }}</a></p>
|
|
|
|
<MkButton v-if="integrations.discord" danger @click="disconnectDiscord">{{ i18n.ts.disconnectService }}</MkButton>
|
|
|
|
<MkButton v-else primary @click="connectDiscord">{{ i18n.ts.connectService }}</MkButton>
|
2022-01-04 02:21:00 -07:00
|
|
|
</FormSection>
|
2020-01-29 12:37:25 -07:00
|
|
|
|
2022-04-30 20:23:12 -06:00
|
|
|
<FormSection v-if="instance.enableGithubIntegration">
|
2022-01-04 02:21:00 -07:00
|
|
|
<template #label><i class="fab fa-github"></i> GitHub</template>
|
2022-04-30 20:23:12 -06:00
|
|
|
<p v-if="integrations.github">{{ i18n.ts.connectedTo }}: <a :href="`https://github.com/${integrations.github.login}`" rel="nofollow noopener" target="_blank">@{{ integrations.github.login }}</a></p>
|
|
|
|
<MkButton v-if="integrations.github" danger @click="disconnectGithub">{{ i18n.ts.disconnectService }}</MkButton>
|
|
|
|
<MkButton v-else primary @click="connectGithub">{{ i18n.ts.connectService }}</MkButton>
|
2022-01-04 02:21:00 -07:00
|
|
|
</FormSection>
|
|
|
|
</div>
|
2020-01-29 12:37:25 -07:00
|
|
|
</template>
|
|
|
|
|
2022-04-30 20:23:12 -06:00
|
|
|
<script lang="ts" setup>
|
2022-06-20 02:38:49 -06:00
|
|
|
import { computed, onMounted, ref, watch } from 'vue';
|
2021-11-11 10:02:25 -07:00
|
|
|
import { apiUrl } from '@/config';
|
2022-01-04 02:21:00 -07:00
|
|
|
import FormSection from '@/components/form/section.vue';
|
2022-09-06 03:21:49 -06:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2022-04-30 20:23:12 -06:00
|
|
|
import { $i } from '@/account';
|
|
|
|
import { instance } from '@/instance';
|
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 02:38:49 -06:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2022-04-30 20:23:12 -06:00
|
|
|
|
|
|
|
const twitterForm = ref<Window | null>(null);
|
|
|
|
const discordForm = ref<Window | null>(null);
|
|
|
|
const githubForm = ref<Window | null>(null);
|
|
|
|
|
|
|
|
const integrations = computed(() => $i!.integrations);
|
|
|
|
|
|
|
|
function openWindow(service: string, type: string) {
|
|
|
|
return window.open(`${apiUrl}/${type}/${service}`,
|
|
|
|
`${service}_${type}_window`,
|
2022-06-20 02:38:49 -06:00
|
|
|
'height=570, width=520',
|
2022-04-30 20:23:12 -06:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function connectTwitter() {
|
|
|
|
twitterForm.value = openWindow('twitter', 'connect');
|
|
|
|
}
|
|
|
|
|
|
|
|
function disconnectTwitter() {
|
|
|
|
openWindow('twitter', 'disconnect');
|
|
|
|
}
|
|
|
|
|
|
|
|
function connectDiscord() {
|
|
|
|
discordForm.value = openWindow('discord', 'connect');
|
|
|
|
}
|
|
|
|
|
|
|
|
function disconnectDiscord() {
|
|
|
|
openWindow('discord', 'disconnect');
|
|
|
|
}
|
|
|
|
|
|
|
|
function connectGithub() {
|
|
|
|
githubForm.value = openWindow('github', 'connect');
|
|
|
|
}
|
|
|
|
|
|
|
|
function disconnectGithub() {
|
|
|
|
openWindow('github', 'disconnect');
|
|
|
|
}
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
document.cookie = `igi=${$i!.token}; path=/;` +
|
2022-06-20 02:38:49 -06:00
|
|
|
' max-age=31536000;' +
|
2022-04-30 20:23:12 -06:00
|
|
|
(document.location.protocol.startsWith('https') ? ' secure' : '');
|
|
|
|
|
|
|
|
watch(integrations, () => {
|
|
|
|
if (integrations.value.twitter) {
|
|
|
|
if (twitterForm.value) twitterForm.value.close();
|
|
|
|
}
|
|
|
|
if (integrations.value.discord) {
|
|
|
|
if (discordForm.value) discordForm.value.close();
|
|
|
|
}
|
|
|
|
if (integrations.value.github) {
|
|
|
|
if (githubForm.value) githubForm.value.close();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2020-01-29 12:37:25 -07:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.integration,
|
2022-11-06 19:30:26 -07:00
|
|
|
icon: 'ph-share-network-bold',
|
2020-01-29 12:37:25 -07:00
|
|
|
});
|
|
|
|
</script>
|