Skip to content

Commit

Permalink
[shared-ui] Improve the workspace outline filter (#3862)
Browse files Browse the repository at this point in the history
  • Loading branch information
paullewis authored and timswanson-google committed Dec 3, 2024
1 parent a7c34b4 commit a7e5684
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/hip-queens-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@breadboard-ai/shared-ui": patch
---

Improve the workspace outline filter
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,14 @@ export class WorkspaceOutline extends LitElement {
background-color: var(--bb-neutral-50);
}
.no-items {
padding: var(--bb-grid-size-2) var(--bb-grid-size-3);
font: 400 var(--bb-body-small) / var(--bb-body-line-height-small)
var(--bb-font-family);
font-style: italic;
color: var(--bb-neutral-700);
}
bb-overflow-menu {
position: fixed;
z-index: 100;
Expand Down Expand Up @@ -868,6 +876,10 @@ export class WorkspaceOutline extends LitElement {
seenSubItems: Set<string>,
renderSubItemsInline = false
): HTMLTemplateResult {
if (nodes.length === 0) {
return html`<div class="no-items">There are no items available</div>`;
}

return html`<ul>
${map(nodes, (node) => {
const { type } = node.descriptor;
Expand Down Expand Up @@ -1356,11 +1368,21 @@ export class WorkspaceOutline extends LitElement {
pending: () => html`Loading...`,
complete: (outline) => {
let nodes = [...outline.items.nodes];
const subItems = new Map([...outline.subItems]);
if (this.filter) {
nodes = nodes.filter((node) => {
const filter = new RegExp(this.filter!, "gim");
return filter.test(node.title());
});
for (const [id, graphOrModule] of subItems) {
const filter = new RegExp(this.filter, "gim");
if (filter.test(id) || filter.test(graphOrModule.title)) {
continue;
}
subItems.delete(id);
}
}
return this.#renderWorkspace(
Expand All @@ -1369,7 +1391,7 @@ export class WorkspaceOutline extends LitElement {
outline.title,
nodes,
outline.items.ports,
outline.subItems,
subItems,
this.mode === "tree"
);
},
Expand Down

0 comments on commit a7e5684

Please sign in to comment.