Skip to content

Commit

Permalink
also add a new_populated_state for populated_state: new
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhamidawan committed Nov 10, 2023
1 parent c9c8c09 commit 55d3b22
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
14 changes: 9 additions & 5 deletions client/src/components/History/Content/ContentItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:id="contentId"
:class="['content-item m-1 p-0 rounded btn-transparent-background', contentCls]"
:data-hid="id"
:data-state="state"
:data-state="dataState"
tabindex="0"
role="button"
@keydown="onKeyDown">
Expand Down Expand Up @@ -173,12 +173,13 @@ export default {
state() {
if (this.isPlaceholder) {
return "placeholder";
} else if (
this.item.history_content_type === "dataset_collection" &&
this.item.populated_state === "failed"
) {
}
if (this.item.populated_state === "failed") {
return "failed_populated_state";
}
if (this.item.populated_state === "new") {
return "new_populated_state";
}
if (this.item.job_state_summary) {
for (const state of HIERARCHICAL_COLLECTION_JOB_STATES) {
if (this.item.job_state_summary[state] > 0) {
Expand All @@ -190,6 +191,9 @@ export default {
}
return "ok";
},
dataState() {
return this.state === "new_populated_state" ? "new" : this.state;
},
tags() {
return this.item.tags;
},
Expand Down
6 changes: 5 additions & 1 deletion client/src/components/History/Content/model/StatesInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ if (props.excludeStates) {
}
}
function dataState(state: string) {
return state === "new_populated_state" ? "new" : state;
}
function onFilter(value: string) {
emit("set-filter", `state`, value);
}
Expand All @@ -37,7 +41,7 @@ function onFilter(value: string) {
</i>
</p>
<dl v-for="(state, key, index) in states" :key="index">
<div :class="['alert', 'content-item', 'alert-' + state.status]" :data-state="key">
<div :class="['alert', 'content-item', 'alert-' + state.status]" :data-state="dataState(key)">
<dt>
<a v-if="!state.nonDb" class="text-decoration-none" href="javascript:void(0)" @click="onFilter(key)"
><code>{{ key }}</code></a
Expand Down
9 changes: 8 additions & 1 deletion client/src/components/History/Content/model/states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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" | "failed_populated_state";
type State = DatasetState | "failed" | "placeholder" | "failed_populated_state" | "new_populated_state";

interface StateRepresentation {
status: "success" | "warning" | "info" | "danger" | "secondary";
Expand Down Expand Up @@ -113,6 +113,13 @@ export const STATES: StateMap = {
icon: "exclamation-triangle",
nonDb: true,
},
/** the `populated_state: new`. This state is only visual and transitional, it does not exist in the database. */
new_populated_state: {
status: "warning",
text: "This is a new collection and not all of its data are available yet.",
icon: "clock",
nonDb: true,
},
} as const satisfies StateMap;

/** We want to display a single state for a dataset collection whose elements may have mixed states.
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", "placeholder", "failed_populated_state"];
const excludeStates = ["empty", "failed", "upload", "placeholder", "failed_populated_state", "new_populated_state"];
const states = Object.keys(STATES).filter((state) => !excludeStates.includes(state));

const validFilters = {
Expand Down

0 comments on commit 55d3b22

Please sign in to comment.