Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nvus #33

Merged
merged 25 commits into from
Oct 31, 2024
Merged

Nvus #33

34 changes: 1 addition & 33 deletions packages/client/src/pages/admin/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
class="icon"
/>
</div>

<MkInfo
v-if="thereIsUnresolvedAbuseReport"
warn
Expand Down Expand Up @@ -65,7 +64,6 @@
</div>
</div>
</template>

<script lang="ts" setup>
import {
computed,
Expand Down Expand Up @@ -93,22 +91,16 @@ import {
provideMetadataReceiver,
} from "@/scripts/page-metadata";
import icon from "@/scripts/icon";
import Integrations from './integrations.vue' // Importa el componente de integración

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 @@ -122,26 +114,22 @@ 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 @@ -268,7 +256,7 @@ const menuDef = computed(() => [
icon: `${icon("ph-thin ph-plug")}`,
text: i18n.ts.integration.title,
to: "/admin/integrations",
active: currentPage.value?.route.name === "integrations",
active: currentPage?.route.name === "integrations",
},
{
icon: `${icon("ph-prohibit")}`,
Expand Down Expand Up @@ -305,34 +293,27 @@ 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 @@ -342,15 +323,13 @@ 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 @@ -366,13 +345,11 @@ 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 @@ -391,7 +368,6 @@ async function lookupNote() {
}
});
}

const lookup = (ev) => {
os.popupMenu(
[
Expand Down Expand Up @@ -427,24 +403,20 @@ 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 @@ -453,23 +425,19 @@ 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 Down
Loading