Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hacs-progress-dialog #663

Merged
merged 1 commit into from
Jun 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/components/dialogs/hacs-dialog-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class HacsDialogBase extends LitElement {
changedProperties.has("active") ||
changedProperties.has("params") ||
changedProperties.has("_error") ||
changedProperties.has("_progress") ||
changedProperties.has("_repository") ||
changedProperties.has("_releaseNotes") ||
changedProperties.has("_updating")
Expand Down
10 changes: 7 additions & 3 deletions src/components/dialogs/hacs-download-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ export class HacsDonwloadDialog extends LitElement {
${this._error.message}
</ha-alert>`
: nothing}
${this._installing
? html`<mwc-linear-progress indeterminate></mwc-linear-progress>`
: nothing}
</div>
${this._installing
? html`<mwc-linear-progress indeterminate></mwc-linear-progress>`
: nothing}
<mwc-button slot="secondaryAction" @click=${this.closeDialog} dialogInitialFocus>
${this._dialogParams.hacs.localize("common.cancel")}
</mwc-button>
Expand Down Expand Up @@ -262,6 +262,10 @@ export class HacsDonwloadDialog extends LitElement {
white-space: pre-line;
user-select: all;
}
mwc-linear-progress {
margin-bottom: -8px;
margin-top: 4px;
}
`,
];
}
Expand Down
1 change: 0 additions & 1 deletion src/components/dialogs/hacs-event-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { HacsDialogBase } from "./hacs-dialog-base";
const DIALOG = {
"custom-repositories": () => import("./hacs-custom-repositories-dialog"),
generic: () => import("./hacs-generic-dialog"),
progress: () => import("./hacs-progress-dialog"),
};

@customElement("hacs-event-dialog")
Expand Down
45 changes: 32 additions & 13 deletions src/components/dialogs/hacs-form-dialog.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import "@material/mwc-button/mwc-button";
import "@material/mwc-linear-progress/mwc-linear-progress";
import { CSSResultGroup, LitElement, css, html, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import "../../../homeassistant-frontend/src/components/ha-dialog";
Expand Down Expand Up @@ -44,24 +46,34 @@ class HacsFromDialog extends LitElement {
: this._dialogParams.title}
@closed=${this.closeDialog}
>
${this._dialogParams.description || nothing}
<ha-form
.hass=${this.hass}
.data=${this._dialogParams.data || {}}
.schema=${this._dialogParams.schema || []}
.error=${this._errors}
.computeLabel=${this._computeLabel}
.computeHelper=${this._computeHelper}
.computeError=${this._computeError}
@value-changed=${this._valueChanged}
dialogInitialFocus
></ha-form>
<div>
${this._dialogParams.description || nothing}
${this._dialogParams.schema && this._dialogParams.saveAction
? html`<ha-form
.hass=${this.hass}
.data=${this._dialogParams.data || {}}
.schema=${this._dialogParams.schema || []}
.error=${this._errors}
.computeLabel=${this._computeLabel}
.computeHelper=${this._computeHelper}
.computeError=${this._computeError}
@value-changed=${this._valueChanged}
dialogInitialFocus
></ha-form>`
: nothing}
${this._waiting
? html`<mwc-linear-progress indeterminate></mwc-linear-progress>`
: nothing}
</div>
${this._dialogParams.saveAction
? html`<mwc-button slot="secondaryAction" @click=${this.closeDialog} dialogInitialFocus>
${this._dialogParams.hacs.localize("common.cancel")}
</mwc-button>
<mwc-button
.disabled=${this._waiting || !this._dialogParams.data}
class="${this._dialogParams.destructive ? "destructive" : ""}"
.disabled=${this._waiting ||
(this._dialogParams.schema?.some((entry) => entry.required) &&
!this._dialogParams.data)}
slot="primaryAction"
@click=${this._saveClicked}
>
Expand Down Expand Up @@ -113,6 +125,13 @@ class HacsFromDialog extends LitElement {
.root > *:not([own-margin]):not(:last-child) {
margin-bottom: 24px;
}
.destructive {
--mdc-theme-primary: var(--hcv-color-error);
}
mwc-linear-progress {
margin-bottom: -8px;
margin-top: 4px;
}
`;
}
}
Expand Down
69 changes: 0 additions & 69 deletions src/components/dialogs/hacs-progress-dialog.ts

This file was deleted.

3 changes: 2 additions & 1 deletion src/components/dialogs/show-hacs-form-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export interface HacsFormDialogParams {
schema?: readonly HaFormSchema[];
data?: HaFormDataContainer;
saveLabel?: string;
description?: HTMLTemplateResult;
destructive?: boolean;
description?: HTMLTemplateResult | string;
computeLabelCallback?: (schema: any, data: HaFormDataContainer) => string;
computeHelper?: (schema: any) => string | undefined;
computeError?: (schema: any, error) => string;
Expand Down
30 changes: 13 additions & 17 deletions src/components/hacs-repository-owerflow-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { repositoryUninstall, repositoryUpdate } from "../data/websocket";
import type { HacsExperimentalPanel } from "../panels/hacs-experimental-panel";
import type { HacsRepositoryPanel } from "../panels/hacs-repository-panel";
import { showHacsDownloadDialog } from "./dialogs/show-hacs-download-dialog";
import { showHacsFormDialog } from "./dialogs/show-hacs-form-dialog";

export const repositoryMenuItems = memoizeOne(
(element: HacsRepositoryPanel | HacsExperimentalPanel, repository: RepositoryBase) => [
Expand Down Expand Up @@ -120,23 +121,18 @@ export const repositoryMenuItems = memoizeOne(
}
}
}
element.dispatchEvent(
new CustomEvent("hacs-dialog", {
detail: {
type: "progress",
title: element.hacs.localize("dialog.remove.title"),
confirmText: element.hacs.localize("dialog.remove.title"),
content: element.hacs.localize("dialog.remove.message", {
name: repository.name,
}),
confirm: async () => {
await _repositoryRemove(element, repository);
},
},
bubbles: true,
composed: true,
})
);
showHacsFormDialog(element, {
hacs: element.hacs,
title: element.hacs.localize("dialog.remove.title"),
saveLabel: element.hacs.localize("dialog.remove.title"),
description: element.hacs.localize("dialog.remove.message", {
name: repository.name,
}),
saveAction: async () => {
await _repositoryRemove(element, repository);
},
destructive: true,
});
},
warning: true,
},
Expand Down