import { customElement, DeesElement, property, html, cssManager, unsafeCSS, css, state, type TemplateResult, } from '@design.estate/dees-element'; import * as plugins from '../../plugins.js'; import * as states from '../../states/accountstate.js'; import { IdpState } from '../../states/idp.state.js'; import { accountDesignTokens } from './sharedstyles.js'; import { commitinfo } from '../../../dist_ts/00_commitinfo_data.js'; declare global { interface HTMLElementTagNameMap { 'lele-accountnavigation': LeleAccountNavigation; } } @customElement('lele-accountnavigation') export class LeleAccountNavigation extends DeesElement { @state() accessor isGlobalAdmin: boolean = false; constructor() { super(); } public static styles = [ cssManager.defaultStyles, accountDesignTokens, css` :host { display: flex; flex-direction: column; background: var(--card); border-right: 1px solid var(--border); height: 100%; } :host([hidden]) { display: none; } .logoArea { padding: 20px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; } .logo { font-family: 'Cal Sans', 'Geist Sans', sans-serif; letter-spacing: -0.02em; font-size: 20px; font-weight: 600; color: var(--foreground); cursor: pointer; transition: opacity 0.15s ease; display: flex; align-items: center; gap: 8px; } .logo:hover { opacity: 0.8; } .logo dees-icon { font-size: 24px; opacity: 0.9; } .navContent { flex: 1; overflow-y: auto; padding-bottom: 16px; } .commitinfo { flex-shrink: 0; text-align: center; font-family: 'Geist Mono', monospace; font-size: 10px; padding: 12px 16px; border-top: 1px solid var(--border); color: var(--muted-foreground); opacity: 0.6; background: var(--card); } .navigationGroupLabel { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-foreground); padding: 20px 16px 8px; opacity: 0.7; } .navigationGroupLabel:first-of-type { padding-top: 16px; } .navigationOption { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 2px 8px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--muted-foreground); transition: all 0.15s ease; cursor: pointer; } .navigationOption:hover { background: var(--muted); color: var(--foreground); } .navigationOption dees-icon { font-size: 16px; opacity: 0.7; flex-shrink: 0; } .navigationOption:hover dees-icon { opacity: 1; } .divider { height: 1px; background: var(--border); margin: 8px 16px; } dees-input-dropdown { margin: 8px; } `, ]; public async getAccountRouter() { const host = (this.getRootNode() as any).host; return (host as any).subrouter; } public render(): TemplateResult { return html`
v${commitinfo.version}
`; } private renderAdminLink(): TemplateResult | null { if (!this.isGlobalAdmin) { return null; } return html`
`; } public firstUpdated() { const deesInputDropdown = this.shadowRoot.querySelector('dees-input-dropdown'); const orgToMenuEntry = (orgArg?: plugins.idpInterfaces.data.IOrganization) => { if (!orgArg) { return null; } return { option: orgArg.data.name, key: orgArg.data.slug, payload: orgArg.data.slug, }; }; // "Create new..." option to add at the end const createNewOption = { option: '+ Create new...', key: '__create_new__', payload: '__create_new__', }; states.accountState .select((stateArg) => stateArg.organizations) .pipe( plugins.deesDomtools.plugins.smartrx.rxjs.ops.map((orgArrayArg) => { const orgEntries = orgArrayArg.map(orgToMenuEntry); // Add "Create new..." at the end return [...orgEntries, createNewOption]; }) ) .subscribe((menuEntries) => { deesInputDropdown.options = menuEntries; }); states.accountState .select((stateArg) => stateArg.selectedOrg) .pipe(plugins.deesDomtools.plugins.smartrx.rxjs.ops.map(orgToMenuEntry)) .subscribe((selectedOrgArg) => { deesInputDropdown.selectedOption = selectedOrgArg; }); // Check if user is global admin states.accountState .select((stateArg) => stateArg.user) .subscribe((user) => { this.isGlobalAdmin = user?.data?.isGlobalAdmin ?? false; }); } }