import { state, property } from "lit/decorators.js";
import { msg, localized, str } from "@lit/localize";
import type { AuthState } from "../../utils/AuthService";
import LiteElement, { html } from "../../utils/LiteElement";
import type { Profile } from "./types";
import type { APIPaginatedList } from "../../types/api";
/**
* Usage:
* ```ts
*
* ```
*/
@localized()
export class BrowserProfilesList extends LiteElement {
@property({ type: Object })
authState!: AuthState;
@property({ type: String })
orgId!: string;
@property({ type: Boolean })
showCreateDialog = false;
@state()
browserProfiles?: Profile[];
@state()
private isCreateFormVisible = false;
@state()
private isSubmitting = false;
firstUpdated() {
if (this.showCreateDialog) {
this.isCreateFormVisible = true;
}
this.fetchBrowserProfiles();
}
render() {
return html`
${this.renderTable()}
(this.isCreateFormVisible = true)}
@sl-after-hide=${() => (this.isCreateFormVisible = false)}
>
${this.isCreateFormVisible ? this.renderCreateForm() : ""}
`;
}
private renderTable() {
return html`
${msg("Description")}
${msg("Created")}
${msg("Visited URLs")}
${this.browserProfiles
? this.browserProfiles.length
? html`
${this.browserProfiles.map(this.renderItem.bind(this))}
`
: html`
${msg("No browser profiles yet.")}
`
: ""}
`;
}
private renderItem(data: Profile) {
return html`
${data.name}
${data.description}
${new Date(data.created).toLocaleDateString()}
${data.origins.join(", ")}
${this.renderMenu(data)}
`;
}
private renderMenu(data: Profile) {
return html`