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

feat(DeviceSettings): info alert with a link to the documentation #2020

Merged
merged 10 commits into from
May 17, 2024
16 changes: 16 additions & 0 deletions src/components/ReadTheDocsInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';

export const ReadTheDocsInfo = (props: { docsUrl: string }): JSX.Element => {
const { docsUrl } = props;
return (
<div className="card alert alert-info" role="alert">
<div className="card-body">
<i className="fa-solid fa-circle-info fa-2xl me-2"></i>

<a href={docsUrl} target="_blank" rel="noreferrer" className="alert-link align-middle">
Read about this in the documentation…
MacDada marked this conversation as resolved.
Show resolved Hide resolved
</a>
</div>
</div>
);
};
23 changes: 15 additions & 8 deletions src/components/device-page/DeviceSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ISubmitEvent, UiSchema } from '@rjsf/core';
import { DescriptionField, TitleField } from '../../i18n/rjsf-translation-fields';
import merge from 'lodash/merge';
import { DeviceSettingsProps, DeviceSettingsState, Form, ParamValue } from './settings';
import { ReadTheDocsInfo } from '../ReadTheDocsInfo';

const genericUiSchema: UiSchema = {
'ui:order': ['friendly_name', 'disabled', 'retain', 'retention', 'qos', 'filtered_attributes', '*'],
Expand Down Expand Up @@ -54,14 +55,20 @@ export class DeviceSettings extends Component<DeviceSettingsProps, DeviceSetting
render(): ReactNode {
const { schema, data, uiSchema } = this.getSchemaAndConfig();
return (
<Form
schema={schema}
formData={data}
onSubmit={this.updateConfig}
onChange={this.onFormChange}
uiSchema={uiSchema}
fields={{ TitleField, DescriptionField }}
/>
<>
<ReadTheDocsInfo
docsUrl={'https://www.zigbee2mqtt.io/guide/configuration/devices-groups.html#common-device-options'}
/>

<Form
schema={schema}
formData={data}
onSubmit={this.updateConfig}
onChange={this.onFormChange}
uiSchema={uiSchema}
fields={{ TitleField, DescriptionField }}
/>
</>
);
}
}