2019-12-20 13:04:34 +01:00
|
|
|
<template>
|
2020-02-18 08:57:00 +01:00
|
|
|
<div class="container section">
|
2020-11-06 11:34:32 +01:00
|
|
|
<b-notification v-if="$apollo.queries.interact.loading">
|
|
|
|
{{ $t("Redirecting to content…") }}
|
2020-02-18 08:57:00 +01:00
|
|
|
</b-notification>
|
2020-11-06 11:34:32 +01:00
|
|
|
<b-notification v-if="$apollo.queries.interact.skip" type="is-danger">
|
2020-02-18 08:57:00 +01:00
|
|
|
{{ $t("Resource provided is not an URL") }}
|
|
|
|
</b-notification>
|
2021-01-15 16:55:58 +01:00
|
|
|
<b-message
|
|
|
|
:title="$t('Error')"
|
|
|
|
type="is-danger"
|
|
|
|
has-icon
|
|
|
|
:closable="false"
|
|
|
|
v-if="!$apollo.loading && errors.length > 0"
|
|
|
|
>
|
|
|
|
<p v-for="error in errors" :key="error">
|
|
|
|
<b>{{ error }}</b>
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
{{
|
|
|
|
$t(
|
|
|
|
"It is possible that the content is not accessible on this instance, because this instance has blocked the profiles or groups behind this content."
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
</p>
|
|
|
|
</b-message>
|
2020-02-18 08:57:00 +01:00
|
|
|
</div>
|
2019-12-20 13:04:34 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-02-18 08:57:00 +01:00
|
|
|
import { Component, Vue } from "vue-property-decorator";
|
2020-11-06 11:34:32 +01:00
|
|
|
import { INTERACT } from "@/graphql/search";
|
2020-02-18 08:57:00 +01:00
|
|
|
import { IEvent } from "@/types/event.model";
|
2020-11-06 11:34:32 +01:00
|
|
|
import { IGroup, usernameWithDomain } from "@/types/actor";
|
2020-02-18 08:57:00 +01:00
|
|
|
import RouteName from "../router/name";
|
2019-12-20 13:04:34 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
apollo: {
|
2020-11-06 11:34:32 +01:00
|
|
|
interact: {
|
|
|
|
query: INTERACT,
|
2019-12-20 13:04:34 +01:00
|
|
|
variables() {
|
|
|
|
return {
|
2020-11-06 11:34:32 +01:00
|
|
|
uri: this.$route.query.uri,
|
2019-12-20 13:04:34 +01:00
|
|
|
};
|
|
|
|
},
|
|
|
|
skip() {
|
|
|
|
try {
|
2020-11-06 11:34:32 +01:00
|
|
|
const url = this.$route.query.uri as string;
|
2020-10-24 17:32:27 +02:00
|
|
|
const uri = new URL(url);
|
|
|
|
return !(uri instanceof URL);
|
2019-12-20 13:04:34 +01:00
|
|
|
} catch (e) {
|
2020-10-24 17:32:27 +02:00
|
|
|
return true;
|
2019-12-20 13:04:34 +01:00
|
|
|
}
|
|
|
|
},
|
2021-01-15 16:55:58 +01:00
|
|
|
error({ graphQLErrors, networkError }) {
|
|
|
|
if (networkError) {
|
|
|
|
this.errors = [networkError.message];
|
|
|
|
}
|
|
|
|
this.errors = graphQLErrors.map((error) => error.message);
|
|
|
|
},
|
2020-11-06 11:34:32 +01:00
|
|
|
async result({ data: { interact } }) {
|
|
|
|
switch (interact.__typename) {
|
|
|
|
case "Group":
|
|
|
|
await this.$router.replace({
|
|
|
|
name: RouteName.GROUP,
|
|
|
|
params: { preferredUsername: usernameWithDomain(interact) },
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case "Event":
|
|
|
|
await this.$router.replace({
|
|
|
|
name: RouteName.EVENT,
|
|
|
|
params: { uuid: interact.uuid },
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
default:
|
2021-01-15 16:55:58 +01:00
|
|
|
this.error = [this.$t("This URL is not supported")];
|
2019-12-20 13:04:34 +01:00
|
|
|
}
|
2020-11-06 11:34:32 +01:00
|
|
|
// await this.$router.replace({
|
|
|
|
// name: RouteName.EVENT,
|
|
|
|
// params: { uuid: event.uuid },
|
|
|
|
// });
|
2019-12-20 13:04:34 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
export default class Interact extends Vue {
|
2020-11-06 11:34:32 +01:00
|
|
|
interact!: IEvent | IGroup;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2021-01-15 16:55:58 +01:00
|
|
|
errors: string[] = [];
|
2019-12-20 13:04:34 +01:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<style lang="scss">
|
2020-02-18 08:57:00 +01:00
|
|
|
main > .container {
|
|
|
|
background: $white;
|
|
|
|
}
|
|
|
|
</style>
|