-
-
Notifications
You must be signed in to change notification settings - Fork 60
WIP: Manage org dedupe indices #2942
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
Draft
SuaYoo
wants to merge
5
commits into
feature-dedupe
Choose a base branch
from
feature-dedupe--frontend-org
base: feature-dedupe
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
168 changes: 168 additions & 0 deletions
168
frontend/src/pages/org/settings/components/deduplication.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,168 @@ | ||
| import { localized, msg } from "@lit/localize"; | ||
| import { Task } from "@lit/task"; | ||
| import { html, type PropertyValues } from "lit"; | ||
| import { customElement, property, state } from "lit/decorators.js"; | ||
| import { when } from "lit/directives/when.js"; | ||
| import queryString from "query-string"; | ||
|
|
||
| import { loadingPanel } from "../templates/loading-panel"; | ||
|
|
||
| import { BtrixElement } from "@/classes/BtrixElement"; | ||
| import { parsePage, type PageChangeEvent } from "@/components/ui/pagination"; | ||
| import { OrgTab } from "@/routes"; | ||
| import { noData } from "@/strings/ui"; | ||
| import type { APIPaginatedList, APIPaginationQuery } from "@/types/api"; | ||
| import type { Collection } from "@/types/collection"; | ||
| import { isNotEqual } from "@/utils/is-not-equal"; | ||
|
|
||
| const INITIAL_PAGE_SIZE = 10; | ||
|
|
||
| @customElement("btrix-org-settings-deduplication") | ||
| @localized() | ||
| export class OrgSettingsDeduplication extends BtrixElement { | ||
| @property({ type: Boolean }) | ||
| visible?: boolean; | ||
|
|
||
| @state({ hasChanged: isNotEqual }) | ||
| private pagination: Required<APIPaginationQuery> = { | ||
| page: parsePage(new URLSearchParams(location.search).get("page")), | ||
| pageSize: INITIAL_PAGE_SIZE, | ||
| }; | ||
|
|
||
| protected willUpdate(changedProperties: PropertyValues): void { | ||
| // Reset pagination when tab is hidden | ||
| if (changedProperties.has("visible") && !this.visible) { | ||
| this.pagination = { | ||
| ...this.pagination, | ||
| page: 1, | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| private readonly sources = new Task(this, { | ||
| task: async ([pagination], { signal }) => { | ||
| return this.getCollections({ ...pagination }, signal); | ||
| }, | ||
| args: () => [this.pagination] as const, | ||
| }); | ||
|
|
||
| render() { | ||
| return html` ${this.sources.render({ | ||
| initial: loadingPanel, | ||
| pending: () => | ||
| this.sources.value | ||
| ? this.renderTable(this.sources.value) | ||
| : loadingPanel(), | ||
| complete: this.renderTable, | ||
| })}`; | ||
| } | ||
|
|
||
| private readonly renderTable = ( | ||
| collections: APIPaginatedList<Collection>, | ||
| ) => { | ||
| return html`<btrix-table | ||
| class="whitespace-nowrap [--btrix-table-cell-padding-x:var(--sl-spacing-2x-small)]" | ||
| style="--btrix-table-grid-template-columns: 10ch 40ch repeat(4, 1fr) min-content" | ||
| > | ||
| <btrix-table-head class="mb-2"> | ||
| <btrix-table-header-cell> | ||
| ${msg("Source Type")} | ||
| </btrix-table-header-cell> | ||
| <btrix-table-header-cell>${msg("Name")}</btrix-table-header-cell> | ||
| <btrix-table-header-cell> | ||
| ${msg("Archived Items")} | ||
| </btrix-table-header-cell> | ||
| <btrix-table-header-cell> | ||
| ${msg("Index Entries")} | ||
| </btrix-table-header-cell> | ||
| <btrix-table-header-cell> | ||
| ${msg("Index Size")} | ||
| </btrix-table-header-cell> | ||
| <btrix-table-header-cell> | ||
| ${msg("Purgeable Entries")} | ||
| </btrix-table-header-cell> | ||
| <btrix-table-header-cell> | ||
| <span class="sr-only">${msg("Actions")}</span> | ||
| </btrix-table-header-cell> | ||
| </btrix-table-head> | ||
| <btrix-table-body | ||
| class="rounded border [--btrix-table-cell-padding:var(--sl-spacing-2x-small)]" | ||
| > | ||
| ${collections.items.map( | ||
| (item) => html` | ||
| <btrix-table-row | ||
| class="border-t first:border-t-0 last:rounded-b hover:bg-neutral-50" | ||
| > | ||
| <btrix-table-cell> | ||
| <btrix-badge>${msg("Collection")}</btrix-badge> | ||
| </btrix-table-cell> | ||
| <btrix-table-cell>${item.name}</btrix-table-cell> | ||
| <btrix-table-cell | ||
| >${this.localize.number(item.crawlCount)}</btrix-table-cell | ||
| > | ||
| <btrix-table-cell>${noData}</btrix-table-cell> | ||
| <btrix-table-cell>${noData}</btrix-table-cell> | ||
| <btrix-table-cell>${noData}</btrix-table-cell> | ||
| <btrix-table-cell> | ||
| <sl-tooltip content=${msg("Open in New Tab")}> | ||
| <sl-icon-button | ||
| name="arrow-up-right" | ||
| href="${this.navigate | ||
| .orgBasePath}/${OrgTab.Collections}/view/${item.id}" | ||
| target="_blank" | ||
| > | ||
| </sl-icon-button> | ||
| </sl-tooltip> | ||
| <btrix-overflow-dropdown> | ||
| <sl-menu> | ||
| <sl-menu-item class="menu-item-warning" | ||
| >${msg("Clear Index")}</sl-menu-item | ||
| > | ||
| <sl-menu-item class="menu-item-danger" | ||
| >${msg("Delete Index")}</sl-menu-item | ||
| > | ||
| </sl-menu> | ||
| </btrix-overflow-dropdown> | ||
| </btrix-table-cell> | ||
| </btrix-table-row> | ||
| `, | ||
| )} | ||
| </btrix-table-body> | ||
| </btrix-table> | ||
| ${when( | ||
| collections.total > collections.pageSize, | ||
| () => html` | ||
| <footer class="mt-6 flex justify-center"> | ||
| <btrix-pagination | ||
| page=${collections.page} | ||
| totalCount=${collections.total} | ||
| size=${collections.pageSize} | ||
| @page-change=${async (e: PageChangeEvent) => { | ||
| this.pagination = { | ||
| ...this.pagination, | ||
| page: e.detail.page, | ||
| }; | ||
| }} | ||
| ></btrix-pagination> | ||
| </footer> | ||
| `, | ||
| )} `; | ||
| }; | ||
|
|
||
| private async getCollections( | ||
| params: APIPaginationQuery, | ||
| signal: AbortSignal, | ||
| ) { | ||
| const query = queryString.stringify({ | ||
| pageSize: 2, | ||
| ...params, | ||
| hasDedupeIndex: true, | ||
| }); | ||
| return this.api.fetch<APIPaginatedList<Collection>>( | ||
| `/orgs/${this.orgId}/collections?${query}`, | ||
| { | ||
| signal, | ||
| }, | ||
| ); | ||
| } | ||
| } |
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,7 @@ | ||
| import { html } from "lit"; | ||
|
|
||
| export const loadingPanel = () => { | ||
| return html`<div class="flex justify-center rounded border p-5 text-xl"> | ||
| <sl-spinner></sl-spinner> | ||
| </div>`; | ||
| }; |
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
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.