Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
srnovus committed Oct 31, 2024
1 parent 3482ca7 commit e9f0ef9
Showing 1 changed file with 32 additions and 7 deletions.
39 changes: 32 additions & 7 deletions packages/client/src/pages/admin/integrations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
class="icon"
/>
</div>
<MkInfo
v-if="thereIsUnresolvedAbuseReport"
warn
Expand Down Expand Up @@ -64,6 +65,7 @@
</div>
</div>
</template>
<script lang="ts" setup>
import {
computed,
Expand Down Expand Up @@ -91,16 +93,21 @@ import {
provideMetadataReceiver,
} from "@/scripts/page-metadata";
import icon from "@/scripts/icon";
const isEmpty = (x: string | null) => x == null || x === "";
const el = ref<HTMLElement | null>(null);
const router = useRouter();
const indexInfo = {
title: i18n.ts.controlPanel,
icon: `${icon("ph-gear-six")}`,
hideHeader: true,
};
provide("shouldOmitHeaderTitle", false);
const instance = getInstanceInfo();
const INFO = ref(indexInfo);
const childInfo = ref(null);
const narrow = ref(false);
Expand All @@ -114,22 +121,26 @@ const noEmailServer = !instance.enableEmail;
const thereIsUnresolvedAbuseReport = ref(false);
const updateAvailable = ref(false);
const currentPage = computed(() => router.currentRef.value?.child);
os.api("admin/abuse-user-reports", {
state: "unresolved",
limit: 1,
}).then((reports) => {
if (reports?.length > 0) thereIsUnresolvedAbuseReport.value = true;
});
if (defaultStore.state.showAdminUpdates) {
os.api("latest-version").then((res) => {
updateAvailable.value = version < res?.latest_version;
});
}
const NARROW_THRESHOLD = 600;
const ro = new ResizeObserver((entries, observer) => {
if (entries.length === 0) return;
narrow.value = entries[0].borderBoxSize[0].inlineSize < NARROW_THRESHOLD;
});
const menuDef = computed(() => [
{
title: i18n.ts.quickAction,
Expand Down Expand Up @@ -246,12 +257,6 @@ const menuDef = computed(() => [
to: "/admin/relays",
active: currentPage.value?.route.name === "relays",
},
{
icon: "ph-plug ph-bold ph-lg",
text: i18n.ts.integration,
to: "/admin/integrations",
active: currentPage?.route.name === "integrations",
},
{
icon: `${icon("ph-prohibit")}`,
text: i18n.ts.instanceBlocking,
Expand Down Expand Up @@ -287,27 +292,34 @@ const menuDef = computed(() => [
]
: []),
]);
watch(narrow.value, () => {
if (currentPage.value?.route.name == null && !narrow.value) {
router.push("/admin/overview");
}
});
onMounted(() => {
ro.observe(el.value);
narrow.value = el.value.offsetWidth < NARROW_THRESHOLD;
if (currentPage.value?.route.name == null && !narrow.value) {
router.push("/admin/overview");
}
});
onActivated(() => {
narrow.value = el.value.offsetWidth < NARROW_THRESHOLD;
if (!narrow.value && currentPage.value?.route.name == null) {
router.replace("/admin/overview");
}
});
onUnmounted(() => {
ro.disconnect();
});
watch(router.currentRef, (to) => {
if (
to?.route.path === "/admin" &&
Expand All @@ -317,13 +329,15 @@ watch(router.currentRef, (to) => {
router.replace("/admin/overview");
}
});
provideMetadataReceiver((info) => {
if (info == null) {
childInfo.value = null;
} else {
childInfo.value = info;
}
});
const invite = () => {
os.api("admin/invite")
.then((x) => {
Expand All @@ -339,11 +353,13 @@ const invite = () => {
});
});
};
async function lookupNote() {
const { canceled, result: q } = await os.inputText({
title: i18n.ts.noteId,
});
if (canceled) return;
os.api(
"notes/show",
q.startsWith("http://") || q.startsWith("https://")
Expand All @@ -362,6 +378,7 @@ async function lookupNote() {
}
});
}
const lookup = (ev) => {
os.popupMenu(
[
Expand Down Expand Up @@ -397,20 +414,24 @@ const lookup = (ev) => {
ev.currentTarget ?? ev.target,
);
};
definePageMetadata(INFO.value);
defineExpose({
header: {
title: i18n.ts.controlPanel,
},
});
</script>
<style lang="scss" scoped>
.hiyeyicy {
&.wide {
display: flex;
margin-block: 0;
margin-inline: auto;
block-size: 100%;
> .nav {
inline-size: 32%;
max-inline-size: 280px;
Expand All @@ -419,19 +440,23 @@ defineExpose({
overflow: auto;
block-size: 100%;
}
> .main {
flex: 1;
min-inline-size: 0;
}
}
> .nav {
.lxpfedzu {
> .info {
margin-block: 16px;
margin-inline: 0;
}
> .banner {
margin: 16px;
> .icon {
display: block;
margin: auto;
Expand All @@ -441,4 +466,4 @@ defineExpose({
}
}
}
</style>
</style>

0 comments on commit e9f0ef9

Please sign in to comment.