delete auto
This commit is contained in:
1 parent
3f0430ab37
commit
473684efa6
4 files changed
+32
-4
No files matched your search
@@ -10,10 +10,12 @@ import {
|
||||
} from "./state";
|
||||
import Alert from "@mui/material/Alert";
|
||||
|
||||
export type AutomationManagerLoadedProps = UseAutomationManagerStateArgs & {};
|
||||
export type AutomationManagerLoadedProps = UseAutomationManagerStateArgs & {
|
||||
onAutomationDelete: (aid: string) => void;
|
||||
};
|
||||
export const AutomationManagerLoaded: FC<
|
||||
PropsWithChildren<AutomationManagerLoadedProps>
|
||||
> = ({ children, ...args }) => {
|
||||
> = ({ children, onAutomationDelete, ...args }) => {
|
||||
const state = useAutomationManagerState(args);
|
||||
|
||||
return (
|
||||
@@ -25,7 +27,7 @@ export const AutomationManagerLoaded: FC<
|
||||
selectedAutomationId={state.currentAutomationId}
|
||||
onSelectedAutomationId={state.setSelectedAutomationId}
|
||||
onAutomationAdd={() => state.addNew()}
|
||||
onAutomationDelete={() => {}}
|
||||
onAutomationDelete={onAutomationDelete}
|
||||
onAutomationUpdate={() => {}}
|
||||
/>
|
||||
<div className={["automation-manager--editor"].join(" ")}>
|
||||
|
||||
@@ -10,7 +10,6 @@ export type UseAutomationManagerStateArgs = {
|
||||
configAutomations: AutomationData[];
|
||||
hassEntities: HassEntities;
|
||||
onUpdateTags: (aid: string, tags: Record<string, string>) => void;
|
||||
// onAutomationDelete: (aid: string) => void;
|
||||
onAutomationAdd: (auto: AutomationData) => void;
|
||||
};
|
||||
export const useAutomationManagerState = ({
|
||||
|
||||
@@ -71,3 +71,23 @@ export const One = make({
|
||||
entitySource: {},
|
||||
},
|
||||
});
|
||||
export const MissingAutoInConfig = make({
|
||||
automations: [],
|
||||
haProps: {
|
||||
loading: false,
|
||||
entities: {
|
||||
[`automation.${auto1.metadata.id}`]: {
|
||||
entity_id: `automation.${auto1.metadata.id}`,
|
||||
attributes: {
|
||||
id: auto1.metadata.id,
|
||||
friendly_name: auto1.metadata.alias,
|
||||
},
|
||||
context: { id: "", parent_id: null, user_id: null },
|
||||
last_changed: "",
|
||||
last_updated: "",
|
||||
state: "on",
|
||||
},
|
||||
},
|
||||
entitySource: {},
|
||||
},
|
||||
});
|
||||
@@ -59,6 +59,13 @@ export const AutomationManager: FC<AutomationManagerProps> = ({
|
||||
auto,
|
||||
})
|
||||
}
|
||||
onAutomationDelete={(aid) =>
|
||||
api.removeAutomation({
|
||||
index: configAutomations.data.findIndex(
|
||||
({ metadata }) => metadata.id === aid
|
||||
),
|
||||
})
|
||||
}
|
||||
onUpdateTags={async (aid, t) => {
|
||||
setIsSaving(true);
|
||||
await api.updateTags({
|
||||
|
||||
Reference in new issue
Block a user