import { LitElement, html, nothing } from 'lit'; import { t } from '../../lib/i18n.js'; import { fetchToolDetail, renderToolBody, STATUS_ICON } from './tool-detail-view.js'; /** * Mobile tool-execution detail page. Same shared engine as the desktop * ``, but prop-driven: `` binds `visible` / `toolId` * from its hash router (`#tool_detail?id=...`) instead of the component listening to * the hash. The back button returns to the previous mobile section via history. */ export class MobileToolDetailPage extends LitElement { // No shadow DOM — inherit the app's global CSS + Bootstrap Icons. createRenderRoot() { return this; } static properties = { visible: { type: Boolean }, toolId: { attribute: 'tool-id' }, _loading: { state: true }, _error: { state: true }, _tool: { state: true }, }; constructor() { super(); this.visible = false; this.toolId = null; this._loading = false; this._error = null; this._tool = null; } updated(changed) { if (changed.has('visible') || changed.has('toolId')) { if (this.visible && this.toolId != null) this._load(); } } async _load() { this._loading = true; this._error = null; this._tool = null; try { this._tool = await fetchToolDetail(this.toolId); } catch (e) { this._error = e.message || String(e); } finally { this._loading = false; } } _back() { history.back(); } render() { if (!this.visible) return nothing; const tl = this._tool; const si = tl ? (STATUS_ICON[tl.status] || STATUS_ICON.done) : null; return html` this._back()}> ${si ? html`` : nothing} ${tl ? (tl.display_name || tl.name) : t('tool_detail.title')} ${this._loading ? html`${t('common.loading')}` : nothing} ${this._error ? html`${this._error}` : nothing} ${renderToolBody(tl)} `; } } customElements.define('mobile-tool-detail-page', MobileToolDetailPage);