displaying source file
This commit is contained in:
1 parent
9bafbf4e8c
commit
8792ed6ed8
15 files changed
+124
-12
No files matched your search
@@ -44,6 +44,9 @@ export const NoTags = make({
|
||||
wowo: "!",
|
||||
},
|
||||
mode: "single",
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
},
|
||||
});
|
||||
|
||||
@@ -60,5 +63,8 @@ export const SomeTags = make({
|
||||
wowo: "!",
|
||||
},
|
||||
mode: "single",
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
},
|
||||
});
|
||||
@@ -53,6 +53,9 @@ Simple.args = {
|
||||
wowo: "!",
|
||||
},
|
||||
mode: "single",
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
trigger: [
|
||||
{
|
||||
platform: "numeric_state",
|
||||
@@ -102,6 +105,9 @@ EmptyStart.args = {
|
||||
id: "random",
|
||||
alias: "Random",
|
||||
description: "Example Metadata",
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
trigger_variables: {
|
||||
wowo: "!",
|
||||
},
|
||||
@@ -131,6 +137,9 @@ BadAutomationInvalidTriggers.args = {
|
||||
id: "random",
|
||||
alias: "Random",
|
||||
description: "Example Metadata",
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
trigger_variables: {
|
||||
wowo: "!",
|
||||
},
|
||||
@@ -169,6 +178,9 @@ RepeatExample.args = {
|
||||
alias: "Get out of baby room",
|
||||
description: "",
|
||||
mode: "single",
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
trigger: [
|
||||
{
|
||||
type: "opened",
|
||||
|
||||
@@ -26,6 +26,9 @@ const { make, componentMeta } = makeStory({
|
||||
description: "Amazing automation!",
|
||||
tags: {},
|
||||
state: "on",
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
flags: {
|
||||
isSelected: false,
|
||||
isModified: false,
|
||||
@@ -37,6 +40,9 @@ const { make, componentMeta } = makeStory({
|
||||
entityId: "automation.2",
|
||||
description: "Cool!",
|
||||
state: "on",
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
flags: {
|
||||
isSelected: false,
|
||||
isModified: false,
|
||||
@@ -84,6 +90,9 @@ export const Nested = make({
|
||||
description: "",
|
||||
title: "Automation #1",
|
||||
state: "on",
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
flags: {
|
||||
isSelected: true,
|
||||
isModified: false,
|
||||
@@ -96,6 +105,9 @@ export const Nested = make({
|
||||
description: "another one",
|
||||
title: "Automation #2",
|
||||
state: "off",
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
flags: {
|
||||
isSelected: false,
|
||||
isModified: false,
|
||||
@@ -108,6 +120,9 @@ export const Nested = make({
|
||||
description: "bad one",
|
||||
title: "Automation #3",
|
||||
state: "offing",
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
flags: {
|
||||
isSelected: false,
|
||||
isModified: false,
|
||||
@@ -146,6 +161,9 @@ export const Nested = make({
|
||||
isSelected: false,
|
||||
isModified: false,
|
||||
},
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
state: "on",
|
||||
tags: {
|
||||
type: "good",
|
||||
|
||||
@@ -54,6 +54,9 @@ export const useAutomationDB = (
|
||||
tags: {},
|
||||
issue: "New Automation",
|
||||
isNew: true,
|
||||
source_file: auto.source_file,
|
||||
source_file_type: auto.source_file_type,
|
||||
configuration_key: auto.configuration_key,
|
||||
},
|
||||
auto,
|
||||
]);
|
||||
@@ -88,11 +91,16 @@ const genMapping = (
|
||||
? undefined
|
||||
: `recived invalid state "${entityData.state}, this could be because you have a lingering automation that was not cleared by homeassistant, try to reboot HA or manually clear this automation from HA Database."`;
|
||||
let found: AutomationData | null = null;
|
||||
|
||||
let source_file = "n/a";
|
||||
let source_file_type = "n/a";
|
||||
let configuration_key = "n/a";
|
||||
if (configData[autoId]) {
|
||||
found = configData[entityData.attributes.id];
|
||||
title = found.alias ?? title;
|
||||
description = found.description ?? description;
|
||||
source_file = found.source_file ?? source_file;
|
||||
source_file_type = found.source_file_type ?? source_file_type;
|
||||
configuration_key = found.configuration_key ?? configuration_key;
|
||||
delete configData[autoId];
|
||||
} else {
|
||||
issue = "failed to find this automation in '/config' folder";
|
||||
@@ -106,6 +114,9 @@ const genMapping = (
|
||||
description,
|
||||
state: entityData.state,
|
||||
tags: tagsDB.getTags(autoId),
|
||||
source_file,
|
||||
source_file_type,
|
||||
configuration_key,
|
||||
issue,
|
||||
},
|
||||
found,
|
||||
@@ -121,6 +132,9 @@ const genMapping = (
|
||||
description: auto.description ?? "",
|
||||
state: "unregistered",
|
||||
tags: tagsDB.getTags(auto.id),
|
||||
source_file: auto.source_file,
|
||||
source_file_type: auto.source_file_type,
|
||||
configuration_key: auto.configuration_key,
|
||||
issue:
|
||||
"homeassistant did not load this automation, try to manually reload automations or restart homeassistant.",
|
||||
},
|
||||
|
||||
@@ -84,4 +84,14 @@
|
||||
font-size: 0.75em;
|
||||
user-select: none;
|
||||
max-width: 5em;
|
||||
}
|
||||
|
||||
.automation-manager--metadatabox .metadatabox--title--source {
|
||||
margin-bottom: -0.5em;
|
||||
}
|
||||
|
||||
|
||||
.automation-manager--metadatabox .metadatabox--title--source .MuiChip-root {
|
||||
font-size: 0.85em;
|
||||
height: 2em;
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||
import { AutomationManagerAuto } from "../types";
|
||||
import { Tags } from "./Tags";
|
||||
import { TagDB } from "../TagDB";
|
||||
import { Chip } from "@mui/material";
|
||||
|
||||
export type MetadataBoxProps = AutomationManagerAuto & {
|
||||
onDelete: () => void;
|
||||
@@ -53,6 +54,9 @@ export const MetadataBox: FC<MetadataBoxProps> = (props) => {
|
||||
className="metadatabox--title"
|
||||
title={`ID=${props.id}, EntityID=${props.entityId}`}
|
||||
>
|
||||
<span className="metadatabox--title--source">
|
||||
<Chip label={`@${props.source_file}`} />
|
||||
</span>
|
||||
<InputTextView
|
||||
className="title"
|
||||
placeholder="Title"
|
||||
|
||||
@@ -68,6 +68,9 @@ const story = makeStory({
|
||||
tags: {},
|
||||
entityId: "automation." + id,
|
||||
state: "on",
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
},
|
||||
]);
|
||||
setSelAutoId(id);
|
||||
@@ -94,6 +97,9 @@ const makeAuto = (
|
||||
description: "",
|
||||
state: "on",
|
||||
tags: {},
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
...data,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -40,6 +40,9 @@ const automations: AutomationManagerAuto[] = [
|
||||
tags: a.tags,
|
||||
id: a.id,
|
||||
isSelected: false,
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
}));
|
||||
|
||||
const bigList = bigMockAutoList.map<AutomationManagerAuto>((a) => ({
|
||||
@@ -50,6 +53,9 @@ const bigList = bigMockAutoList.map<AutomationManagerAuto>((a) => ({
|
||||
tags: a.tags,
|
||||
id: a.id,
|
||||
isSelected: false,
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
}));
|
||||
|
||||
test("no grouping", () => {
|
||||
|
||||
@@ -154,6 +154,9 @@ export const BadAutomation = make({
|
||||
mode: "single",
|
||||
alias: "Light.Tank_Day",
|
||||
description: "",
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
trigger: [
|
||||
{
|
||||
platform: "sun",
|
||||
|
||||
@@ -60,7 +60,7 @@ export const AutomationManager: FC<AutomationManagerProps> = ({
|
||||
const invalidAutomations = configAutomationsValidated.filter(
|
||||
({ failures }) => failures !== null
|
||||
);
|
||||
if (invalidAutomations.length > 0) {
|
||||
if (invalidAutomations.length > 0 && !validationsShown.current) {
|
||||
validationsShown.current = true;
|
||||
confirm({
|
||||
cancellationButtonProps: {
|
||||
@@ -102,7 +102,7 @@ export const AutomationManager: FC<AutomationManagerProps> = ({
|
||||
.catch(console.error);
|
||||
}
|
||||
}
|
||||
}, [api.state.automations, validationsShown.current]);
|
||||
}, [api.state.automations, confirm]);
|
||||
|
||||
// handle bad states
|
||||
if (!haEntities.ready && haEntities.error) {
|
||||
|
||||
@@ -9,6 +9,9 @@ export type AutomationManagerAuto = AutomationManagerAutoUpdatable & {
|
||||
tags: Record<string, string>;
|
||||
issue?: string;
|
||||
isNew?: boolean;
|
||||
source_file: string;
|
||||
source_file_type: string;
|
||||
configuration_key: string;
|
||||
};
|
||||
export type AutomationManagerAutoItem = AutomationManagerAuto & {
|
||||
flags: AutomationManagerItemFlags;
|
||||
|
||||
@@ -8,8 +8,13 @@ export const AutomationData = st.object({
|
||||
st.nullable(st.record(st.string(), st.string()))
|
||||
),
|
||||
mode: st.enums(["single", "restart", "queued", "parallel"]),
|
||||
tags: st.record(st.string(), st.string()),
|
||||
|
||||
source_file: st.string(),
|
||||
source_file_type: st.string(),
|
||||
configuration_key: st.string(),
|
||||
|
||||
trigger: st.array(st.object()),
|
||||
condition: st.array(st.object()),
|
||||
action: st.array(st.object()),
|
||||
tags: st.record(st.string(), st.string()),
|
||||
});
|
||||
@@ -1,10 +1,14 @@
|
||||
import * as st from 'superstruct'
|
||||
|
||||
import * as st from "superstruct";
|
||||
|
||||
export const AutomationMetadata = st.object({
|
||||
id: st.string(),
|
||||
alias: st.optional(st.string()),
|
||||
description: st.optional(st.string()),
|
||||
trigger_variables: st.optional(st.nullable(st.record(st.string(), st.string()))),
|
||||
mode: st.enums(["single", "restart", "queued", "parallel"]),
|
||||
})
|
||||
id: st.string(),
|
||||
alias: st.optional(st.string()),
|
||||
description: st.optional(st.string()),
|
||||
trigger_variables: st.optional(
|
||||
st.nullable(st.record(st.string(), st.string()))
|
||||
),
|
||||
mode: st.enums(["single", "restart", "queued", "parallel"]),
|
||||
source_file: st.string(),
|
||||
source_file_type: st.string(),
|
||||
configuration_key: st.string(),
|
||||
});
|
||||
@@ -67,6 +67,9 @@ export const defaultAutomation = (id: string): AutomationData => ({
|
||||
alias: "New Automation",
|
||||
description: "",
|
||||
mode: "single",
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
tags: {},
|
||||
trigger: [],
|
||||
action: [],
|
||||
|
||||
@@ -16,6 +16,9 @@ export const createMockAuto = ({
|
||||
mode: "single",
|
||||
tags,
|
||||
condition: [],
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
trigger: [
|
||||
{
|
||||
platform: "numeric_state",
|
||||
@@ -82,6 +85,9 @@ export const bigMockAutoList: AutomationData[] = [
|
||||
description: "",
|
||||
trigger_variables: null,
|
||||
mode: "single",
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
trigger: [
|
||||
{
|
||||
device_id: "asdasdasdas",
|
||||
@@ -231,6 +237,9 @@ export const bigMockAutoList: AutomationData[] = [
|
||||
description: "",
|
||||
trigger_variables: null,
|
||||
mode: "single",
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
trigger: [
|
||||
{
|
||||
platform: "device",
|
||||
@@ -271,6 +280,9 @@ export const bigMockAutoList: AutomationData[] = [
|
||||
"Ensures that the climate is always in sync with the house settings",
|
||||
trigger_variables: null,
|
||||
mode: "single",
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
trigger: [
|
||||
{
|
||||
platform: "state",
|
||||
@@ -403,6 +415,9 @@ export const bigMockAutoList: AutomationData[] = [
|
||||
description: "Configures max/min light settings for the baby ",
|
||||
trigger_variables: null,
|
||||
mode: "single",
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
trigger: [
|
||||
{
|
||||
platform: "time",
|
||||
@@ -463,6 +478,9 @@ export const bigMockAutoList: AutomationData[] = [
|
||||
id: "alarmanlage_an",
|
||||
alias: "alarmanlage_an (Uhrzeit)",
|
||||
mode: "single",
|
||||
source_file: "automation.yaml",
|
||||
source_file_type: "list",
|
||||
configuration_key: "automation",
|
||||
tags: {},
|
||||
trigger: [
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user