mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 10:46:35 +00:00

* Fix eslint import extension * Update eslint hound * Enable no unresolved for normal usage
63 lines
1.6 KiB
JavaScript
63 lines
1.6 KiB
JavaScript
import { h, Component } from 'preact';
|
|
|
|
import Script from '../common/component/script/index.js';
|
|
|
|
export default class ScriptEditor extends Component {
|
|
constructor() {
|
|
super();
|
|
|
|
this.onChange = this.onChange.bind(this);
|
|
this.sequenceChanged = this.sequenceChanged.bind(this);
|
|
}
|
|
|
|
onChange(ev) {
|
|
this.props.onChange({
|
|
...this.props.script,
|
|
[ev.target.name]: ev.target.value,
|
|
});
|
|
}
|
|
|
|
sequenceChanged(sequence) {
|
|
this.props.onChange({
|
|
...this.props.script,
|
|
sequence,
|
|
});
|
|
}
|
|
|
|
render({ script, isWide }) {
|
|
const { alias, sequence } = script;
|
|
|
|
return (
|
|
<div>
|
|
<ha-config-section is-wide={isWide}>
|
|
<span slot='header'>{alias}</span>
|
|
<span slot='introduction'>
|
|
Use scripts to execute a sequence of actions.
|
|
</span>
|
|
<paper-card>
|
|
<div class='card-content'>
|
|
<paper-input
|
|
label="Name"
|
|
name="alias"
|
|
value={alias}
|
|
onChange={this.onChange}
|
|
/>
|
|
</div>
|
|
</paper-card>
|
|
</ha-config-section>
|
|
|
|
<ha-config-section is-wide={isWide}>
|
|
<span slot='header'>Sequence</span>
|
|
<span slot='introduction'>
|
|
The sequence of actions of this script.
|
|
<p><a href="https://home-assistant.io/docs/scripts/" target="_blank">
|
|
Learn more about available actions.
|
|
</a></p>
|
|
</span>
|
|
<Script script={sequence} onChange={this.sequenceChanged} />
|
|
</ha-config-section>
|
|
</div>
|
|
);
|
|
}
|
|
}
|