Skip to content

Commit

Permalink
add HistoryIndicators component
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhamidawan committed Jul 25, 2024
1 parent f5cc111 commit 9de0ee2
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 56 deletions.
26 changes: 2 additions & 24 deletions client/src/components/History/CurrentHistory/HistoryDetails.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
<script setup lang="ts">
import { library } from "@fortawesome/fontawesome-svg-core";
import { faArchive, faBurn, faTrash } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { BBadge } from "bootstrap-vue";
import type { HistorySummary } from "@/api";
import { useHistoryStore } from "@/stores/historyStore";
import type { DetailsLayoutSummarized } from "../Layout/types";
import HistoryIndicators from "../HistoryIndicators.vue";
import TextSummary from "@/components/Common/TextSummary.vue";
import DetailsLayout from "@/components/History/Layout/DetailsLayout.vue";
import UtcDate from "@/components/UtcDate.vue";
library.add(faArchive, faBurn, faTrash);
interface Props {
history: HistorySummary;
Expand Down Expand Up @@ -56,22 +49,7 @@ function onSave(newDetails: HistorySummary) {
no-expand />
</template>
<template v-if="summarized" v-slot:update-time>
<BBadge v-b-tooltip pill>
<span v-localize>last edited </span>
<UtcDate v-if="history.update_time" :date="history.update_time" mode="elapsed" />
</BBadge>
<BBadge v-if="history.purged" pill class="alert-warning">
<FontAwesomeIcon :icon="faBurn" />
<span v-localize> Purged</span>
</BBadge>
<BBadge v-else-if="history.deleted" pill class="alert-danger">
<FontAwesomeIcon :icon="faTrash" />
<span v-localize> Deleted</span>
</BBadge>
<BBadge v-if="history.archived" pill class="alert-warning">
<FontAwesomeIcon :icon="faArchive" />
<span v-localize> Archived</span>
</BBadge>
<HistoryIndicators :history="history" detailed-time />
</template>
</DetailsLayout>
</template>
45 changes: 45 additions & 0 deletions client/src/components/History/HistoryIndicators.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<script setup lang="ts">
import { library } from "@fortawesome/fontawesome-svg-core";
import { faArchive, faBurn, faTrash } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { BBadge } from "bootstrap-vue";
import { storeToRefs } from "pinia";
import { type HistorySummary, userOwnsHistory } from "@/api";
import { useUserStore } from "@/stores/userStore";
import localize from "@/utils/localization";
import UtcDate from "../UtcDate.vue";
library.add(faArchive, faBurn, faTrash);
const userStore = useUserStore();
const { currentUser } = storeToRefs(userStore);
const props = defineProps<{
history: HistorySummary;
includeCount?: boolean;
detailedTime?: boolean;
}>();
</script>

<template>
<div class="d-flex align-items-center flex-gapx-1">
<BBadge v-if="props.includeCount" pill :title="localize('Amount of items in history')">
{{ history.count }} {{ localize("items") }}
</BBadge>
<BBadge v-if="history.update_time" pill :title="localize('Last edited')">
<span v-if="props.detailedTime" v-localize>last edited </span>
<UtcDate :date="history.update_time" mode="elapsed" />
</BBadge>
<BBadge v-if="props.history.purged" pill class="alert-warning" title="Permanently deleted">
<FontAwesomeIcon :icon="faBurn" fixed-width />
</BBadge>
<BBadge v-else-if="history.deleted" pill class="alert-danger" title="Deleted">
<FontAwesomeIcon :icon="faTrash" fixed-width />
</BBadge>
<BBadge v-if="history.archived && userOwnsHistory(currentUser, props.history)" pill title="Archived">
<FontAwesomeIcon :icon="faArchive" fixed-width />
</BBadge>
</div>
</template>
36 changes: 4 additions & 32 deletions client/src/components/History/HistoryScrollList.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { library } from "@fortawesome/fontawesome-svg-core";
import { faCheckSquare, faListAlt, faSquare } from "@fortawesome/free-regular-svg-icons";
import { faArchive, faArrowDown, faBurn, faColumns, faSignInAlt, faTrash } from "@fortawesome/free-solid-svg-icons";
import { faArrowDown, faColumns, faSignInAlt } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { useInfiniteScroll } from "@vueuse/core";
import { BAlert, BBadge, BButton, BButtonGroup, BListGroup, BListGroupItem, BOverlay } from "bootstrap-vue";
Expand All @@ -19,10 +19,10 @@ import localize from "@/utils/localization";
import { HistoriesFilters } from "./HistoriesFilters";
import TextSummary from "../Common/TextSummary.vue";
import HistoryIndicators from "./HistoryIndicators.vue";
import Heading from "@/components/Common/Heading.vue";
import StatelessTags from "@/components/TagsMultiselect/StatelessTags.vue";
import ScrollToTopButton from "@/components/ToolsList/ScrollToTopButton.vue";
import UtcDate from "@/components/UtcDate.vue";
type AdditionalOptions = "set-current" | "multi" | "center";
type PinnedHistory = { id: string };
Expand Down Expand Up @@ -54,7 +54,7 @@ const emit = defineEmits<{
(e: "update:show-modal", showModal: boolean): void;
}>();
library.add(faColumns, faSignInAlt, faListAlt, faArrowDown, faCheckSquare, faSquare, faBurn, faTrash, faArchive);
library.add(faColumns, faSignInAlt, faListAlt, faArrowDown, faCheckSquare, faSquare);
const busy = ref(false);
const showAdvanced = ref(false);
Expand Down Expand Up @@ -277,35 +277,7 @@ async function loadMore(noScroll = false) {
</i>
</div>
<TextSummary v-else component="h4" :description="history.name" one-line-summary />
<div class="d-flex align-items-center flex-gapx-1">
<BBadge
v-if="history.purged"
pill
class="alert-warning"
title="Permanently deleted">
<FontAwesomeIcon :icon="faBurn" fixed-width />
</BBadge>
<BBadge v-else-if="history.deleted" pill class="alert-danger" title="Deleted">
<FontAwesomeIcon :icon="faTrash" fixed-width />
</BBadge>
<BBadge
v-if="history.archived && userOwnsHistory(currentUser, history)"
pill
class="alert-warning"
title="Archived">
<FontAwesomeIcon :icon="faArchive" fixed-width />
</BBadge>
<BBadge pill :title="localize('Amount of items in history')">
{{ history.count }} {{ localize("items") }}
</BBadge>
<BBadge
v-if="history.update_time"
v-b-tooltip.noninteractive.hover
pill
:title="localize('Last edited')">
<UtcDate :date="history.update_time" mode="elapsed" />
</BBadge>
</div>
<HistoryIndicators :history="history" include-count />
</div>

<p v-if="!isMultiviewPanel && history.annotation" class="my-1">{{ history.annotation }}</p>
Expand Down

0 comments on commit 9de0ee2

Please sign in to comment.