Skip to content

Commit

Permalink
Add history items display state for empty collections/lists
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhamidawan committed Nov 8, 2023
1 parent 7404ed0 commit 05ceeba
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 4 deletions.
8 changes: 7 additions & 1 deletion client/src/components/History/Content/ContentItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@
<FontAwesomeIcon class="text-info" icon="arrow-circle-down" />
</b-button>
<span v-if="hasStateIcon" class="state-icon">
<icon fixed-width :icon="contentState.icon" :spin="contentState.spin" />
<icon
fixed-width
:icon="contentState.icon"
:spin="contentState.spin"
:title="contentState.text" />
</span>
<span class="id hid">{{ id }}:</span>
<span class="content-title name font-weight-bold">{{ name }}</span>
Expand Down Expand Up @@ -169,6 +173,8 @@ export default {
state() {
if (this.isPlaceholder) {
return "placeholder";
} else if (this.item.element_count !== undefined && this.item.element_count === 0) {
return "emptyCollection";
}
if (this.item.job_state_summary) {
for (const state of HIERARCHICAL_COLLECTION_JOB_STATES) {
Expand Down
5 changes: 4 additions & 1 deletion client/src/components/History/Content/model/StatesInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ function onFilter(value: string) {
<dl v-for="(state, key, index) in states" :key="index">
<div :class="['alert', 'content-item', 'alert-' + state.status]" :data-state="key">
<dt>
<a class="text-decoration-none" href="javascript:void(0)" @click="onFilter(key)"
<a v-if="!state.nonDb" class="text-decoration-none" href="javascript:void(0)" @click="onFilter(key)"
><code>{{ key }}</code></a
>
<span v-else
><code>{{ key }}</code></span
>
<icon v-if="state.icon" :icon="state.icon" />
</dt>
<dd>{{ helpText[key] || state.text }}</dd>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type State = {
text?: string;
icon?: string;
spin?: boolean;
nonDb?: boolean;
};

export type States = {
Expand Down
11 changes: 10 additions & 1 deletion client/src/components/History/Content/model/states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import type { components } from "@/api/schema";

type DatasetState = components["schemas"]["DatasetState"];
// The 'failed' state is for the collection job state summary, not a dataset state.
type State = DatasetState | "failed" | "placeholder";
type State = DatasetState | "failed" | "placeholder" | "emptyCollection";

interface StateRepresentation {
status: "success" | "warning" | "info" | "danger" | "secondary";
text?: string;
icon?: string;
spin?: boolean;
nonDb?: boolean;
}

type StateMap = {
Expand Down Expand Up @@ -103,6 +104,14 @@ export const STATES: StateMap = {
text: "This dataset is being fetched.",
icon: "spinner",
spin: true,
nonDb: true,
},
/** the collection is empty. This state is only visual and transitional, it does not exist in the database. */
emptyCollection: {
status: "secondary",
text: "This is an empty list/collection.",
icon: "exclamation-triangle",
nonDb: true,
},
} as const satisfies StateMap;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ watch(
</section>
<section class="position-relative flex-grow-1 scroller">
<div>
<b-alert v-if="collectionElements.length === 0" class="m-2" variant="info" show>
This is an empty list/collection.
</b-alert>
<ListingLayout
v-else
data-key="element_index"
:items="collectionElements"
:loading="loading"
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/History/HistoryFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { STATES } from "components/History/Content/model/states";
import StatesInfo from "components/History/Content/model/StatesInfo";
import Filtering, { compare, contains, equals, expandNameTag, toBool, toDate } from "utils/filtering";

const excludeStates = ["empty", "failed", "upload"];
const excludeStates = ["empty", "failed", "upload", "placeholder", "emptyCollection"];
const states = Object.keys(STATES).filter((state) => !excludeStates.includes(state));

const validFilters = {
Expand Down

0 comments on commit 05ceeba

Please sign in to comment.