2021-02-24 19:06:48 +01:00
|
|
|
<template>
|
|
|
|
<div class="activity-item">
|
2022-08-26 16:08:58 +02:00
|
|
|
<o-icon :icon="'calendar'" :variant="iconColor" custom-size="24" />
|
|
|
|
<div class="mt-1 ml-2 prose dark:prose-invert prose-p:m-0">
|
2022-07-12 10:55:28 +02:00
|
|
|
<i18n-t :keypath="translation" tag="p">
|
|
|
|
<template #event>
|
|
|
|
<router-link
|
|
|
|
v-if="activity.object"
|
|
|
|
:to="{
|
|
|
|
name: RouteName.EVENT,
|
|
|
|
params: { uuid: subjectParams.event_uuid },
|
|
|
|
}"
|
|
|
|
>{{ subjectParams.event_title }}</router-link
|
|
|
|
>
|
|
|
|
<b v-else>{{ subjectParams.event_title }}</b>
|
|
|
|
</template>
|
|
|
|
<template #profile>
|
|
|
|
<popover-actor-card :actor="activity.author" :inline="true">
|
|
|
|
<b>
|
|
|
|
{{
|
|
|
|
$t("{'@'}{username}", {
|
|
|
|
username: usernameWithDomain(activity.author),
|
|
|
|
})
|
|
|
|
}}</b
|
|
|
|
></popover-actor-card
|
|
|
|
></template
|
|
|
|
></i18n-t
|
2021-02-24 19:06:48 +01:00
|
|
|
>
|
2022-07-12 10:55:28 +02:00
|
|
|
<small class="activity-date">{{
|
|
|
|
formatTimeString(activity.insertedAt)
|
2021-02-24 19:06:48 +01:00
|
|
|
}}</small>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-07-12 10:55:28 +02:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import {
|
|
|
|
useActivitySubjectParams,
|
|
|
|
useIsActivityAuthorCurrentActor,
|
|
|
|
} from "@/composition/activity";
|
|
|
|
import { IActivity } from "@/types/activity.model";
|
2021-02-24 19:06:48 +01:00
|
|
|
import { usernameWithDomain } from "@/types/actor";
|
2022-07-12 10:55:28 +02:00
|
|
|
import { formatTimeString } from "@/filters/datetime";
|
2021-03-10 17:38:13 +01:00
|
|
|
import {
|
|
|
|
ActivityEventCommentSubject,
|
|
|
|
ActivityEventSubject,
|
|
|
|
} from "@/types/enums";
|
2022-07-12 10:55:28 +02:00
|
|
|
import { computed } from "vue";
|
2021-02-24 19:06:48 +01:00
|
|
|
import RouteName from "../../router/name";
|
|
|
|
import PopoverActorCard from "../Account/PopoverActorCard.vue";
|
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const props = defineProps<{
|
|
|
|
activity: IActivity;
|
|
|
|
}>();
|
2021-02-24 19:06:48 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const isAuthorCurrentActor = useIsActivityAuthorCurrentActor()(props.activity);
|
|
|
|
|
|
|
|
const subjectParams = useActivitySubjectParams()(props.activity);
|
|
|
|
|
|
|
|
const translation = computed((): string | undefined => {
|
|
|
|
switch (props.activity.subject) {
|
|
|
|
case ActivityEventSubject.EVENT_CREATED:
|
|
|
|
if (isAuthorCurrentActor) {
|
|
|
|
return "You created the event {event}.";
|
|
|
|
}
|
|
|
|
return "The event {event} was created by {profile}.";
|
|
|
|
case ActivityEventSubject.EVENT_UPDATED:
|
|
|
|
if (isAuthorCurrentActor) {
|
|
|
|
return "You updated the event {event}.";
|
|
|
|
}
|
|
|
|
return "The event {event} was updated by {profile}.";
|
|
|
|
case ActivityEventSubject.EVENT_DELETED:
|
|
|
|
if (isAuthorCurrentActor) {
|
|
|
|
return "You deleted the event {event}.";
|
|
|
|
}
|
|
|
|
return "The event {event} was deleted by {profile}.";
|
|
|
|
case ActivityEventCommentSubject.COMMENT_POSTED:
|
|
|
|
if (subjectParams.comment_reply_to) {
|
|
|
|
if (isAuthorCurrentActor) {
|
|
|
|
return "You replied to a comment on the event {event}.";
|
2021-03-10 17:38:13 +01:00
|
|
|
}
|
2022-07-12 10:55:28 +02:00
|
|
|
return "{profile} replied to a comment on the event {event}.";
|
|
|
|
}
|
|
|
|
if (isAuthorCurrentActor) {
|
|
|
|
return "You posted a comment on the event {event}.";
|
|
|
|
}
|
|
|
|
return "{profile} posted a comment on the event {event}.";
|
|
|
|
default:
|
|
|
|
return undefined;
|
2021-02-24 19:06:48 +01:00
|
|
|
}
|
2022-07-12 10:55:28 +02:00
|
|
|
});
|
2021-02-24 19:06:48 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const iconColor = computed((): string | undefined => {
|
|
|
|
switch (props.activity.subject) {
|
|
|
|
case ActivityEventSubject.EVENT_CREATED:
|
|
|
|
case ActivityEventCommentSubject.COMMENT_POSTED:
|
2022-08-26 16:08:58 +02:00
|
|
|
return "success";
|
2022-07-12 10:55:28 +02:00
|
|
|
case ActivityEventSubject.EVENT_UPDATED:
|
2022-08-26 16:08:58 +02:00
|
|
|
return "grey";
|
2022-07-12 10:55:28 +02:00
|
|
|
case ActivityEventSubject.EVENT_DELETED:
|
2022-08-26 16:08:58 +02:00
|
|
|
return "danger";
|
2022-07-12 10:55:28 +02:00
|
|
|
default:
|
|
|
|
return undefined;
|
2021-02-24 19:06:48 +01:00
|
|
|
}
|
2022-07-12 10:55:28 +02:00
|
|
|
});
|
2021-02-24 19:06:48 +01:00
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import "./activity.scss";
|
|
|
|
</style>
|