2020-11-27 19:27:44 +01:00
|
|
|
import { IActor } from "@/types/actor";
|
|
|
|
import { ActorType } from "@/types/enums";
|
2021-05-12 18:10:07 +02:00
|
|
|
import { Component, Vue, Ref } from "vue-property-decorator";
|
|
|
|
import VueRouter from "vue-router";
|
|
|
|
const { isNavigationFailure, NavigationFailureType } = VueRouter;
|
2019-12-03 11:29:51 +01:00
|
|
|
|
2021-05-12 18:10:07 +02:00
|
|
|
@Component
|
2019-12-03 11:29:51 +01:00
|
|
|
export default class RelayMixin extends Vue {
|
2020-02-18 08:57:00 +01:00
|
|
|
@Ref("table") readonly table!: any;
|
2019-12-03 11:29:51 +01:00
|
|
|
|
2020-10-13 20:39:59 +02:00
|
|
|
toggle(row: Record<string, unknown>): void {
|
2020-02-18 08:57:00 +01:00
|
|
|
this.table.toggleDetails(row);
|
2019-12-03 11:29:51 +01:00
|
|
|
}
|
|
|
|
|
2021-05-12 18:10:07 +02:00
|
|
|
protected async pushRouter(
|
|
|
|
routeName: string,
|
|
|
|
args: Record<string, string>
|
|
|
|
): Promise<void> {
|
2020-10-27 09:13:17 +01:00
|
|
|
try {
|
2021-05-12 18:10:07 +02:00
|
|
|
await this.$router.push({
|
|
|
|
name: routeName,
|
|
|
|
query: { ...this.$route.query, ...args },
|
2020-10-27 09:13:17 +01:00
|
|
|
});
|
2021-05-12 18:10:07 +02:00
|
|
|
} catch (e) {
|
|
|
|
if (isNavigationFailure(e, NavigationFailureType.redirected)) {
|
|
|
|
throw Error(e.toString());
|
|
|
|
}
|
2020-10-27 09:13:17 +01:00
|
|
|
}
|
2019-12-03 11:29:51 +01:00
|
|
|
}
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
static isInstance(actor: IActor): boolean {
|
|
|
|
return (
|
|
|
|
actor.type === ActorType.APPLICATION &&
|
2020-11-30 10:24:11 +01:00
|
|
|
(actor.preferredUsername === "relay" ||
|
|
|
|
actor.preferredUsername === actor.domain)
|
2020-02-18 08:57:00 +01:00
|
|
|
);
|
2019-12-03 11:29:51 +01:00
|
|
|
}
|
|
|
|
}
|