2021-02-24 19:06:48 +01:00
|
|
|
<template>
|
|
|
|
<div class="activity-item">
|
2022-07-12 10:55:28 +02:00
|
|
|
<o-icon :icon="'chat'" :type="iconColor" />
|
2021-02-24 19:06:48 +01:00
|
|
|
<div class="subject">
|
2022-07-12 10:55:28 +02:00
|
|
|
<i18n-t :keypath="translation" tag="p">
|
|
|
|
<template #discussion>
|
|
|
|
<router-link
|
|
|
|
v-if="activity.object"
|
|
|
|
:to="{
|
|
|
|
name: RouteName.DISCUSSION,
|
|
|
|
params: { slug: subjectParams.discussion_slug },
|
|
|
|
}"
|
|
|
|
>{{ subjectParams.discussion_title }}</router-link
|
|
|
|
>
|
|
|
|
<b v-else>{{ subjectParams.discussion_title }}</b>
|
|
|
|
</template>
|
|
|
|
<template #old_discussion>
|
|
|
|
<router-link
|
|
|
|
v-if="activity.object && subjectParams.old_discussion_title"
|
|
|
|
:to="{
|
|
|
|
name: RouteName.DISCUSSION,
|
|
|
|
params: { slug: subjectParams.discussion_slug },
|
|
|
|
}"
|
|
|
|
>{{ subjectParams.old_discussion_title }}</router-link
|
|
|
|
>
|
|
|
|
<b v-else-if="subjectParams.old_discussion_title">{{
|
|
|
|
subjectParams.old_discussion_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
|
|
|
>
|
2021-06-15 17:25:33 +02:00
|
|
|
<small class="has-text-grey-dark activity-date">{{
|
2022-07-12 10:55:28 +02:00
|
|
|
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>
|
2021-02-24 19:06:48 +01:00
|
|
|
import { usernameWithDomain } from "@/types/actor";
|
|
|
|
import { ActivityDiscussionSubject } from "@/types/enums";
|
|
|
|
import RouteName from "../../router/name";
|
|
|
|
import PopoverActorCard from "../Account/PopoverActorCard.vue";
|
2022-07-12 10:55:28 +02:00
|
|
|
import { IActivity } from "@/types/activity.model";
|
|
|
|
import { computed } from "vue";
|
|
|
|
import { formatTimeString } from "@/filters/datetime";
|
|
|
|
import {
|
|
|
|
useActivitySubjectParams,
|
|
|
|
useIsActivityAuthorCurrentActor,
|
|
|
|
} from "@/composition/activity";
|
2021-02-24 19:06:48 +01:00
|
|
|
|
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 ActivityDiscussionSubject.DISCUSSION_CREATED:
|
|
|
|
if (isAuthorCurrentActor) {
|
|
|
|
return "You created the discussion {discussion}.";
|
|
|
|
}
|
|
|
|
return "{profile} created the discussion {discussion}.";
|
|
|
|
case ActivityDiscussionSubject.DISCUSSION_REPLIED:
|
|
|
|
if (isAuthorCurrentActor) {
|
|
|
|
return "You replied to the discussion {discussion}.";
|
|
|
|
}
|
|
|
|
return "{profile} replied to the discussion {discussion}.";
|
|
|
|
case ActivityDiscussionSubject.DISCUSSION_RENAMED:
|
|
|
|
if (isAuthorCurrentActor) {
|
|
|
|
return "You renamed the discussion from {old_discussion} to {discussion}.";
|
|
|
|
}
|
|
|
|
return "{profile} renamed the discussion from {old_discussion} to {discussion}.";
|
|
|
|
case ActivityDiscussionSubject.DISCUSSION_ARCHIVED:
|
|
|
|
if (isAuthorCurrentActor) {
|
|
|
|
return "You archived the discussion {discussion}.";
|
|
|
|
}
|
|
|
|
return "{profile} archived the discussion {discussion}.";
|
|
|
|
case ActivityDiscussionSubject.DISCUSSION_DELETED:
|
|
|
|
if (isAuthorCurrentActor) {
|
|
|
|
return "You deleted the discussion {discussion}.";
|
|
|
|
}
|
|
|
|
return "{profile} deleted the discussion {discussion}.";
|
|
|
|
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 ActivityDiscussionSubject.DISCUSSION_CREATED:
|
|
|
|
case ActivityDiscussionSubject.DISCUSSION_REPLIED:
|
|
|
|
return "is-success";
|
|
|
|
case ActivityDiscussionSubject.DISCUSSION_RENAMED:
|
|
|
|
case ActivityDiscussionSubject.DISCUSSION_ARCHIVED:
|
|
|
|
return "is-grey";
|
|
|
|
case ActivityDiscussionSubject.DISCUSSION_DELETED:
|
|
|
|
return "is-danger";
|
|
|
|
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>
|