import {AppDisplay} from "../../../types/app-display.js" import {Service} from "../../../../../../../types/service.js" import {html} from "../../../../../../../framework/component.js" import {emailValidator} from "../../../utils/admin-email-validator.js" import {makeAppEditService} from "../../../services/app-edit-service.js" import {adminManagerControls} from "./aspects/admin-manager-controls.js" import {renderOp} from "../../../../../../../framework/op-rendering/render-op.js" import {XioTextInput} from "../../../../../../xio-components/inputs/xio-text-input.js" import {adminManagerStateAndActions} from "./aspects/admin-manager-state-and-actions.js" import {ValueChangeEvent} from "../../../../../../xio-components/inputs/events/value-change-event.js" export function makeAdminManager({app, appEditService, query}: { app: AppDisplay appEditService: Service query: (selector: string) => E }) { const {state, actions, subscribe} = adminManagerStateAndActions() const controls = adminManagerControls({ app, state, actions, appEditService, }) function handleEmailChange(event: ValueChangeEvent) { const email = event.detail.value ?? undefined actions.setAssignerDraft({email}) } function handleAssignButtonPress() { const textInput = query(".adminassigner xio-text-input") controls.assignAdmin() textInput.text = "" } function renderAdminAssigner() { const exportPartsTextInput = ` label: xiotextinput-label, textinput: xiotextinput-textinput, problems: xiotextinput-problems, label: adminmanager-xiotextinput-label, textinput: adminmanager-xiotextinput-textinput, problems: adminmanager-xiotextinput-problems, ` return html`
email grant
` } function renderAdminList() { return html`
${renderOp(state.admins, admins => html`
    ${admins.map(({email, userId}) => html`
  • ${email} controls.revokeAdmin(userId)}> revoke
  • `)}
`)}
` } function render() { return html` ${renderAdminAssigner()} ${renderAdminList()} ` } return {render, controls, subscribe} }