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

My redirects tweaks #8447

Merged
merged 4 commits into from
Feb 24, 2021
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
10 changes: 9 additions & 1 deletion src/panels/developer-tools/service/developer-tools-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import memoizeOne from "memoize-one";
import { LocalStorage } from "../../../common/decorators/local-storage";
import { computeDomain } from "../../../common/entity/compute_domain";
import { computeObjectId } from "../../../common/entity/compute_object_id";
import { extractSearchParam } from "../../../common/url/search-params";
import "../../../components/buttons/ha-progress-button";
import "../../../components/entity/ha-entity-picker";
import "../../../components/ha-card";
Expand Down Expand Up @@ -40,7 +41,14 @@ class HaPanelDevService extends LitElement {

protected firstUpdated(params) {
super.firstUpdated(params);
if (!this._serviceData?.service) {
const serviceParam = extractSearchParam("service");
if (serviceParam) {
this._serviceData = {
service: serviceParam,
target: {},
data: {},
};
} else if (!this._serviceData?.service) {
const domain = Object.keys(this.hass.services).sort()[0];
const service = Object.keys(this.hass.services[domain]).sort()[0];
this._serviceData = {
Expand Down
56 changes: 50 additions & 6 deletions src/panels/my/ha-panel-my.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import "../../layouts/hass-error-screen";
import { isComponentLoaded } from "../../common/config/is_component_loaded";
import { domainToName } from "../../data/integration";
import { documentationUrl } from "../../util/documentation-url";

const REDIRECTS: Redirects = {
developer_states: {
Expand All @@ -23,12 +24,21 @@ const REDIRECTS: Redirects = {
developer_services: {
redirect: "/developer-tools/service",
},
developer_call_service: {
redirect: "/developer-tools/service",
params: {
service: "string",
},
},
developer_template: {
redirect: "/developer-tools/template",
},
developer_events: {
redirect: "/developer-tools/event",
},
config: {
redirect: "/config",
},
cloud: {
component: "cloud",
redirect: "/config/cloud",
Expand All @@ -42,6 +52,18 @@ const REDIRECTS: Redirects = {
domain: "string",
},
},
config_mqtt: {
component: "mqtt",
redirect: "/config/mqtt",
},
config_zha: {
component: "zha",
redirect: "/config/zha/dashboard",
},
config_zwave_js: {
component: "zwave_js",
redirect: "/config/zwave_js/dashboard",
},
devices: {
redirect: "/config/devices/dashboard",
},
Expand All @@ -52,39 +74,49 @@ const REDIRECTS: Redirects = {
redirect: "/config/areas/dashboard",
},
blueprints: {
component: "blueprint",
redirect: "/config/blueprint/dashboard",
},
blueprint_import: {
component: "blueprint",
redirect: "/config/blueprint/dashboard/import",
params: {
blueprint_url: "url",
},
},
automations: {
component: "automation",
redirect: "/config/automation/dashboard",
},
scenes: {
component: "scene",
redirect: "/config/scene/dashboard",
},
scripts: {
component: "script",
redirect: "/config/script/dashboard",
},
helpers: {
redirect: "/config/helpers",
},
tags: {
component: "tags",
redirect: "/config/tags",
},
lovelace_dashboards: {
component: "lovelace",
redirect: "/config/lovelace/dashboards",
},
lovelace_resources: {
component: "lovelace",
redirect: "/config/lovelace/resources",
},
people: {
component: "person",
redirect: "/config/person",
},
zones: {
component: "zone",
redirect: "/config/zone",
},
users: {
Expand All @@ -108,6 +140,14 @@ const REDIRECTS: Redirects = {
profile: {
redirect: "/profile/dashboard",
},
logbook: {
component: "logbook",
redirect: "/logbook",
},
history: {
component: "history",
redirect: "/history",
},
};

export type ParamType = "url" | "string";
Expand Down Expand Up @@ -201,12 +241,16 @@ class HaPanelMy extends LitElement {
) || "This redirect is not supported.";
break;
case "no_supervisor":
error =
this.hass.localize(
"ui.panel.my.component_not_loaded",
"integration",
"Home Assistant Supervisor"
) || "This redirect requires Home Assistant Supervisor.";
error = this.hass.localize(
"ui.panel.my.no_supervisor",
"docs_link",
html`<a
target="_blank"
rel="noreferrer noopener"
href="${documentationUrl(this.hass, "/installation")}"
>${this.hass.localize("ui.panel.my.documentation")}</a
>`
);
break;
default:
error = this.hass.localize("ui.panel.my.error") || "Unknown error";
Expand Down
2 changes: 2 additions & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,8 @@
"my": {
"not_supported": "This redirect is not supported by your Home Assistant instance. Check the {link} for the supported redirects and the version they where introduced.",
"component_not_loaded": "This redirect is not supported by your Home Assistant instance. You need the integration {integration} to use this redirect.",
"no_supervisor": "This redirect is not supported by your Home Assistant installation. It needs either the Home Assistant Operating System or Home Assistant Supervised installation method. For more information, see the {docs_link}.",
"documentation": "documentation",
"faq_link": "My Home Assistant FAQ",
"error": "An unknown error occured"
},
Expand Down