Handle stopping state in UI (#269)

closes #262
This commit is contained in:
sua yoo 2022-06-23 16:35:03 -07:00 committed by GitHub
parent c6d9e7d612
commit c2be1a27ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 7 deletions

View File

@ -63,7 +63,11 @@ export class CrawlDetail extends LiteElement {
private get isActive(): boolean | null { private get isActive(): boolean | null {
if (!this.crawl) return null; if (!this.crawl) return null;
return this.crawl.state === "running" || this.crawl.state === "starting"; return (
this.crawl.state === "running" ||
this.crawl.state === "starting" ||
this.crawl.state === "stopping"
);
} }
private get hasFiles(): boolean | null { private get hasFiles(): boolean | null {

View File

@ -30,8 +30,12 @@ const sortableFieldLabels = {
fileSize_desc: msg("Largest Files"), fileSize_desc: msg("Largest Files"),
}; };
function isRunning(crawl: Crawl) { function isActive(crawl: Crawl) {
return crawl.state === "running" || crawl.state === "starting"; return (
crawl.state === "running" ||
crawl.state === "starting" ||
crawl.state === "stopping"
);
} }
/** /**
@ -279,7 +283,7 @@ export class CrawlsList extends LiteElement {
></sl-icon-button> ></sl-icon-button>
<ul class="text-sm text-0-800 whitespace-nowrap" role="menu"> <ul class="text-sm text-0-800 whitespace-nowrap" role="menu">
${isRunning(crawl) ${isActive(crawl)
? html` ? html`
<li <li
class="p-2 hover:bg-zinc-100 cursor-pointer" class="p-2 hover:bg-zinc-100 cursor-pointer"
@ -376,7 +380,7 @@ export class CrawlsList extends LiteElement {
? "text-red-500" ? "text-red-500"
: crawl.state === "complete" : crawl.state === "complete"
? "text-emerald-500" ? "text-emerald-500"
: isRunning(crawl) : isActive(crawl)
? "text-purple-500" ? "text-purple-500"
: "text-zinc-300"}" : "text-zinc-300"}"
style="font-size: 10px; vertical-align: 2px" style="font-size: 10px; vertical-align: 2px"
@ -386,7 +390,7 @@ export class CrawlsList extends LiteElement {
</div> </div>
<div> <div>
<div <div
class="whitespace-nowrap mb-1 capitalize${isRunning(crawl) class="whitespace-nowrap mb-1 capitalize${isActive(crawl)
? " motion-safe:animate-pulse" ? " motion-safe:animate-pulse"
: ""}" : ""}"
> >

View File

@ -4,7 +4,8 @@ type CrawlState =
| "complete" | "complete"
| "failed" | "failed"
| "partial_complete" | "partial_complete"
| "timed_out"; | "timed_out"
| "stopping";
export type Crawl = { export type Crawl = {
id: string; id: string;