-
-
Notifications
You must be signed in to change notification settings - Fork 55
feat: Filter workflows by tag + update existing filter UI #2702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
12827c7
convert existing filters
SuaYoo 70ff546
clear filters
SuaYoo 8b74805
wip
SuaYoo c07bf3b
move to component
SuaYoo 4a0f2b3
add tag filter
SuaYoo fee0427
show tags in detail
SuaYoo b1f108c
handle no tags
SuaYoo d8b729f
create custom component
SuaYoo 4c7e6cd
add search and update value
SuaYoo c80f17d
refactor to common component
SuaYoo cad6666
fix array fromat
SuaYoo 32e2ed7
handle hide on select
SuaYoo a1da89a
style updates from emma
SuaYoo bd0ec66
update button active styles
SuaYoo e4682f4
localization + fix suggestions from emma
SuaYoo 8d64c9d
get localized list working
SuaYoo 88090a8
move to ui components and add to storybook
SuaYoo 586fdec
update imports
SuaYoo 2835487
fix checkbox clearing
SuaYoo 8a99840
fix focus trapping
SuaYoo 644c276
switch back to menu
SuaYoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { localized } from "@lit/localize"; | ||
import type { SlDropdown } from "@shoelace-style/shoelace"; | ||
import { html } from "lit"; | ||
import { customElement, property, query } from "lit/decorators.js"; | ||
import { ifDefined } from "lit/directives/if-defined.js"; | ||
|
||
import { TailwindElement } from "@/classes/TailwindElement"; | ||
|
||
/** | ||
* @slot | ||
* @slot dropdown-header | ||
* @slot dropdown-content | ||
*/ | ||
@customElement("btrix-workflow-filter") | ||
@localized() | ||
export class WorkflowFilter extends TailwindElement { | ||
@property({ type: Boolean }) | ||
checked?: boolean; | ||
|
||
@property({ type: Boolean }) | ||
select?: boolean; | ||
|
||
@property({ type: Boolean }) | ||
stayOpenOnChange?: boolean; | ||
|
||
@query("sl-dropdown") | ||
private readonly dropdown?: SlDropdown | null; | ||
|
||
render() { | ||
if (this.select) { | ||
return html` | ||
<sl-dropdown | ||
distance="4" | ||
hoist | ||
?stayOpenOnSelect=${this.stayOpenOnChange} | ||
SuaYoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@sl-change=${() => { | ||
if (!this.stayOpenOnChange) { | ||
void this.dropdown?.hide(); | ||
} | ||
}} | ||
> | ||
${this.renderButton()} | ||
|
||
<div | ||
class="flex max-h-[var(--auto-size-available-height)] max-w-[var(--auto-size-available-width)] flex-col overflow-hidden rounded border bg-white" | ||
> | ||
<header | ||
class="flex-shrink-0 flex-grow-0 overflow-hidden rounded-t bg-white" | ||
> | ||
<slot name="dropdown-header"></slot> | ||
</header> | ||
<slot name="dropdown-content"></slot> | ||
</div> | ||
</sl-dropdown> | ||
`; | ||
} | ||
|
||
return this.renderButton(); | ||
} | ||
|
||
private renderButton() { | ||
return html` | ||
<sl-button | ||
slot=${ifDefined(this.select ? "trigger" : undefined)} | ||
role="checkbox" | ||
aria-checked=${this.checked ? "true" : "false"} | ||
size="small" | ||
?caret=${this.select} | ||
outline | ||
pill | ||
SuaYoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
> | ||
<sl-icon | ||
class="size-4 text-base" | ||
slot="prefix" | ||
name=${this.checked ? "check2-circle" : "plus-circle-dotted"} | ||
></sl-icon> | ||
<slot></slot> | ||
</sl-button> | ||
`; | ||
} | ||
} |
126 changes: 126 additions & 0 deletions
126
frontend/src/features/crawl-workflows/workflow-schedule-filter.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import { localized, msg } from "@lit/localize"; | ||
import type { SlChangeEvent, SlRadioGroup } from "@shoelace-style/shoelace"; | ||
import { html, nothing, type PropertyValues } from "lit"; | ||
import { customElement, property } from "lit/decorators.js"; | ||
|
||
import { BtrixElement } from "@/classes/BtrixElement"; | ||
import type { BtrixChangeEvent } from "@/events/btrix-change"; | ||
|
||
export type BtrixChangeWorkflowScheduleFilterEvent = BtrixChangeEvent< | ||
undefined | boolean | ||
>; | ||
|
||
enum ScheduleType { | ||
Scheduled = "Scheduled", | ||
None = "None", | ||
Any = "Any", | ||
} | ||
|
||
/** | ||
* @fires btrix-change | ||
*/ | ||
@customElement("btrix-workflow-schedule-filter") | ||
@localized() | ||
export class WorkflowScheduleFilter extends BtrixElement { | ||
@property({ type: Boolean }) | ||
schedule?: boolean; | ||
|
||
#schedule?: boolean; | ||
|
||
protected willUpdate(changedProperties: PropertyValues): void { | ||
if (changedProperties.has("schedule")) { | ||
this.#schedule = this.schedule; | ||
} | ||
} | ||
|
||
render() { | ||
const radio = (label: string, value: string) => html` | ||
<sl-radio | ||
class="!mt-0 w-full part-[base]:w-full part-[base]:rounded part-[base]:p-2 part-[base]:hover:bg-primary-50" | ||
value=${value} | ||
>${label}</sl-radio | ||
> | ||
`; | ||
|
||
return html` | ||
<btrix-workflow-filter | ||
?checked=${this.schedule !== undefined} | ||
select | ||
@sl-after-hide=${() => { | ||
if (this.#schedule !== this.schedule) { | ||
this.dispatchEvent( | ||
new CustomEvent<BtrixChangeWorkflowScheduleFilterEvent["detail"]>( | ||
"btrix-change", | ||
{ | ||
detail: { value: this.#schedule }, | ||
}, | ||
), | ||
); | ||
} | ||
}} | ||
> | ||
${this.schedule === undefined | ||
? msg("Schedule") | ||
: html`<strong class="font-semibold" | ||
>${this.schedule ? msg("Scheduled") : msg("No Schedule")}</strong | ||
>`} | ||
|
||
<div | ||
slot="dropdown-header" | ||
class="flex items-center justify-between py-1" | ||
> | ||
<sl-menu-label class="part-[base]:px-4" id="schedule-list-label"> | ||
${msg("Filter by Schedule Type")} | ||
</sl-menu-label> | ||
${this.schedule !== undefined | ||
? html`<sl-button | ||
variant="text" | ||
size="small" | ||
@click=${() => { | ||
this.dispatchEvent( | ||
new CustomEvent<BtrixChangeEvent["detail"]>( | ||
"btrix-change", | ||
{ | ||
detail: { | ||
value: undefined, | ||
}, | ||
}, | ||
), | ||
); | ||
}} | ||
>${msg("Clear Filter")}</sl-button | ||
>` | ||
: nothing} | ||
</div> | ||
|
||
<div slot="dropdown-content" class="p-1"> | ||
<sl-radio-group | ||
@sl-change=${(e: SlChangeEvent) => { | ||
const { value } = e.target as SlRadioGroup; | ||
|
||
switch (value as ScheduleType) { | ||
case ScheduleType.Scheduled: | ||
this.#schedule = true; | ||
break; | ||
case ScheduleType.None: | ||
this.#schedule = false; | ||
break; | ||
default: | ||
this.#schedule = undefined; | ||
break; | ||
} | ||
}} | ||
value=${this.schedule === undefined | ||
? ScheduleType.Any | ||
: this.schedule | ||
? ScheduleType.Scheduled | ||
: ScheduleType.None} | ||
> | ||
${radio(msg("Scheduled"), ScheduleType.Scheduled)} | ||
${radio(msg("No Schedule"), ScheduleType.None)} | ||
</sl-radio-group> | ||
</div> | ||
</btrix-workflow-filter> | ||
`; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.