Fixes for flow help icon (#12224)

This commit is contained in:
Joakim Sørensen 2022-04-06 00:47:24 +02:00 committed by GitHub
parent 59595aabde
commit 4e82c23b29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 51 additions and 14 deletions

View File

@ -29,6 +29,7 @@ import {
DeviceRegistryEntry, DeviceRegistryEntry,
subscribeDeviceRegistry, subscribeDeviceRegistry,
} from "../../data/device_registry"; } from "../../data/device_registry";
import { fetchIntegrationManifest } from "../../data/integration";
import { haStyleDialog } from "../../resources/styles"; import { haStyleDialog } from "../../resources/styles";
import type { HomeAssistant } from "../../types"; import type { HomeAssistant } from "../../types";
import { documentationUrl } from "../../util/documentation-url"; import { documentationUrl } from "../../util/documentation-url";
@ -43,10 +44,10 @@ import "./step-flow-create-entry";
import "./step-flow-external"; import "./step-flow-external";
import "./step-flow-form"; import "./step-flow-form";
import "./step-flow-loading"; import "./step-flow-loading";
import "./step-flow-menu";
import "./step-flow-pick-flow"; import "./step-flow-pick-flow";
import "./step-flow-pick-handler"; import "./step-flow-pick-handler";
import "./step-flow-progress"; import "./step-flow-progress";
import "./step-flow-menu";
let instance = 0; let instance = 0;
@ -237,22 +238,32 @@ class DataEntryFlowDialog extends LitElement {
"" ""
: html` : html`
<div class="dialog-actions"> <div class="dialog-actions">
${["form", "menu", "external"].includes( ${([
this._step?.type as any "form",
) "menu",
"external",
"progress",
"data_entry_flow_progressed",
].includes(this._step?.type as any) &&
this._params.manifest?.is_built_in) ||
this._params.manifest?.documentation
? html` ? html`
<a <a
href=${documentationUrl( href=${this._params.manifest.is_built_in
this.hass, ? documentationUrl(
`/integrations/${this._step!.handler}` this.hass,
)} `/integrations/${this._params.manifest.domain}`
)
: this._params?.manifest?.documentation}
target="_blank" target="_blank"
rel="noreferrer noopener" rel="noreferrer noopener"
><ha-icon-button >
<ha-icon-button
.label=${this.hass.localize("ui.common.help")} .label=${this.hass.localize("ui.common.help")}
.path=${mdiHelpCircle} .path=${mdiHelpCircle}
?rtl=${computeRTL(this.hass)} ?rtl=${computeRTL(this.hass)}
></ha-icon-button >
</ha-icon-button
></a> ></a>
` `
: ""} : ""}
@ -427,6 +438,17 @@ class DataEntryFlowDialog extends LitElement {
this._handler = undefined; this._handler = undefined;
} }
this._processStep(step); this._processStep(step);
if (this._params!.manifest === undefined) {
try {
this._params!.manifest = await fetchIntegrationManifest(
this.hass,
this._params?.domain || step.handler
);
} catch (_) {
// No manifest
this._params!.manifest = null;
}
}
} else { } else {
this._step = null; this._step = null;
this._flowsInProgress = flowsInProgress; this._flowsInProgress = flowsInProgress;

View File

@ -10,6 +10,7 @@ import {
DataEntryFlowStepMenu, DataEntryFlowStepMenu,
DataEntryFlowStepProgress, DataEntryFlowStepProgress,
} from "../../data/data_entry_flow"; } from "../../data/data_entry_flow";
import { IntegrationManifest } from "../../data/integration";
import { HomeAssistant } from "../../types"; import { HomeAssistant } from "../../types";
export interface FlowHandlers { export interface FlowHandlers {
@ -122,6 +123,8 @@ export interface DataEntryFlowDialogParams {
startFlowHandler?: string; startFlowHandler?: string;
searchQuery?: string; searchQuery?: string;
continueFlowId?: string; continueFlowId?: string;
manifest?: IntegrationManifest | null;
domain?: string;
dialogClosedCallback?: (params: { dialogClosedCallback?: (params: {
flowFinished: boolean; flowFinished: boolean;
entryId?: string; entryId?: string;

View File

@ -1,6 +1,6 @@
import { html } from "lit"; import { html } from "lit";
import { ConfigEntry } from "../../data/config_entries"; import { ConfigEntry } from "../../data/config_entries";
import { domainToName } from "../../data/integration"; import { domainToName, IntegrationManifest } from "../../data/integration";
import { import {
createOptionsFlow, createOptionsFlow,
deleteOptionsFlow, deleteOptionsFlow,
@ -16,12 +16,15 @@ export const loadOptionsFlowDialog = loadDataEntryFlowDialog;
export const showOptionsFlowDialog = ( export const showOptionsFlowDialog = (
element: HTMLElement, element: HTMLElement,
configEntry: ConfigEntry configEntry: ConfigEntry,
manifest?: IntegrationManifest | null
): void => ): void =>
showFlowDialog( showFlowDialog(
element, element,
{ {
startFlowHandler: configEntry.entry_id, startFlowHandler: configEntry.entry_id,
domain: configEntry.domain,
manifest,
}, },
{ {
loadDevicesAndAreas: false, loadDevicesAndAreas: false,

View File

@ -190,6 +190,10 @@ class StepFlowForm extends LitElement {
margin-top: 24px; margin-top: 24px;
display: block; display: block;
} }
h2 {
word-break: break-word;
padding-right: 72px;
}
`, `,
]; ];
} }

View File

@ -730,7 +730,7 @@ export class EntityRegistrySettings extends SubscribeMixin(LitElement) {
} }
private async _showOptionsFlow() { private async _showOptionsFlow() {
showOptionsFlowDialog(this, this._helperConfigEntry!); showOptionsFlowDialog(this, this._helperConfigEntry!, null);
} }
private _switchAsDomainsSorted = memoizeOne( private _switchAsDomainsSorted = memoizeOne(

View File

@ -700,6 +700,7 @@ class HaConfigIntegrations extends SubscribeMixin(LitElement) {
this._handleFlowUpdated(); this._handleFlowUpdated();
}, },
startFlowHandler: domain, startFlowHandler: domain,
manifest: this._manifests[domain],
showAdvanced: this.hass.userData?.showAdvanced, showAdvanced: this.hass.userData?.showAdvanced,
}); });
} }

View File

@ -482,7 +482,11 @@ export class HaIntegrationCard extends LitElement {
); );
private _showOptions(ev) { private _showOptions(ev) {
showOptionsFlowDialog(this, ev.target.closest("ha-card").configEntry); showOptionsFlowDialog(
this,
ev.target.closest("ha-card").configEntry,
this.manifest
);
} }
private _handleRename(ev: CustomEvent<RequestSelectedDetail>): void { private _handleRename(ev: CustomEvent<RequestSelectedDetail>): void {