Merge branch 'develop' into vite
This commit is contained in:
commit
17047d2d2d
3 changed files with 159 additions and 238 deletions
|
@ -37,8 +37,8 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, onMounted, ref } from 'vue';
|
import { defineExpose, ref } from 'vue';
|
||||||
import MkButton from '@/components/ui/button.vue';
|
import MkButton from '@/components/ui/button.vue';
|
||||||
import FormSection from '@/components/form/section.vue';
|
import FormSection from '@/components/form/section.vue';
|
||||||
import FormGroup from '@/components/form/group.vue';
|
import FormGroup from '@/components/form/group.vue';
|
||||||
|
@ -48,108 +48,80 @@ import { selectFile } from '@/scripts/select-file';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
|
|
||||||
export default defineComponent({
|
const excludeMutingUsers = ref(false);
|
||||||
components: {
|
const excludeInactiveUsers = ref(false);
|
||||||
FormSection,
|
|
||||||
FormGroup,
|
|
||||||
FormSwitch,
|
|
||||||
MkButton,
|
|
||||||
},
|
|
||||||
|
|
||||||
emits: ['info'],
|
const onExportSuccess = () => {
|
||||||
|
os.alert({
|
||||||
|
type: 'info',
|
||||||
|
text: i18n.ts.exportRequested,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
setup(props, context) {
|
const onImportSuccess = () => {
|
||||||
const INFO = {
|
os.alert({
|
||||||
title: i18n.ts.importAndExport,
|
type: 'info',
|
||||||
icon: 'fas fa-boxes',
|
text: i18n.ts.importRequested,
|
||||||
bg: 'var(--bg)',
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const excludeMutingUsers = ref(false);
|
const onError = (ev) => {
|
||||||
const excludeInactiveUsers = ref(false);
|
os.alert({
|
||||||
|
type: 'error',
|
||||||
|
text: ev.message,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const onExportSuccess = () => {
|
const exportNotes = () => {
|
||||||
os.alert({
|
os.api('i/export-notes', {}).then(onExportSuccess).catch(onError);
|
||||||
type: 'info',
|
};
|
||||||
text: i18n.ts.exportRequested,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const onImportSuccess = () => {
|
const exportFollowing = () => {
|
||||||
os.alert({
|
os.api('i/export-following', {
|
||||||
type: 'info',
|
excludeMuting: excludeMutingUsers.value,
|
||||||
text: i18n.ts.importRequested,
|
excludeInactive: excludeInactiveUsers.value,
|
||||||
});
|
})
|
||||||
};
|
.then(onExportSuccess).catch(onError);
|
||||||
|
};
|
||||||
|
|
||||||
const onError = (e) => {
|
const exportBlocking = () => {
|
||||||
os.alert({
|
os.api('i/export-blocking', {}).then(onExportSuccess).catch(onError);
|
||||||
type: 'error',
|
};
|
||||||
text: e.message,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const exportNotes = () => {
|
const exportUserLists = () => {
|
||||||
os.api('i/export-notes', {}).then(onExportSuccess).catch(onError);
|
os.api('i/export-user-lists', {}).then(onExportSuccess).catch(onError);
|
||||||
};
|
};
|
||||||
|
|
||||||
const exportFollowing = () => {
|
const exportMuting = () => {
|
||||||
os.api('i/export-following', {
|
os.api('i/export-mute', {}).then(onExportSuccess).catch(onError);
|
||||||
excludeMuting: excludeMutingUsers.value,
|
};
|
||||||
excludeInactive: excludeInactiveUsers.value,
|
|
||||||
})
|
|
||||||
.then(onExportSuccess).catch(onError);
|
|
||||||
};
|
|
||||||
|
|
||||||
const exportBlocking = () => {
|
const importFollowing = async (ev) => {
|
||||||
os.api('i/export-blocking', {}).then(onExportSuccess).catch(onError);
|
const file = await selectFile(ev.currentTarget ?? ev.target);
|
||||||
};
|
os.api('i/import-following', { fileId: file.id }).then(onImportSuccess).catch(onError);
|
||||||
|
};
|
||||||
|
|
||||||
const exportUserLists = () => {
|
const importUserLists = async (ev) => {
|
||||||
os.api('i/export-user-lists', {}).then(onExportSuccess).catch(onError);
|
const file = await selectFile(ev.currentTarget ?? ev.target);
|
||||||
};
|
os.api('i/import-user-lists', { fileId: file.id }).then(onImportSuccess).catch(onError);
|
||||||
|
};
|
||||||
|
|
||||||
const exportMuting = () => {
|
const importMuting = async (ev) => {
|
||||||
os.api('i/export-mute', {}).then(onExportSuccess).catch(onError);
|
const file = await selectFile(ev.currentTarget ?? ev.target);
|
||||||
};
|
os.api('i/import-muting', { fileId: file.id }).then(onImportSuccess).catch(onError);
|
||||||
|
};
|
||||||
|
|
||||||
const importFollowing = async (ev) => {
|
const importBlocking = async (ev) => {
|
||||||
const file = await selectFile(ev.currentTarget ?? ev.target);
|
const file = await selectFile(ev.currentTarget ?? ev.target);
|
||||||
os.api('i/import-following', { fileId: file.id }).then(onImportSuccess).catch(onError);
|
os.api('i/import-blocking', { fileId: file.id }).then(onImportSuccess).catch(onError);
|
||||||
};
|
};
|
||||||
|
|
||||||
const importUserLists = async (ev) => {
|
defineExpose({
|
||||||
const file = await selectFile(ev.currentTarget ?? ev.target);
|
[symbols.PAGE_INFO]: {
|
||||||
os.api('i/import-user-lists', { fileId: file.id }).then(onImportSuccess).catch(onError);
|
title: i18n.ts.importAndExport,
|
||||||
};
|
icon: 'fas fa-boxes',
|
||||||
|
bg: 'var(--bg)',
|
||||||
const importMuting = async (ev) => {
|
}
|
||||||
const file = await selectFile(ev.currentTarget ?? ev.target);
|
|
||||||
os.api('i/import-muting', { fileId: file.id }).then(onImportSuccess).catch(onError);
|
|
||||||
};
|
|
||||||
|
|
||||||
const importBlocking = async (ev) => {
|
|
||||||
const file = await selectFile(ev.currentTarget ?? ev.target);
|
|
||||||
os.api('i/import-blocking', { fileId: file.id }).then(onImportSuccess).catch(onError);
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
[symbols.PAGE_INFO]: INFO,
|
|
||||||
excludeMutingUsers,
|
|
||||||
excludeInactiveUsers,
|
|
||||||
|
|
||||||
exportNotes,
|
|
||||||
exportFollowing,
|
|
||||||
exportBlocking,
|
|
||||||
exportUserLists,
|
|
||||||
exportMuting,
|
|
||||||
|
|
||||||
importFollowing,
|
|
||||||
importUserLists,
|
|
||||||
importMuting,
|
|
||||||
importBlocking,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,67 +1,51 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="_formRoot">
|
<div class="_formRoot">
|
||||||
<MkInfo>{{ $ts._instanceMute.title }}</MkInfo>
|
<MkInfo>{{ i18n.ts._instanceMute.title }}</MkInfo>
|
||||||
<FormTextarea v-model="instanceMutes" class="_formBlock">
|
<FormTextarea v-model="instanceMutes" class="_formBlock">
|
||||||
<template #label>{{ $ts._instanceMute.heading }}</template>
|
<template #label>{{ i18n.ts._instanceMute.heading }}</template>
|
||||||
<template #caption>{{ $ts._instanceMute.instanceMuteDescription }}<br>{{ $ts._instanceMute.instanceMuteDescription2 }}</template>
|
<template #caption>{{ i18n.ts._instanceMute.instanceMuteDescription }}<br>{{ i18n.ts._instanceMute.instanceMuteDescription2 }}</template>
|
||||||
</FormTextarea>
|
</FormTextarea>
|
||||||
<MkButton primary :disabled="!changed" class="_formBlock" @click="save()"><i class="fas fa-save"></i> {{ $ts.save }}</MkButton>
|
<MkButton primary :disabled="!changed" class="_formBlock" @click="save()"><i class="fas fa-save"></i> {{ i18n.ts.save }}</MkButton>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts" setup>
|
||||||
import { defineComponent } from 'vue';
|
import { defineExpose, ref, watch } from 'vue';
|
||||||
import FormTextarea from '@/components/form/textarea.vue';
|
import FormTextarea from '@/components/form/textarea.vue';
|
||||||
import MkInfo from '@/components/ui/info.vue';
|
import MkInfo from '@/components/ui/info.vue';
|
||||||
import MkButton from '@/components/ui/button.vue';
|
import MkButton from '@/components/ui/button.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
|
import { $i } from '@/account';
|
||||||
|
import { i18n } from '@/i18n';
|
||||||
|
|
||||||
export default defineComponent({
|
const instanceMutes = ref($i!.mutedInstances.join('\n'));
|
||||||
components: {
|
const changed = ref(false);
|
||||||
MkButton,
|
|
||||||
FormTextarea,
|
|
||||||
MkInfo,
|
|
||||||
},
|
|
||||||
|
|
||||||
emits: ['info'],
|
async function save() {
|
||||||
|
let mutes = instanceMutes.value
|
||||||
|
.trim().split('\n')
|
||||||
|
.map(el => el.trim())
|
||||||
|
.filter(el => el);
|
||||||
|
|
||||||
data() {
|
await os.api('i/update', {
|
||||||
return {
|
mutedInstances: mutes,
|
||||||
[symbols.PAGE_INFO]: {
|
});
|
||||||
title: this.$ts.instanceMute,
|
|
||||||
icon: 'fas fa-volume-mute'
|
|
||||||
},
|
|
||||||
tab: 'soft',
|
|
||||||
instanceMutes: '',
|
|
||||||
changed: false,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
watch: {
|
changed.value = false;
|
||||||
instanceMutes: {
|
|
||||||
handler() {
|
|
||||||
this.changed = true;
|
|
||||||
},
|
|
||||||
deep: true
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
async created() {
|
// Refresh filtered list to signal to the user how they've been saved
|
||||||
this.instanceMutes = this.$i.mutedInstances.join('\n');
|
instanceMutes.value = mutes.join('\n');
|
||||||
},
|
}
|
||||||
|
|
||||||
methods: {
|
watch(instanceMutes, () => {
|
||||||
async save() {
|
changed.value = true;
|
||||||
let mutes = this.instanceMutes.trim().split('\n').map(el => el.trim()).filter(el => el);
|
});
|
||||||
await os.api('i/update', {
|
|
||||||
mutedInstances: mutes,
|
|
||||||
});
|
|
||||||
this.changed = false;
|
|
||||||
|
|
||||||
// Refresh filtered list to signal to the user how they've been saved
|
defineExpose({
|
||||||
this.instanceMutes = mutes.join('\n');
|
[symbols.PAGE_INFO]: {
|
||||||
},
|
title: i18n.ts.instanceMute,
|
||||||
|
icon: 'fas fa-volume-mute'
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,133 +1,98 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="_formRoot">
|
<div class="_formRoot">
|
||||||
<FormSection v-if="enableTwitterIntegration">
|
<FormSection v-if="instance.enableTwitterIntegration">
|
||||||
<template #label><i class="fab fa-twitter"></i> Twitter</template>
|
<template #label><i class="fab fa-twitter"></i> Twitter</template>
|
||||||
<p v-if="integrations.twitter">{{ $ts.connectedTo }}: <a :href="`https://twitter.com/${integrations.twitter.screenName}`" rel="nofollow noopener" target="_blank">@{{ integrations.twitter.screenName }}</a></p>
|
<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">{{ $ts.disconnectService }}</MkButton>
|
<MkButton v-if="integrations.twitter" danger @click="disconnectTwitter">{{ i18n.ts.disconnectService }}</MkButton>
|
||||||
<MkButton v-else primary @click="connectTwitter">{{ $ts.connectService }}</MkButton>
|
<MkButton v-else primary @click="connectTwitter">{{ i18n.ts.connectService }}</MkButton>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
|
|
||||||
<FormSection v-if="enableDiscordIntegration">
|
<FormSection v-if="instance.enableDiscordIntegration">
|
||||||
<template #label><i class="fab fa-discord"></i> Discord</template>
|
<template #label><i class="fab fa-discord"></i> Discord</template>
|
||||||
<p v-if="integrations.discord">{{ $ts.connectedTo }}: <a :href="`https://discord.com/users/${integrations.discord.id}`" rel="nofollow noopener" target="_blank">@{{ integrations.discord.username }}#{{ integrations.discord.discriminator }}</a></p>
|
<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">{{ $ts.disconnectService }}</MkButton>
|
<MkButton v-if="integrations.discord" danger @click="disconnectDiscord">{{ i18n.ts.disconnectService }}</MkButton>
|
||||||
<MkButton v-else primary @click="connectDiscord">{{ $ts.connectService }}</MkButton>
|
<MkButton v-else primary @click="connectDiscord">{{ i18n.ts.connectService }}</MkButton>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
|
|
||||||
<FormSection v-if="enableGithubIntegration">
|
<FormSection v-if="instance.enableGithubIntegration">
|
||||||
<template #label><i class="fab fa-github"></i> GitHub</template>
|
<template #label><i class="fab fa-github"></i> GitHub</template>
|
||||||
<p v-if="integrations.github">{{ $ts.connectedTo }}: <a :href="`https://github.com/${integrations.github.login}`" rel="nofollow noopener" target="_blank">@{{ integrations.github.login }}</a></p>
|
<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">{{ $ts.disconnectService }}</MkButton>
|
<MkButton v-if="integrations.github" danger @click="disconnectGithub">{{ i18n.ts.disconnectService }}</MkButton>
|
||||||
<MkButton v-else primary @click="connectGithub">{{ $ts.connectService }}</MkButton>
|
<MkButton v-else primary @click="connectGithub">{{ i18n.ts.connectService }}</MkButton>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent } from 'vue';
|
import { computed, defineExpose, onMounted, ref, watch } from 'vue';
|
||||||
import { apiUrl } from '@/config';
|
import { apiUrl } from '@/config';
|
||||||
import FormSection from '@/components/form/section.vue';
|
import FormSection from '@/components/form/section.vue';
|
||||||
import MkButton from '@/components/ui/button.vue';
|
import MkButton from '@/components/ui/button.vue';
|
||||||
import * as os from '@/os';
|
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
|
import { $i } from '@/account';
|
||||||
|
import { instance } from '@/instance';
|
||||||
|
import { i18n } from '@/i18n';
|
||||||
|
|
||||||
export default defineComponent({
|
const twitterForm = ref<Window | null>(null);
|
||||||
components: {
|
const discordForm = ref<Window | null>(null);
|
||||||
FormSection,
|
const githubForm = ref<Window | null>(null);
|
||||||
MkButton
|
|
||||||
},
|
|
||||||
|
|
||||||
emits: ['info'],
|
const integrations = computed(() => $i!.integrations);
|
||||||
|
|
||||||
data() {
|
function openWindow(service: string, type: string) {
|
||||||
return {
|
return window.open(`${apiUrl}/${type}/${service}`,
|
||||||
[symbols.PAGE_INFO]: {
|
`${service}_${type}_window`,
|
||||||
title: this.$ts.integration,
|
'height=570, width=520'
|
||||||
icon: 'fas fa-share-alt',
|
);
|
||||||
bg: 'var(--bg)',
|
}
|
||||||
},
|
|
||||||
apiUrl,
|
|
||||||
twitterForm: null,
|
|
||||||
discordForm: null,
|
|
||||||
githubForm: null,
|
|
||||||
enableTwitterIntegration: false,
|
|
||||||
enableDiscordIntegration: false,
|
|
||||||
enableGithubIntegration: false,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
function connectTwitter() {
|
||||||
integrations() {
|
twitterForm.value = openWindow('twitter', 'connect');
|
||||||
return this.$i.integrations;
|
}
|
||||||
},
|
|
||||||
|
|
||||||
meta() {
|
|
||||||
return this.$instance;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
created() {
|
function disconnectTwitter() {
|
||||||
this.enableTwitterIntegration = this.meta.enableTwitterIntegration;
|
openWindow('twitter', 'disconnect');
|
||||||
this.enableDiscordIntegration = this.meta.enableDiscordIntegration;
|
}
|
||||||
this.enableGithubIntegration = this.meta.enableGithubIntegration;
|
|
||||||
},
|
|
||||||
|
|
||||||
mounted() {
|
function connectDiscord() {
|
||||||
document.cookie = `igi=${this.$i.token}; path=/;` +
|
discordForm.value = openWindow('discord', 'connect');
|
||||||
` max-age=31536000;` +
|
}
|
||||||
(document.location.protocol.startsWith('https') ? ' secure' : '');
|
|
||||||
|
|
||||||
this.$watch('integrations', () => {
|
function disconnectDiscord() {
|
||||||
if (this.integrations.twitter) {
|
openWindow('discord', 'disconnect');
|
||||||
if (this.twitterForm) this.twitterForm.close();
|
}
|
||||||
}
|
|
||||||
if (this.integrations.discord) {
|
|
||||||
if (this.discordForm) this.discordForm.close();
|
|
||||||
}
|
|
||||||
if (this.integrations.github) {
|
|
||||||
if (this.githubForm) this.githubForm.close();
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
deep: true
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
function connectGithub() {
|
||||||
connectTwitter() {
|
githubForm.value = openWindow('github', 'connect');
|
||||||
this.twitterForm = window.open(apiUrl + '/connect/twitter',
|
}
|
||||||
'twitter_connect_window',
|
|
||||||
'height=570, width=520');
|
|
||||||
},
|
|
||||||
|
|
||||||
disconnectTwitter() {
|
function disconnectGithub() {
|
||||||
window.open(apiUrl + '/disconnect/twitter',
|
openWindow('github', 'disconnect');
|
||||||
'twitter_disconnect_window',
|
}
|
||||||
'height=570, width=520');
|
|
||||||
},
|
|
||||||
|
|
||||||
connectDiscord() {
|
onMounted(() => {
|
||||||
this.discordForm = window.open(apiUrl + '/connect/discord',
|
document.cookie = `igi=${$i!.token}; path=/;` +
|
||||||
'discord_connect_window',
|
` max-age=31536000;` +
|
||||||
'height=570, width=520');
|
(document.location.protocol.startsWith('https') ? ' secure' : '');
|
||||||
},
|
|
||||||
|
|
||||||
disconnectDiscord() {
|
watch(integrations, () => {
|
||||||
window.open(apiUrl + '/disconnect/discord',
|
if (integrations.value.twitter) {
|
||||||
'discord_disconnect_window',
|
if (twitterForm.value) twitterForm.value.close();
|
||||||
'height=570, width=520');
|
}
|
||||||
},
|
if (integrations.value.discord) {
|
||||||
|
if (discordForm.value) discordForm.value.close();
|
||||||
|
}
|
||||||
|
if (integrations.value.github) {
|
||||||
|
if (githubForm.value) githubForm.value.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
connectGithub() {
|
defineExpose({
|
||||||
this.githubForm = window.open(apiUrl + '/connect/github',
|
[symbols.PAGE_INFO]: {
|
||||||
'github_connect_window',
|
title: i18n.ts.integration,
|
||||||
'height=570, width=520');
|
icon: 'fas fa-share-alt',
|
||||||
},
|
bg: 'var(--bg)',
|
||||||
|
|
||||||
disconnectGithub() {
|
|
||||||
window.open(apiUrl + '/disconnect/github',
|
|
||||||
'github_disconnect_window',
|
|
||||||
'height=570, width=520');
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue