@iobroker/json-config 8.4.7 → 8.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/README.md +19 -4
  2. package/build/JsonConfig.js +7 -7
  3. package/build/JsonConfig.js.map +1 -1
  4. package/build/JsonConfigComponent/ConfigAccordion.js +9 -9
  5. package/build/JsonConfigComponent/ConfigAccordion.js.map +1 -1
  6. package/build/JsonConfigComponent/ConfigAlive.js +2 -2
  7. package/build/JsonConfigComponent/ConfigAlive.js.map +1 -1
  8. package/build/JsonConfigComponent/ConfigAutocomplete.js +11 -2
  9. package/build/JsonConfigComponent/ConfigAutocomplete.js.map +1 -1
  10. package/build/JsonConfigComponent/ConfigAutocompleteSendTo.js +10 -3
  11. package/build/JsonConfigComponent/ConfigAutocompleteSendTo.js.map +1 -1
  12. package/build/JsonConfigComponent/ConfigCRON.js +1 -1
  13. package/build/JsonConfigComponent/ConfigCRON.js.map +1 -1
  14. package/build/JsonConfigComponent/ConfigCertCollection.js +2 -2
  15. package/build/JsonConfigComponent/ConfigCertCollection.js.map +1 -1
  16. package/build/JsonConfigComponent/ConfigCertificates.js +6 -6
  17. package/build/JsonConfigComponent/ConfigCertificates.js.map +1 -1
  18. package/build/JsonConfigComponent/ConfigCheckDocker.js +4 -4
  19. package/build/JsonConfigComponent/ConfigCheckDocker.js.map +1 -1
  20. package/build/JsonConfigComponent/ConfigCheckLicense.js +31 -31
  21. package/build/JsonConfigComponent/ConfigCheckLicense.js.map +1 -1
  22. package/build/JsonConfigComponent/ConfigCheckbox.js +1 -1
  23. package/build/JsonConfigComponent/ConfigCheckbox.js.map +1 -1
  24. package/build/JsonConfigComponent/ConfigChip.js +1 -1
  25. package/build/JsonConfigComponent/ConfigChip.js.map +1 -1
  26. package/build/JsonConfigComponent/ConfigCoordinates.js +7 -7
  27. package/build/JsonConfigComponent/ConfigCoordinates.js.map +1 -1
  28. package/build/JsonConfigComponent/ConfigCredentialSelect.d.ts +24 -0
  29. package/build/JsonConfigComponent/ConfigCredentialSelect.js +210 -11
  30. package/build/JsonConfigComponent/ConfigCredentialSelect.js.map +1 -1
  31. package/build/JsonConfigComponent/ConfigFileSelector.js +6 -6
  32. package/build/JsonConfigComponent/ConfigFileSelector.js.map +1 -1
  33. package/build/JsonConfigComponent/ConfigGeneric.js +6 -6
  34. package/build/JsonConfigComponent/ConfigGeneric.js.map +1 -1
  35. package/build/JsonConfigComponent/ConfigIFrameSendTo.js +1 -1
  36. package/build/JsonConfigComponent/ConfigIFrameSendTo.js.map +1 -1
  37. package/build/JsonConfigComponent/ConfigIP.js +2 -2
  38. package/build/JsonConfigComponent/ConfigIP.js.map +1 -1
  39. package/build/JsonConfigComponent/ConfigImageSendTo.js +2 -2
  40. package/build/JsonConfigComponent/ConfigImageSendTo.js.map +1 -1
  41. package/build/JsonConfigComponent/ConfigJsonEditor.js +2 -2
  42. package/build/JsonConfigComponent/ConfigJsonEditor.js.map +1 -1
  43. package/build/JsonConfigComponent/ConfigLanguage.js +2 -2
  44. package/build/JsonConfigComponent/ConfigLanguage.js.map +1 -1
  45. package/build/JsonConfigComponent/ConfigLicense.js +3 -3
  46. package/build/JsonConfigComponent/ConfigLicense.js.map +1 -1
  47. package/build/JsonConfigComponent/ConfigNumber.js +5 -5
  48. package/build/JsonConfigComponent/ConfigNumber.js.map +1 -1
  49. package/build/JsonConfigComponent/ConfigOAuth2.js +9 -9
  50. package/build/JsonConfigComponent/ConfigOAuth2.js.map +1 -1
  51. package/build/JsonConfigComponent/ConfigPassword.js +4 -4
  52. package/build/JsonConfigComponent/ConfigPassword.js.map +1 -1
  53. package/build/JsonConfigComponent/ConfigPattern.js +1 -1
  54. package/build/JsonConfigComponent/ConfigPattern.js.map +1 -1
  55. package/build/JsonConfigComponent/ConfigPort.js +7 -7
  56. package/build/JsonConfigComponent/ConfigPort.js.map +1 -1
  57. package/build/JsonConfigComponent/ConfigQrCodeSendTo.js +3 -3
  58. package/build/JsonConfigComponent/ConfigQrCodeSendTo.js.map +1 -1
  59. package/build/JsonConfigComponent/ConfigSelectSendTo.js +2 -2
  60. package/build/JsonConfigComponent/ConfigSelectSendTo.js.map +1 -1
  61. package/build/JsonConfigComponent/ConfigSendto.js +10 -10
  62. package/build/JsonConfigComponent/ConfigSendto.js.map +1 -1
  63. package/build/JsonConfigComponent/ConfigSetState.js +2 -2
  64. package/build/JsonConfigComponent/ConfigSetState.js.map +1 -1
  65. package/build/JsonConfigComponent/ConfigState.js +1 -1
  66. package/build/JsonConfigComponent/ConfigState.js.map +1 -1
  67. package/build/JsonConfigComponent/ConfigStaticImage.js +2 -2
  68. package/build/JsonConfigComponent/ConfigStaticImage.js.map +1 -1
  69. package/build/JsonConfigComponent/ConfigStaticInfo.js +1 -1
  70. package/build/JsonConfigComponent/ConfigStaticInfo.js.map +1 -1
  71. package/build/JsonConfigComponent/ConfigTable.js +33 -33
  72. package/build/JsonConfigComponent/ConfigTable.js.map +1 -1
  73. package/build/JsonConfigComponent/ConfigText.js +3 -3
  74. package/build/JsonConfigComponent/ConfigText.js.map +1 -1
  75. package/build/JsonConfigComponent/ConfigTextSendTo.js +2 -2
  76. package/build/JsonConfigComponent/ConfigTextSendTo.js.map +1 -1
  77. package/build/JsonConfigComponent/ConfigUUID.js +2 -2
  78. package/build/JsonConfigComponent/ConfigUUID.js.map +1 -1
  79. package/build/JsonConfigComponent/ConfigYamlEditor.js +2 -2
  80. package/build/JsonConfigComponent/ConfigYamlEditor.js.map +1 -1
  81. package/build/JsonConfigComponent/i18n/de.json +116 -0
  82. package/build/JsonConfigComponent/i18n/en.json +136 -0
  83. package/build/JsonConfigComponent/i18n/es.json +116 -0
  84. package/build/JsonConfigComponent/i18n/fr.json +116 -0
  85. package/build/JsonConfigComponent/i18n/it.json +116 -0
  86. package/build/JsonConfigComponent/i18n/nl.json +116 -0
  87. package/build/JsonConfigComponent/i18n/pl.json +116 -0
  88. package/build/JsonConfigComponent/i18n/pt.json +116 -0
  89. package/build/JsonConfigComponent/i18n/ru.json +116 -0
  90. package/build/JsonConfigComponent/i18n/uk.json +116 -0
  91. package/build/JsonConfigComponent/i18n/zh-cn.json +116 -0
  92. package/build/JsonConfigComponent/index.d.ts +1 -0
  93. package/build/JsonConfigComponent/index.js +28 -0
  94. package/build/JsonConfigComponent/index.js.map +1 -1
  95. package/build/JsonConfigComponent/wrapper/Components/CustomModal.js +3 -3
  96. package/build/JsonConfigComponent/wrapper/Components/CustomModal.js.map +1 -1
  97. package/build/types.d.ts +2 -0
  98. package/package.json +13 -9
@@ -52,7 +52,7 @@ class ConfigCoordinates extends ConfigGeneric {
52
52
  console.error(`Cannot get system configuration: ${e}`);
53
53
  }
54
54
  if (systemConfig?.common && (systemConfig.common.longitude || systemConfig.common.latitude)) {
55
- window.alert(I18n.t('ra_Used system settings'));
55
+ window.alert(I18n.t('jc_Used system settings'));
56
56
  if (this.props.schema.longitudeName && this.props.schema.latitudeName) {
57
57
  this.setState({
58
58
  longitude: systemConfig.common.longitude,
@@ -75,7 +75,7 @@ class ConfigCoordinates extends ConfigGeneric {
75
75
  }
76
76
  }
77
77
  else {
78
- window.alert(I18n.t('ra_Cannot determine position: System settings are empty and GPS detection is disabled in browser'));
78
+ window.alert(I18n.t('jc_Cannot determine position: System settings are empty and GPS detection is disabled in browser'));
79
79
  }
80
80
  }
81
81
  getCoordinates() {
@@ -125,7 +125,7 @@ class ConfigCoordinates extends ConfigGeneric {
125
125
  void this.getSystemCoordinates().catch(e => console.error(`Cannot determine coordinates: ${e}`));
126
126
  }
127
127
  this.setState({ useSystem }, () => this.onChange(this.props.schema.useSystemName, useSystem));
128
- } }), label: I18n.t('ra_Use system settings for position') })) : null,
128
+ } }), label: I18n.t('jc_Use system settings for position') })) : null,
129
129
  this.props.schema.longitudeName && this.props.schema.latitudeName ? (React.createElement(TextField, { variant: "standard", style: styles.width50, value: this.state.longitude ?? '', error: !!error, disabled: this.state.useSystem || !!disabled, onChange: e => {
130
130
  const longitude = e.target.value;
131
131
  this.setState({ longitude }, () => {
@@ -134,11 +134,11 @@ class ConfigCoordinates extends ConfigGeneric {
134
134
  mayBePromise.catch(e => console.error(`Cannot set value: ${e}`));
135
135
  }
136
136
  });
137
- }, label: I18n.t('ra_Longitude') })) : null,
137
+ }, label: I18n.t('jc_Longitude') })) : null,
138
138
  this.props.schema.longitudeName && this.props.schema.latitudeName ? (React.createElement(TextField, { variant: "standard", style: styles.width50, value: this.state.latitude ?? '', error: !!error, disabled: this.state.useSystem || !!disabled, onChange: e => {
139
139
  const latitude = e.target.value;
140
140
  this.setState({ latitude }, () => this.onChange(this.props.schema.latitudeName, (latitude || '').trim()));
141
- }, label: I18n.t('ra_Latitude') })) : null,
141
+ }, label: I18n.t('jc_Latitude') })) : null,
142
142
  !this.props.schema.longitudeName || !this.props.schema.latitudeName ? (React.createElement(TextField, { variant: "standard", style: styles.width, value: this.state.value ?? '', error: !!error, disabled: !!disabled, slotProps: {
143
143
  htmlInput: {
144
144
  maxLength: this.props.schema.maxLength || this.props.schema.max || undefined,
@@ -148,9 +148,9 @@ class ConfigCoordinates extends ConfigGeneric {
148
148
  const value = e.target.value;
149
149
  this.setState({ value }, () => this.onChange(this.props.attr, (value || '').trim()));
150
150
  }, placeholder: this.getText(this.props.schema.placeholder), label: this.getText(this.props.schema.label), helperText: this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation) })) : null,
151
- !this.state.useSystem ? (React.createElement(Fab, { size: "small", onClick: () => this.getCoordinates(), title: I18n.t('ra_Take browser position'), style: { marginRight: 4 } },
151
+ !this.state.useSystem ? (React.createElement(Fab, { size: "small", onClick: () => this.getCoordinates(), title: I18n.t('jc_Take browser position'), style: { marginRight: 4 } },
152
152
  React.createElement(IconLocationOn, null))) : null,
153
- !this.state.useSystem ? (React.createElement(Fab, { size: "small", onClick: () => this.getSystemCoordinates(), title: I18n.t('ra_Take position from system settings') },
153
+ !this.state.useSystem ? (React.createElement(Fab, { size: "small", onClick: () => this.getSystemCoordinates(), title: I18n.t('jc_Take position from system settings') },
154
154
  React.createElement(IconGpsFixed, null))) : null));
155
155
  }
156
156
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigCoordinates.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigCoordinates.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE3E,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE7F,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGlD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,MAAM,MAAM,GAAwC;IAChD,KAAK,EAAE;QACH,KAAK,EAAE,mBAAmB;KAC7B;IACD,OAAO,EAAE;QACL,KAAK,EAAE,GAAG;QACV,WAAW,EAAE,CAAC;KACjB;CACJ,CAAC;AAYF,MAAM,iBAAkB,SAAQ,aAA6D;IACzF,KAAK,CAAC,iBAAiB;QACnB,MAAM,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAEhC,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACvE,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAEzB,MAAM,QAAQ,GAAoC,EAAE,CAAC;QACrD,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;YAClC,QAAQ,CAAC,SAAS,GAAG,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QACpG,CAAC;QACD,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AU,CACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,GACH,CACL,CAAC,CAAC,CAAC,IAAI;YACP,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CACrB,oBAAC,GAAG,IACA,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,EACpC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,0BAA0B,CAAC,EACzC,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE;gBAEzB,oBAAC,cAAc,OAAG,CAChB,CACT,CAAC,CAAC,CAAC,IAAI;YACP,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CACrB,oBAAC,GAAG,IACA,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAC1C,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,uCAAuC,CAAC;gBAEtD,oBAAC,YAAY,OAAG,CACd,CACT,CAAC,CAAC,CAAC,IAAI,CACT,CACN,CAAC;IACN,CAAC;CACJ;AAED,eAAe,iBAAiB,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { TextField, Fab, FormControlLabel, Checkbox } from '@mui/material';\n\nimport { GpsFixed as IconGpsFixed, LocationOn as IconLocationOn } from '@mui/icons-material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemCoordinates } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, React.CSSProperties> = {\n width: {\n width: 'calc(100% - 85px)',\n },\n width50: {\n width: 120,\n marginRight: 5,\n },\n};\n\ninterface ConfigCoordinatesProps extends ConfigGenericProps {\n schema: ConfigItemCoordinates;\n}\n\ninterface ConfigCoordinatesState extends ConfigGenericState {\n useSystem?: boolean;\n longitude?: string | number;\n latitude?: string | number;\n}\n\nclass ConfigCoordinates extends ConfigGeneric<ConfigCoordinatesProps, ConfigCoordinatesState> {\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n this.setState({ value });\n\n const newState: Partial<ConfigCoordinatesState> = {};\n if (this.props.schema.useSystemName) {\n newState.useSystem = !!ConfigGeneric.getValue(this.props.data, this.props.schema.useSystemName);\n }\n if (this.props.schema.longitudeName && this.props.schema.latitudeName) {\n newState.longitude = ConfigGeneric.getValue(this.props.data, this.props.schema.longitudeName);\n newState.latitude = ConfigGeneric.getValue(this.props.data, this.props.schema.latitudeName);\n if (!newState.longitude && !newState.latitude && this.props.schema.autoInit) {\n setTimeout(() => this.getCoordinates(), 300);\n }\n } else {\n const value_ = ConfigGeneric.getValue(this.props.data, this.props.attr);\n if (!value_ && this.props.schema.autoInit) {\n setTimeout(() => this.getCoordinates(), 300);\n }\n }\n if (Object.keys(newState).length) {\n setTimeout(() => this.setState(newState as ConfigCoordinatesState), 50);\n }\n }\n\n async getSystemCoordinates(): Promise<void> {\n let systemConfig: ioBroker.SystemConfigObject | undefined;\n try {\n if (this.props.oContext.socket.getCompactSystemConfig) {\n systemConfig = await this.props.oContext.socket.getCompactSystemConfig();\n } else {\n systemConfig = (await this.getCachedObject('system.config')) as ioBroker.SystemConfigObject | undefined;\n }\n } catch (e) {\n console.error(`Cannot get system configuration: ${e}`);\n }\n if (systemConfig?.common && (systemConfig.common.longitude || systemConfig.common.latitude)) {\n window.alert(I18n.t('ra_Used system settings'));\n if (this.props.schema.longitudeName && this.props.schema.latitudeName) {\n this.setState(\n {\n longitude: systemConfig.common.longitude,\n latitude: systemConfig.common.latitude,\n },\n async () => {\n await this.onChange(this.props.schema.longitudeName, systemConfig.common.longitude);\n await this.onChange(this.props.schema.latitudeName, systemConfig.common.latitude);\n },\n );\n } else {\n const value =\n systemConfig.common.latitude + (this.props.schema.divider || ',') + systemConfig.common.longitude;\n this.setState(\n {\n value,\n },\n () => {\n const mayByPromise = this.onChange(this.props.attr, value);\n if (mayByPromise instanceof Promise) {\n mayByPromise.catch(e => console.error(`Cannot set value: ${e}`));\n }\n },\n );\n }\n } else {\n window.alert(\n I18n.t(\n 'ra_Cannot determine position: System settings are empty and GPS detection is disabled in browser',\n ),\n );\n }\n }\n\n getCoordinates(): void {\n if (navigator.geolocation) {\n navigator.geolocation.getCurrentPosition(\n async (position: GeolocationPosition): Promise<void> => {\n if (position?.coords) {\n if (this.props.schema.longitudeName && this.props.schema.latitudeName) {\n this.setState(\n {\n longitude: position.coords.longitude,\n latitude: position.coords.latitude,\n },\n async () => {\n await this.onChange(\n this.props.schema.longitudeName,\n position.coords.longitude || '',\n );\n await this.onChange(this.props.schema.latitudeName, position.coords.latitude || '');\n },\n );\n } else {\n const value =\n position.coords.latitude +\n (this.props.schema.divider || ',') +\n position.coords.longitude;\n this.setState({ value }, () => {\n const mayByPromise = this.onChange(this.props.attr, value);\n if (mayByPromise instanceof Promise) {\n mayByPromise.catch(e => console.error(`Cannot set value: ${e}`));\n }\n });\n }\n } else {\n await this.getSystemCoordinates();\n }\n },\n async (error: GeolocationPositionError): Promise<void> => {\n console.error(`Cannot determine coordinates from browser: ${error.message}`);\n await this.getSystemCoordinates();\n },\n );\n } else {\n void this.getSystemCoordinates().catch(e => {\n console.error(`Cannot determine coordinates: ${e}`);\n });\n }\n }\n\n renderItem(error: string, disabled: boolean /* , defaultValue */): JSX.Element {\n return (\n <>\n {this.props.schema.useSystemName ? (\n <FormControlLabel\n control={\n <Checkbox\n checked={!!this.state.useSystem}\n onChange={e => {\n const useSystem = e.target.checked;\n if (useSystem) {\n void this.getSystemCoordinates().catch(e =>\n console.error(`Cannot determine coordinates: ${e}`),\n );\n }\n this.setState({ useSystem }, () =>\n this.onChange(this.props.schema.useSystemName, useSystem),\n );\n }}\n />\n }\n label={I18n.t('ra_Use system settings for position')}\n />\n ) : null}\n {this.props.schema.longitudeName && this.props.schema.latitudeName ? (\n <TextField\n variant=\"standard\"\n style={styles.width50}\n value={this.state.longitude ?? ''}\n error={!!error}\n disabled={this.state.useSystem || !!disabled}\n onChange={e => {\n const longitude = e.target.value;\n this.setState({ longitude }, () => {\n const mayBePromise = this.onChange(\n this.props.schema.longitudeName,\n (longitude || '').trim(),\n );\n if (mayBePromise instanceof Promise) {\n mayBePromise.catch(e => console.error(`Cannot set value: ${e}`));\n }\n });\n }}\n label={I18n.t('ra_Longitude')}\n />\n ) : null}\n {this.props.schema.longitudeName && this.props.schema.latitudeName ? (\n <TextField\n variant=\"standard\"\n style={styles.width50}\n value={this.state.latitude ?? ''}\n error={!!error}\n disabled={this.state.useSystem || !!disabled}\n onChange={e => {\n const latitude = e.target.value;\n this.setState({ latitude }, () =>\n this.onChange(this.props.schema.latitudeName, (latitude || '').trim()),\n );\n }}\n label={I18n.t('ra_Latitude')}\n />\n ) : null}\n {!this.props.schema.longitudeName || !this.props.schema.latitudeName ? (\n <TextField\n variant=\"standard\"\n style={styles.width}\n value={this.state.value ?? ''}\n error={!!error}\n disabled={!!disabled}\n slotProps={{\n htmlInput: {\n maxLength: this.props.schema.maxLength || this.props.schema.max || undefined,\n readOnly: this.state.useSystem,\n },\n }}\n onChange={e => {\n const value = e.target.value;\n this.setState({ value }, () => this.onChange(this.props.attr, (value || '').trim()));\n }}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n />\n ) : null}\n {!this.state.useSystem ? (\n <Fab\n size=\"small\"\n onClick={() => this.getCoordinates()}\n title={I18n.t('ra_Take browser position')}\n style={{ marginRight: 4 }}\n >\n <IconLocationOn />\n </Fab>\n ) : null}\n {!this.state.useSystem ? (\n <Fab\n size=\"small\"\n onClick={() => this.getSystemCoordinates()}\n title={I18n.t('ra_Take position from system settings')}\n >\n <IconGpsFixed />\n </Fab>\n ) : null}\n </>\n );\n }\n}\n\nexport default ConfigCoordinates;\n"]}
1
+ {"version":3,"file":"ConfigCoordinates.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigCoordinates.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE3E,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE7F,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGlD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,MAAM,MAAM,GAAwC;IAChD,KAAK,EAAE;QACH,KAAK,EAAE,mBAAmB;KAC7B;IACD,OAAO,EAAE;QACL,KAAK,EAAE,GAAG;QACV,WAAW,EAAE,CAAC;KACjB;CACJ,CAAC;AAYF,MAAM,iBAAkB,SAAQ,aAA6D;IACzF,KAAK,CAAC,iBAAiB;QACnB,MAAM,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAEhC,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACvE,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAEzB,MAAM,QAAQ,GAAoC,EAAE,CAAC;QACrD,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;YAClC,QAAQ,CAAC,SAAS,GAAG,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CA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UAAU,EAAE,IAAI,CAAC,UAAU,CACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,GACH,CACL,CAAC,CAAC,CAAC,IAAI;YACP,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CACrB,oBAAC,GAAG,IACA,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,EACpC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,0BAA0B,CAAC,EACzC,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE;gBAEzB,oBAAC,cAAc,OAAG,CAChB,CACT,CAAC,CAAC,CAAC,IAAI;YACP,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CACrB,oBAAC,GAAG,IACA,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAC1C,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,uCAAuC,CAAC;gBAEtD,oBAAC,YAAY,OAAG,CACd,CACT,CAAC,CAAC,CAAC,IAAI,CACT,CACN,CAAC;IACN,CAAC;CACJ;AAED,eAAe,iBAAiB,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { TextField, Fab, FormControlLabel, Checkbox } from '@mui/material';\n\nimport { GpsFixed as IconGpsFixed, LocationOn as IconLocationOn } from '@mui/icons-material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemCoordinates } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, React.CSSProperties> = {\n width: {\n width: 'calc(100% - 85px)',\n },\n width50: {\n width: 120,\n marginRight: 5,\n },\n};\n\ninterface ConfigCoordinatesProps extends ConfigGenericProps {\n schema: ConfigItemCoordinates;\n}\n\ninterface ConfigCoordinatesState extends ConfigGenericState {\n useSystem?: boolean;\n longitude?: string | number;\n latitude?: string | number;\n}\n\nclass ConfigCoordinates extends ConfigGeneric<ConfigCoordinatesProps, ConfigCoordinatesState> {\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n this.setState({ value });\n\n const newState: Partial<ConfigCoordinatesState> = {};\n if (this.props.schema.useSystemName) {\n newState.useSystem = !!ConfigGeneric.getValue(this.props.data, this.props.schema.useSystemName);\n }\n if (this.props.schema.longitudeName && this.props.schema.latitudeName) {\n newState.longitude = ConfigGeneric.getValue(this.props.data, this.props.schema.longitudeName);\n newState.latitude = ConfigGeneric.getValue(this.props.data, this.props.schema.latitudeName);\n if (!newState.longitude && !newState.latitude && this.props.schema.autoInit) {\n setTimeout(() => this.getCoordinates(), 300);\n }\n } else {\n const value_ = ConfigGeneric.getValue(this.props.data, this.props.attr);\n if (!value_ && this.props.schema.autoInit) {\n setTimeout(() => this.getCoordinates(), 300);\n }\n }\n if (Object.keys(newState).length) {\n setTimeout(() => this.setState(newState as ConfigCoordinatesState), 50);\n }\n }\n\n async getSystemCoordinates(): Promise<void> {\n let systemConfig: ioBroker.SystemConfigObject | undefined;\n try {\n if (this.props.oContext.socket.getCompactSystemConfig) {\n systemConfig = await this.props.oContext.socket.getCompactSystemConfig();\n } else {\n systemConfig = (await this.getCachedObject('system.config')) as ioBroker.SystemConfigObject | undefined;\n }\n } catch (e) {\n console.error(`Cannot get system configuration: ${e}`);\n }\n if (systemConfig?.common && (systemConfig.common.longitude || systemConfig.common.latitude)) {\n window.alert(I18n.t('jc_Used system settings'));\n if (this.props.schema.longitudeName && this.props.schema.latitudeName) {\n this.setState(\n {\n longitude: systemConfig.common.longitude,\n latitude: systemConfig.common.latitude,\n },\n async () => {\n await this.onChange(this.props.schema.longitudeName, systemConfig.common.longitude);\n await this.onChange(this.props.schema.latitudeName, systemConfig.common.latitude);\n },\n );\n } else {\n const value =\n systemConfig.common.latitude + (this.props.schema.divider || ',') + systemConfig.common.longitude;\n this.setState(\n {\n value,\n },\n () => {\n const mayByPromise = this.onChange(this.props.attr, value);\n if (mayByPromise instanceof Promise) {\n mayByPromise.catch(e => console.error(`Cannot set value: ${e}`));\n }\n },\n );\n }\n } else {\n window.alert(\n I18n.t(\n 'jc_Cannot determine position: System settings are empty and GPS detection is disabled in browser',\n ),\n );\n }\n }\n\n getCoordinates(): void {\n if (navigator.geolocation) {\n navigator.geolocation.getCurrentPosition(\n async (position: GeolocationPosition): Promise<void> => {\n if (position?.coords) {\n if (this.props.schema.longitudeName && this.props.schema.latitudeName) {\n this.setState(\n {\n longitude: position.coords.longitude,\n latitude: position.coords.latitude,\n },\n async () => {\n await this.onChange(\n this.props.schema.longitudeName,\n position.coords.longitude || '',\n );\n await this.onChange(this.props.schema.latitudeName, position.coords.latitude || '');\n },\n );\n } else {\n const value =\n position.coords.latitude +\n (this.props.schema.divider || ',') +\n position.coords.longitude;\n this.setState({ value }, () => {\n const mayByPromise = this.onChange(this.props.attr, value);\n if (mayByPromise instanceof Promise) {\n mayByPromise.catch(e => console.error(`Cannot set value: ${e}`));\n }\n });\n }\n } else {\n await this.getSystemCoordinates();\n }\n },\n async (error: GeolocationPositionError): Promise<void> => {\n console.error(`Cannot determine coordinates from browser: ${error.message}`);\n await this.getSystemCoordinates();\n },\n );\n } else {\n void this.getSystemCoordinates().catch(e => {\n console.error(`Cannot determine coordinates: ${e}`);\n });\n }\n }\n\n renderItem(error: string, disabled: boolean /* , defaultValue */): JSX.Element {\n return (\n <>\n {this.props.schema.useSystemName ? (\n <FormControlLabel\n control={\n <Checkbox\n checked={!!this.state.useSystem}\n onChange={e => {\n const useSystem = e.target.checked;\n if (useSystem) {\n void this.getSystemCoordinates().catch(e =>\n console.error(`Cannot determine coordinates: ${e}`),\n );\n }\n this.setState({ useSystem }, () =>\n this.onChange(this.props.schema.useSystemName, useSystem),\n );\n }}\n />\n }\n label={I18n.t('jc_Use system settings for position')}\n />\n ) : null}\n {this.props.schema.longitudeName && this.props.schema.latitudeName ? (\n <TextField\n variant=\"standard\"\n style={styles.width50}\n value={this.state.longitude ?? ''}\n error={!!error}\n disabled={this.state.useSystem || !!disabled}\n onChange={e => {\n const longitude = e.target.value;\n this.setState({ longitude }, () => {\n const mayBePromise = this.onChange(\n this.props.schema.longitudeName,\n (longitude || '').trim(),\n );\n if (mayBePromise instanceof Promise) {\n mayBePromise.catch(e => console.error(`Cannot set value: ${e}`));\n }\n });\n }}\n label={I18n.t('jc_Longitude')}\n />\n ) : null}\n {this.props.schema.longitudeName && this.props.schema.latitudeName ? (\n <TextField\n variant=\"standard\"\n style={styles.width50}\n value={this.state.latitude ?? ''}\n error={!!error}\n disabled={this.state.useSystem || !!disabled}\n onChange={e => {\n const latitude = e.target.value;\n this.setState({ latitude }, () =>\n this.onChange(this.props.schema.latitudeName, (latitude || '').trim()),\n );\n }}\n label={I18n.t('jc_Latitude')}\n />\n ) : null}\n {!this.props.schema.longitudeName || !this.props.schema.latitudeName ? (\n <TextField\n variant=\"standard\"\n style={styles.width}\n value={this.state.value ?? ''}\n error={!!error}\n disabled={!!disabled}\n slotProps={{\n htmlInput: {\n maxLength: this.props.schema.maxLength || this.props.schema.max || undefined,\n readOnly: this.state.useSystem,\n },\n }}\n onChange={e => {\n const value = e.target.value;\n this.setState({ value }, () => this.onChange(this.props.attr, (value || '').trim()));\n }}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n />\n ) : null}\n {!this.state.useSystem ? (\n <Fab\n size=\"small\"\n onClick={() => this.getCoordinates()}\n title={I18n.t('jc_Take browser position')}\n style={{ marginRight: 4 }}\n >\n <IconLocationOn />\n </Fab>\n ) : null}\n {!this.state.useSystem ? (\n <Fab\n size=\"small\"\n onClick={() => this.getSystemCoordinates()}\n title={I18n.t('jc_Take position from system settings')}\n >\n <IconGpsFixed />\n </Fab>\n ) : null}\n </>\n );\n }\n}\n\nexport default ConfigCoordinates;\n"]}
@@ -1,6 +1,7 @@
1
1
  import { type JSX } from 'react';
2
2
  import type { ConfigItemCredentialSelect } from '../types';
3
3
  import ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';
4
+ type CredentialType = 'email' | 'cloud' | 'ai' | 'custom';
4
5
  interface ConfigCredentialSelectProps extends ConfigGenericProps {
5
6
  schema: ConfigItemCredentialSelect;
6
7
  }
@@ -12,10 +13,33 @@ interface CredentialSelectOption {
12
13
  }
13
14
  interface ConfigCredentialSelectState extends ConfigGenericState {
14
15
  selectOptions?: CredentialSelectOption[];
16
+ /** Whether the "create credential" dialog is open */
17
+ addOpen?: boolean;
18
+ /** Selected template key */
19
+ addTemplate?: string;
20
+ addName?: string;
21
+ addType?: CredentialType;
22
+ addFields?: Record<string, string>;
23
+ addError?: string;
24
+ addSaving?: boolean;
15
25
  }
16
26
  export default class ConfigCredentialSelect extends ConfigGeneric<ConfigCredentialSelectProps, ConfigCredentialSelectState> {
17
27
  componentDidMount(): Promise<void>;
28
+ /**
29
+ * Read the credential objects ("system.credentials.<name>") and turn them into select options,
30
+ * filtered by `schema.credentialType` if set. The "none" option is prepended.
31
+ */
32
+ readCredentials(): Promise<CredentialSelectOption[]>;
18
33
  static getCredentialName(obj: ioBroker.Object): string;
34
+ /** Template keys offered for this field, filtered by `schema.credentialType` (type-agnostic ones always shown). */
35
+ templateKeys(): string[];
36
+ /** Apply a template: it defines the form, the (proposed) name, the category and the icon. */
37
+ selectTemplate(key: string): void;
38
+ /** Open the create dialog, pre-selecting the first template that fits the schema's credentialType. */
39
+ openAddDialog(): void;
40
+ /** Create the credential object, encrypt its secret fields, store it (with icon), then select it. */
41
+ createCredential(): Promise<void>;
42
+ renderAddDialog(): JSX.Element | null;
19
43
  renderItem(error: unknown, disabled: boolean): JSX.Element | null;
20
44
  }
21
45
  export {};
@@ -1,9 +1,63 @@
1
1
  import React from 'react';
2
- import { InputLabel, MenuItem, FormControl, Select, FormHelperText } from '@mui/material';
3
- import { I18n, Icon } from '@iobroker/adapter-react-v5';
2
+ import { InputLabel, MenuItem, FormControl, Select, FormHelperText, IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button, TextField, Alert, } from '@mui/material';
3
+ import { Add as AddIcon, Check as CheckIcon, Close as CloseIcon } from '@mui/icons-material';
4
+ import { I18n, Icon, Utils } from '@iobroker/adapter-react-v5';
4
5
  import ConfigGeneric from './ConfigGeneric';
5
6
  /** Prefix of all credential object IDs. Synchronized with `@iobroker/adapter-core` (src/credentials.ts) */
6
7
  const CREDENTIALS_PREFIX = 'system.credentials.';
8
+ /** Current version of the credential data format (keep in sync with `@iobroker/adapter-core`). */
9
+ const CREDENTIALS_VERSION = 1;
10
+ const CREDENTIAL_TYPES = ['email', 'cloud', 'ai', 'custom'];
11
+ /** Readable labels for the category selector (translated where a key exists, English fallback otherwise). */
12
+ const CREDENTIAL_TYPE_LABELS = {
13
+ email: 'E-mail',
14
+ cloud: 'Cloud',
15
+ ai: 'AI',
16
+ custom: 'Custom',
17
+ };
18
+ /** The two credential forms and their fields (keep in sync with admin `credentialTypes.ts`). */
19
+ const CREDENTIAL_FORMS = {
20
+ login: [
21
+ { name: 'login', type: 'text', required: true, label: 'Login' },
22
+ { name: 'password', type: 'password', encrypted: true, required: true, label: 'Password' },
23
+ ],
24
+ key: [{ name: 'key', type: 'password', encrypted: true, required: true, label: 'Key' }],
25
+ };
26
+ /**
27
+ * SVG paths in a 24x24 viewBox: brand logos from https://simpleicons.org (CC0), the rest Material icons.
28
+ * Kept in sync with admin `CredentialsDialog.tsx`.
29
+ */
30
+ const ICON_PATHS = {
31
+ anthropic: 'M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5527h3.7442L10.5363 3.541Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z',
32
+ chatgpt: 'M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.073zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.8956zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654 2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z',
33
+ gemini: 'M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81',
34
+ email: 'M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4-8 5-8-5V6l8 5 8-5v2z',
35
+ login: 'M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z',
36
+ key: 'M21 10h-8.35A5.99 5.99 0 0 0 7 6c-3.31 0-6 2.69-6 6s2.69 6 6 6a5.99 5.99 0 0 0 5.65-4H13l2 2 2-2 2 2 4-4.04L21 10zM7 15c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3z',
37
+ };
38
+ /** Convert an SVG path to a base64 data URL (the SVG content is pure ASCII, so `btoa` can encode it directly). */
39
+ function svgDataUrl(path, color) {
40
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="${color}" d="${path}"/></svg>`;
41
+ return `data:image/svg+xml;base64,${window.btoa(svg)}`;
42
+ }
43
+ /** Icon data URLs per template key — stored in `common.icon` of the created credential and shown in the UI. */
44
+ const ICON_DATA = {
45
+ anthropic: svgDataUrl(ICON_PATHS.anthropic, '#d97757'),
46
+ chatgpt: svgDataUrl(ICON_PATHS.chatgpt, '#74aa9c'),
47
+ gemini: svgDataUrl(ICON_PATHS.gemini, '#8e75b2'),
48
+ email: svgDataUrl(ICON_PATHS.email, '#2196f3'),
49
+ login: svgDataUrl(ICON_PATHS.login, '#9e9e9e'),
50
+ key: svgDataUrl(ICON_PATHS.key, '#ffc107'),
51
+ };
52
+ /** Templates offered in the "Add credential" dialog (a focused subset of the admin's templates). */
53
+ const CREDENTIAL_TEMPLATES = {
54
+ anthropic: { label: 'Anthropic', icon: ICON_DATA.anthropic, form: 'key', type: 'ai', name: 'anthropic' },
55
+ chatgpt: { label: 'ChatGPT', icon: ICON_DATA.chatgpt, form: 'key', type: 'ai', name: 'chatgpt' },
56
+ gemini: { label: 'Google Gemini', icon: ICON_DATA.gemini, form: 'key', type: 'ai', name: 'gemini' },
57
+ email: { label: 'E-mail', icon: ICON_DATA.email, form: 'login', type: 'email' },
58
+ login: { label: 'Login & password', icon: ICON_DATA.login, form: 'login', type: null },
59
+ key: { label: 'Key', icon: ICON_DATA.key, form: 'key', type: null },
60
+ };
7
61
  function renderCredentialItem(option, label, anyIcon) {
8
62
  return (React.createElement("span", { style: { display: 'flex', alignItems: 'center', gap: 8 } },
9
63
  option?.icon ? (React.createElement(Icon, { src: option.icon, style: { width: 20, height: 20 } })) : anyIcon ? (
@@ -15,8 +69,14 @@ export default class ConfigCredentialSelect extends ConfigGeneric {
15
69
  async componentDidMount() {
16
70
  await super.componentDidMount();
17
71
  const value = ConfigGeneric.getValue(this.props.data, this.props.attr);
18
- // Credentials are managed in admin: Settings -> Credentials.
19
- // They are stored as objects "system.credentials.<name>" with the category in native.type.
72
+ const selectOptions = await this.readCredentials();
73
+ this.setState({ value, selectOptions });
74
+ }
75
+ /**
76
+ * Read the credential objects ("system.credentials.<name>") and turn them into select options,
77
+ * filtered by `schema.credentialType` if set. The "none" option is prepended.
78
+ */
79
+ async readCredentials() {
20
80
  let selectOptions = [];
21
81
  try {
22
82
  const objs = await this.props.oContext.socket.getObjectViewSystem('config', CREDENTIALS_PREFIX, `${CREDENTIALS_PREFIX}香`);
@@ -35,7 +95,7 @@ export default class ConfigCredentialSelect extends ConfigGeneric {
35
95
  console.error(`Cannot read credentials: ${e}`);
36
96
  }
37
97
  selectOptions.unshift({ label: I18n.t(ConfigGeneric.NONE_LABEL), value: ConfigGeneric.NONE_VALUE });
38
- this.setState({ value, selectOptions });
98
+ return selectOptions;
39
99
  }
40
100
  static getCredentialName(obj) {
41
101
  const name = obj.common?.name;
@@ -48,6 +108,139 @@ export default class ConfigCredentialSelect extends ConfigGeneric {
48
108
  }
49
109
  return text || obj._id.substring(CREDENTIALS_PREFIX.length);
50
110
  }
111
+ /** Template keys offered for this field, filtered by `schema.credentialType` (type-agnostic ones always shown). */
112
+ templateKeys() {
113
+ const credentialType = this.props.schema.credentialType;
114
+ return Object.keys(CREDENTIAL_TEMPLATES).filter(key => {
115
+ const template = CREDENTIAL_TEMPLATES[key];
116
+ return !credentialType || template.type === credentialType || template.type === null;
117
+ });
118
+ }
119
+ /** Apply a template: it defines the form, the (proposed) name, the category and the icon. */
120
+ selectTemplate(key) {
121
+ const template = CREDENTIAL_TEMPLATES[key];
122
+ this.setState({
123
+ addTemplate: key,
124
+ addName: template.name || '',
125
+ addType: template.type || this.props.schema.credentialType || 'custom',
126
+ addFields: {},
127
+ addError: '',
128
+ });
129
+ }
130
+ /** Open the create dialog, pre-selecting the first template that fits the schema's credentialType. */
131
+ openAddDialog() {
132
+ const keys = this.templateKeys();
133
+ const addTemplate = keys[0];
134
+ const template = CREDENTIAL_TEMPLATES[addTemplate];
135
+ this.setState({
136
+ addOpen: true,
137
+ addTemplate,
138
+ addName: template.name || '',
139
+ addType: template.type || this.props.schema.credentialType || 'custom',
140
+ addFields: {},
141
+ addError: '',
142
+ addSaving: false,
143
+ });
144
+ }
145
+ /** Create the credential object, encrypt its secret fields, store it (with icon), then select it. */
146
+ async createCredential() {
147
+ const template = CREDENTIAL_TEMPLATES[this.state.addTemplate || ''];
148
+ const name = (this.state.addName || '').trim().replace(Utils.FORBIDDEN_CHARS, '_');
149
+ if (!name) {
150
+ this.setState({ addError: I18n.t('jc_A unique name is required') });
151
+ return;
152
+ }
153
+ const id = `${CREDENTIALS_PREFIX}${name}`;
154
+ if ((this.state.selectOptions || []).find(option => option.value === id)) {
155
+ this.setState({ addError: I18n.t('jc_A credential with this name already exists') });
156
+ return;
157
+ }
158
+ const form = template?.form || 'login';
159
+ const fields = CREDENTIAL_FORMS[form];
160
+ const addFields = this.state.addFields || {};
161
+ if (fields.some(field => field.required && !(addFields[field.name] || '').trim())) {
162
+ this.setState({ addError: I18n.t('jc_Please fill in all required fields') });
163
+ return;
164
+ }
165
+ const type = template?.type || this.props.schema.credentialType || this.state.addType || 'custom';
166
+ this.setState({ addSaving: true, addError: '' });
167
+ try {
168
+ // The actual socket is always an AdminConnection at runtime (only admin can write credentials);
169
+ // `encrypt` uses the system secret, exactly as the admin "Credentials" dialog does.
170
+ const socket = this.props.oContext.socket;
171
+ const native = {
172
+ type,
173
+ version: CREDENTIALS_VERSION,
174
+ encryptedFields: fields.filter(field => field.encrypted).map(field => field.name),
175
+ };
176
+ for (const field of fields) {
177
+ const raw = addFields[field.name] || '';
178
+ native[field.name] = field.encrypted && raw ? await socket.encrypt(raw) : raw;
179
+ }
180
+ const obj = {
181
+ _id: id,
182
+ type: 'config',
183
+ common: { name, ...(template?.icon ? { icon: template.icon } : {}) },
184
+ native,
185
+ // Only the admin may read credentials.
186
+ acl: {
187
+ object: 0x600,
188
+ owner: 'system.user.admin',
189
+ ownerGroup: 'system.group.administrator',
190
+ },
191
+ };
192
+ await socket.setObject(id, obj);
193
+ // Insert the new credential into the options (keeping "none" on top), then select it.
194
+ const existing = this.state.selectOptions || [];
195
+ const none = existing.find(option => option.value === ConfigGeneric.NONE_VALUE);
196
+ const rest = existing.filter(option => option.value !== ConfigGeneric.NONE_VALUE);
197
+ rest.push({ label: name, value: id, icon: template?.icon });
198
+ rest.sort((a, b) => a.label.localeCompare(b.label));
199
+ const selectOptions = none ? [none, ...rest] : rest;
200
+ this.setState({ addOpen: false, addSaving: false, selectOptions, value: id }, () => this.onChange(this.props.attr, id));
201
+ }
202
+ catch (e) {
203
+ this.setState({
204
+ addSaving: false,
205
+ addError: I18n.t('jc_Cannot create credential: %s', e.toString()),
206
+ });
207
+ }
208
+ }
209
+ renderAddDialog() {
210
+ if (!this.state.addOpen) {
211
+ return null;
212
+ }
213
+ const template = CREDENTIAL_TEMPLATES[this.state.addTemplate || ''];
214
+ const form = template?.form || 'login';
215
+ const fields = CREDENTIAL_FORMS[form];
216
+ const id = `${CREDENTIALS_PREFIX}${(this.state.addName || '').trim().replace(Utils.FORBIDDEN_CHARS, '_')}`;
217
+ // The category can only be chosen for type-agnostic templates when the schema doesn't pin a type.
218
+ const showCategory = !this.props.schema.credentialType && template?.type === null;
219
+ return (React.createElement(Dialog, { open: true, maxWidth: "sm", fullWidth: true, onClose: () => this.setState({ addOpen: false }) },
220
+ React.createElement(DialogTitle, null, I18n.t('jc_Add credential')),
221
+ React.createElement(DialogContent, { style: { display: 'flex', flexDirection: 'column', gap: 12, paddingTop: 8 } },
222
+ React.createElement(FormControl, { fullWidth: true, variant: "standard" },
223
+ React.createElement(InputLabel, { shrink: true }, I18n.t('jc_Template')),
224
+ React.createElement(Select, { variant: "standard", value: this.state.addTemplate || '', onChange: e => this.selectTemplate(e.target.value) }, this.templateKeys().map(key => (React.createElement(MenuItem, { key: key, value: key },
225
+ React.createElement("span", { style: { display: 'flex', alignItems: 'center', gap: 8 } },
226
+ React.createElement("img", { src: CREDENTIAL_TEMPLATES[key].icon, width: 20, height: 20, alt: "" }),
227
+ I18n.t(CREDENTIAL_TEMPLATES[key].label))))))),
228
+ showCategory ? (React.createElement(FormControl, { fullWidth: true, variant: "standard" },
229
+ React.createElement(InputLabel, { shrink: true }, I18n.t('jc_Credential type')),
230
+ React.createElement(Select, { variant: "standard", value: this.state.addType || 'custom', onChange: e => this.setState({ addType: e.target.value }) }, CREDENTIAL_TYPES.map(type => (React.createElement(MenuItem, { key: type, value: type }, I18n.t(CREDENTIAL_TYPE_LABELS[type]))))))) : null,
231
+ React.createElement(TextField, { variant: "standard", fullWidth: true, label: I18n.t('jc_Name'), value: this.state.addName || '', error: !!this.state.addError, helperText: this.state.addName ? id : '', slotProps: { inputLabel: { shrink: true }, htmlInput: { autoComplete: 'off' } }, onChange: e => this.setState({ addName: e.target.value, addError: '' }) }),
232
+ fields.map(field => (React.createElement(TextField, { key: field.name, variant: "standard", fullWidth: true, type: field.type === 'password' ? 'password' : 'text', required: field.required, label: I18n.t(field.label), value: this.state.addFields?.[field.name] || '', slotProps: {
233
+ inputLabel: { shrink: true },
234
+ htmlInput: { autoComplete: field.type === 'password' ? 'new-password' : 'off' },
235
+ }, onChange: e => this.setState({
236
+ addFields: { ...(this.state.addFields || {}), [field.name]: e.target.value },
237
+ addError: '',
238
+ }) }))),
239
+ this.state.addError ? React.createElement(Alert, { severity: "error" }, this.state.addError) : null),
240
+ React.createElement(DialogActions, null,
241
+ React.createElement(Button, { variant: "contained", color: "primary", disabled: !!this.state.addSaving || !(this.state.addName || '').trim(), startIcon: React.createElement(CheckIcon, null), onClick: () => this.createCredential() }, I18n.t('jc_Create')),
242
+ React.createElement(Button, { variant: "contained", color: "grey", disabled: !!this.state.addSaving, startIcon: React.createElement(CloseIcon, null), onClick: () => this.setState({ addOpen: false }) }, I18n.t('jc_Cancel')))));
243
+ }
51
244
  renderItem(error, disabled /* , defaultValue */) {
52
245
  if (!this.state.selectOptions) {
53
246
  return null;
@@ -57,12 +250,18 @@ export default class ConfigCredentialSelect extends ConfigGeneric {
57
250
  const unknownValue = this.state.value && this.state.value !== ConfigGeneric.NONE_VALUE && !item ? this.state.value : null;
58
251
  // if at least one option has an icon, options without icon get a placeholder for alignment
59
252
  const anyIcon = this.state.selectOptions.some(option => !!option.icon);
60
- return (React.createElement(FormControl, { style: { width: '100%' }, variant: "standard" },
61
- this.props.schema.label ? (React.createElement(InputLabel, { shrink: true }, this.getText(this.props.schema.label))) : null,
62
- React.createElement(Select, { variant: "standard", error: !!error || !!unknownValue, displayEmpty: true, disabled: !!disabled, value: this.state.value || ConfigGeneric.NONE_VALUE, renderValue: () => unknownValue
63
- ? unknownValue
64
- : renderCredentialItem(item, this.getText(item?.label, this.props.schema.noTranslation !== false), anyIcon), onChange: e => this.setState({ value: e.target.value === ConfigGeneric.NONE_VALUE ? '' : e.target.value }, () => this.onChange(this.props.attr, this.state.value)) }, this.state.selectOptions?.map(item_ => (React.createElement(MenuItem, { key: item_.value, value: item_.value, style: item_.value === ConfigGeneric.NONE_VALUE ? { opacity: 0.5 } : {} }, renderCredentialItem(item_, this.getText(item_.label, this.props.schema.noTranslation !== false), anyIcon))))),
65
- this.props.schema.help ? (React.createElement(FormHelperText, null, this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation))) : null));
253
+ // creation can be suppressed per schema (`disableCreation`)
254
+ const canCreate = !this.props.schema.disableCreation;
255
+ return (React.createElement("div", { style: { display: 'flex', alignItems: 'flex-end', gap: 4, width: '100%' } },
256
+ React.createElement(FormControl, { style: { flex: 1, minWidth: 0 }, variant: "standard" },
257
+ this.props.schema.label ? (React.createElement(InputLabel, { shrink: true }, this.getText(this.props.schema.label))) : null,
258
+ React.createElement(Select, { variant: "standard", error: !!error || !!unknownValue, displayEmpty: true, disabled: !!disabled, value: this.state.value || ConfigGeneric.NONE_VALUE, renderValue: () => unknownValue
259
+ ? unknownValue
260
+ : renderCredentialItem(item, this.getText(item?.label, this.props.schema.noTranslation !== false), anyIcon), onChange: e => this.setState({ value: e.target.value === ConfigGeneric.NONE_VALUE ? '' : e.target.value }, () => this.onChange(this.props.attr, this.state.value)) }, this.state.selectOptions?.map(item_ => (React.createElement(MenuItem, { key: item_.value, value: item_.value, style: item_.value === ConfigGeneric.NONE_VALUE ? { opacity: 0.5 } : {} }, renderCredentialItem(item_, this.getText(item_.label, this.props.schema.noTranslation !== false), anyIcon))))),
261
+ this.props.schema.help ? (React.createElement(FormHelperText, null, this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation))) : null),
262
+ canCreate ? (React.createElement(IconButton, { size: "small", disabled: !!disabled, title: I18n.t('jc_Add credential'), onClick: () => this.openAddDialog() },
263
+ React.createElement(AddIcon, null))) : null,
264
+ this.renderAddDialog()));
66
265
  }
67
266
  }
68
267
  //# sourceMappingURL=ConfigCredentialSelect.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigCredentialSelect.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigCredentialSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE1F,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,2GAA2G;AAC3G,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AAiBjD,SAAS,oBAAoB,CACzB,MAA0C,EAC1C,KAAa,EACb,OAAgB;IAEhB,OAAO,CACH,8BAAM,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE;QACzD,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CACZ,oBAAC,IAAI,IACD,GAAG,EAAE,MAAM,CAAC,IAAI,EAChB,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,GAClC,CACL,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QACV,8DAA8D;QAC9D,8BAAM,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,GAAI,C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AE,CAAC,CAAC,MAAM,CAAC,KAAK,KAAK,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,EAC5E,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CACzD,IAGJ,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CACpC,oBAAC,QAAQ,IACL,GAAG,EAAE,KAAK,CAAC,KAAK,EAChB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,KAAK,EAAE,KAAK,CAAC,KAAK,KAAK,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,IAEtE,oBAAoB,CACjB,KAAK,EACL,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,KAAK,KAAK,CAAC,EACpE,OAAO,CACV,CACM,CACd,CAAC,CACG;YACR,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CACtB,oBAAC,cAAc,QACV,IAAI,CAAC,UAAU,CACZ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,CACY,CACpB,CAAC,CAAC,CAAC,IAAI,CACE,CACjB,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { InputLabel, MenuItem, FormControl, Select, FormHelperText } from '@mui/material';\n\nimport { I18n, Icon } from '@iobroker/adapter-react-v5';\nimport type { ConfigItemCredentialSelect } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\n/** Prefix of all credential object IDs. Synchronized with `@iobroker/adapter-core` (src/credentials.ts) */\nconst CREDENTIALS_PREFIX = 'system.credentials.';\n\ninterface ConfigCredentialSelectProps extends ConfigGenericProps {\n schema: ConfigItemCredentialSelect;\n}\n\ninterface CredentialSelectOption {\n label: string;\n value: string;\n /** Icon of the credential (data URL from `common.icon`) */\n icon?: string;\n}\n\ninterface ConfigCredentialSelectState extends ConfigGenericState {\n selectOptions?: CredentialSelectOption[];\n}\n\nfunction renderCredentialItem(\n option: CredentialSelectOption | undefined,\n label: string,\n anyIcon: boolean,\n): JSX.Element {\n return (\n <span style={{ display: 'flex', alignItems: 'center', gap: 8 }}>\n {option?.icon ? (\n <Icon\n src={option.icon}\n style={{ width: 20, height: 20 }}\n />\n ) : anyIcon ? (\n // if at least one option has an icon, keep the labels aligned\n <span style={{ width: 20, height: 20, flexShrink: 0 }} />\n ) : null}\n {label}\n </span>\n );\n}\n\nexport default class ConfigCredentialSelect extends ConfigGeneric<\n ConfigCredentialSelectProps,\n ConfigCredentialSelectState\n> {\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n // Credentials are managed in admin: Settings -> Credentials.\n // They are stored as objects \"system.credentials.<name>\" with the category in native.type.\n let selectOptions: CredentialSelectOption[] = [];\n try {\n const objs = await this.props.oContext.socket.getObjectViewSystem(\n 'config',\n CREDENTIALS_PREFIX,\n `${CREDENTIALS_PREFIX}香`,\n );\n selectOptions = Object.values(objs)\n .filter(\n obj =>\n !!obj &&\n (!this.props.schema.credentialType ||\n (obj.native as Record<string, any>)?.type === this.props.schema.credentialType),\n )\n .map(obj => ({\n label: ConfigCredentialSelect.getCredentialName(obj as ioBroker.Object),\n value: obj._id,\n icon: typeof obj.common?.icon === 'string' ? obj.common.icon : undefined,\n }))\n .sort((a, b) => a.label.localeCompare(b.label));\n } catch (e) {\n console.error(`Cannot read credentials: ${e}`);\n }\n\n selectOptions.unshift({ label: I18n.t(ConfigGeneric.NONE_LABEL), value: ConfigGeneric.NONE_VALUE });\n\n this.setState({ value, selectOptions });\n }\n\n static getCredentialName(obj: ioBroker.Object): string {\n const name = obj.common?.name;\n let text: string;\n if (name && typeof name === 'object') {\n text = name[I18n.getLanguage()] || name.en || Object.values(name)[0] || '';\n } else {\n text = (name as string) || '';\n }\n return text || obj._id.substring(CREDENTIALS_PREFIX.length);\n }\n\n renderItem(error: unknown, disabled: boolean /* , defaultValue */): JSX.Element | null {\n if (!this.state.selectOptions) {\n return null;\n }\n\n const item = this.state.selectOptions?.find(_item => _item.value === this.state.value);\n // The stored value could point to a meanwhile deleted credential\n const unknownValue =\n this.state.value && this.state.value !== ConfigGeneric.NONE_VALUE && !item ? this.state.value : null;\n // if at least one option has an icon, options without icon get a placeholder for alignment\n const anyIcon = this.state.selectOptions.some(option => !!option.icon);\n\n return (\n <FormControl\n style={{ width: '100%' }}\n variant=\"standard\"\n >\n {this.props.schema.label ? (\n <InputLabel shrink>{this.getText(this.props.schema.label)}</InputLabel>\n ) : null}\n <Select\n variant=\"standard\"\n error={!!error || !!unknownValue}\n displayEmpty\n disabled={!!disabled}\n value={this.state.value || ConfigGeneric.NONE_VALUE}\n renderValue={() =>\n unknownValue\n ? unknownValue\n : renderCredentialItem(\n item,\n this.getText(item?.label, this.props.schema.noTranslation !== false),\n anyIcon,\n )\n }\n onChange={e =>\n this.setState(\n { value: e.target.value === ConfigGeneric.NONE_VALUE ? '' : e.target.value },\n () => this.onChange(this.props.attr, this.state.value),\n )\n }\n >\n {this.state.selectOptions?.map(item_ => (\n <MenuItem\n key={item_.value}\n value={item_.value}\n style={item_.value === ConfigGeneric.NONE_VALUE ? { opacity: 0.5 } : {}}\n >\n {renderCredentialItem(\n item_,\n this.getText(item_.label, this.props.schema.noTranslation !== false),\n anyIcon,\n )}\n </MenuItem>\n ))}\n </Select>\n {this.props.schema.help ? (\n <FormHelperText>\n {this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n </FormHelperText>\n ) : null}\n </FormControl>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"ConfigCredentialSelect.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigCredentialSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EACH,UAAU,EACV,QAAQ,EACR,WAAW,EACX,MAAM,EACN,cAAc,EACd,UAAU,EACV,MAAM,EACN,WAAW,EACX,aAAa,EACb,aAAa,EACb,MAAM,EACN,SAAS,EACT,KAAK,GACR,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAE7F,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,2GAA2G;AAC3G,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AAEjD,kGAAkG;AAClG,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAG9B,MAAM,gBAAgB,GAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC9E,6GAA6G;AAC7G,MAAM,sBAAsB,GAAmC;IAC3D,KAAK,EAAE,QAAQ;IACf,KAAK,EAAE,OAAO;IACd,EAAE,EAAE,IAAI;IACR,MAAM,EAAE,QAAQ;CACnB,CAAC;AAeF,gGAAgG;AAChG,MAAM,gBAAgB,GAAwD;IAC1E,KAAK,EAAE;QACH,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE;QAC/D,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,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,CACjB,KAAK,EACL,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,KAAK,KAAK,CAAC,EACpE,OAAO,CACV,CACM,CACd,CAAC,CACG;gBACR,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CACtB,oBAAC,cAAc,QACV,IAAI,CAAC,UAAU,CACZ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,CACY,CACpB,CAAC,CAAC,CAAC,IAAI,CACE;YACb,SAAS,CAAC,CAAC,CAAC,CACT,oBAAC,UAAU,IACP,IAAI,EAAC,OAAO,EACZ,QAAQ,EAAE,CAAC,CAAC,QAAQ,EACpB,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,EAClC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE;gBAEnC,oBAAC,OAAO,OAAG,CACF,CAChB,CAAC,CAAC,CAAC,IAAI;YACP,IAAI,CAAC,eAAe,EAAE,CACrB,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\n\nimport {\n InputLabel,\n MenuItem,\n FormControl,\n Select,\n FormHelperText,\n IconButton,\n Dialog,\n DialogTitle,\n DialogContent,\n DialogActions,\n Button,\n TextField,\n Alert,\n} from '@mui/material';\nimport { Add as AddIcon, Check as CheckIcon, Close as CloseIcon } from '@mui/icons-material';\n\nimport { I18n, Icon, Utils } from '@iobroker/adapter-react-v5';\nimport type { ConfigItemCredentialSelect } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\n/** Prefix of all credential object IDs. Synchronized with `@iobroker/adapter-core` (src/credentials.ts) */\nconst CREDENTIALS_PREFIX = 'system.credentials.';\n\n/** Current version of the credential data format (keep in sync with `@iobroker/adapter-core`). */\nconst CREDENTIALS_VERSION = 1;\n\ntype CredentialType = 'email' | 'cloud' | 'ai' | 'custom';\nconst CREDENTIAL_TYPES: CredentialType[] = ['email', 'cloud', 'ai', 'custom'];\n/** Readable labels for the category selector (translated where a key exists, English fallback otherwise). */\nconst CREDENTIAL_TYPE_LABELS: Record<CredentialType, string> = {\n email: 'E-mail',\n cloud: 'Cloud',\n ai: 'AI',\n custom: 'Custom',\n};\n\ntype CredentialForm = 'login' | 'key';\n\ninterface CredentialFieldDefinition {\n /** Attribute name in the object's `native` */\n name: string;\n type: 'text' | 'password';\n /** Stored encrypted with the system secret */\n encrypted?: boolean;\n required?: boolean;\n /** Label shown in the create dialog */\n label: string;\n}\n\n/** The two credential forms and their fields (keep in sync with admin `credentialTypes.ts`). */\nconst CREDENTIAL_FORMS: Record<CredentialForm, CredentialFieldDefinition[]> = {\n login: [\n { name: 'login', type: 'text', required: true, label: 'Login' },\n { name: 'password', type: 'password', encrypted: true, required: true, label: 'Password' },\n ],\n key: [{ name: 'key', type: 'password', encrypted: true, required: true, label: 'Key' }],\n};\n\n/**\n * SVG paths in a 24x24 viewBox: brand logos from https://simpleicons.org (CC0), the rest Material icons.\n * Kept in sync with admin `CredentialsDialog.tsx`.\n */\nconst ICON_PATHS = {\n anthropic:\n 'M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5527h3.7442L10.5363 3.541Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z',\n chatgpt:\n 'M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.073zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.8956zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654 2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z',\n gemini: 'M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81',\n email: 'M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4-8 5-8-5V6l8 5 8-5v2z',\n login: 'M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z',\n key: 'M21 10h-8.35A5.99 5.99 0 0 0 7 6c-3.31 0-6 2.69-6 6s2.69 6 6 6a5.99 5.99 0 0 0 5.65-4H13l2 2 2-2 2 2 4-4.04L21 10zM7 15c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3z',\n};\n\n/** Convert an SVG path to a base64 data URL (the SVG content is pure ASCII, so `btoa` can encode it directly). */\nfunction svgDataUrl(path: string, color: string): string {\n const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"${color}\" d=\"${path}\"/></svg>`;\n return `data:image/svg+xml;base64,${window.btoa(svg)}`;\n}\n\n/** Icon data URLs per template key — stored in `common.icon` of the created credential and shown in the UI. */\nconst ICON_DATA: Record<string, string> = {\n anthropic: svgDataUrl(ICON_PATHS.anthropic, '#d97757'),\n chatgpt: svgDataUrl(ICON_PATHS.chatgpt, '#74aa9c'),\n gemini: svgDataUrl(ICON_PATHS.gemini, '#8e75b2'),\n email: svgDataUrl(ICON_PATHS.email, '#2196f3'),\n login: svgDataUrl(ICON_PATHS.login, '#9e9e9e'),\n key: svgDataUrl(ICON_PATHS.key, '#ffc107'),\n};\n\ninterface CredentialTemplate {\n /** Label shown in the template selector */\n label: string;\n /** Icon (data URL) stored in `common.icon` */\n icon: string;\n /** Form of the credential: login/password or a single key */\n form: CredentialForm;\n /** Fixed category, or null if it follows the schema/user selection */\n type: CredentialType | null;\n /** Proposed unique name */\n name?: string;\n}\n\n/** Templates offered in the \"Add credential\" dialog (a focused subset of the admin's templates). */\nconst CREDENTIAL_TEMPLATES: Record<string, CredentialTemplate> = {\n anthropic: { label: 'Anthropic', icon: ICON_DATA.anthropic, form: 'key', type: 'ai', name: 'anthropic' },\n chatgpt: { label: 'ChatGPT', icon: ICON_DATA.chatgpt, form: 'key', type: 'ai', name: 'chatgpt' },\n gemini: { label: 'Google Gemini', icon: ICON_DATA.gemini, form: 'key', type: 'ai', name: 'gemini' },\n email: { label: 'E-mail', icon: ICON_DATA.email, form: 'login', type: 'email' },\n login: { label: 'Login & password', icon: ICON_DATA.login, form: 'login', type: null },\n key: { label: 'Key', icon: ICON_DATA.key, form: 'key', type: null },\n};\n\ninterface ConfigCredentialSelectProps extends ConfigGenericProps {\n schema: ConfigItemCredentialSelect;\n}\n\ninterface CredentialSelectOption {\n label: string;\n value: string;\n /** Icon of the credential (data URL from `common.icon`) */\n icon?: string;\n}\n\ninterface ConfigCredentialSelectState extends ConfigGenericState {\n selectOptions?: CredentialSelectOption[];\n /** Whether the \"create credential\" dialog is open */\n addOpen?: boolean;\n /** Selected template key */\n addTemplate?: string;\n addName?: string;\n addType?: CredentialType;\n addFields?: Record<string, string>;\n addError?: string;\n addSaving?: boolean;\n}\n\nfunction renderCredentialItem(\n option: CredentialSelectOption | undefined,\n label: string,\n anyIcon: boolean,\n): JSX.Element {\n return (\n <span style={{ display: 'flex', alignItems: 'center', gap: 8 }}>\n {option?.icon ? (\n <Icon\n src={option.icon}\n style={{ width: 20, height: 20 }}\n />\n ) : anyIcon ? (\n // if at least one option has an icon, keep the labels aligned\n <span style={{ width: 20, height: 20, flexShrink: 0 }} />\n ) : null}\n {label}\n </span>\n );\n}\n\nexport default class ConfigCredentialSelect extends ConfigGeneric<\n ConfigCredentialSelectProps,\n ConfigCredentialSelectState\n> {\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n const selectOptions = await this.readCredentials();\n this.setState({ value, selectOptions });\n }\n\n /**\n * Read the credential objects (\"system.credentials.<name>\") and turn them into select options,\n * filtered by `schema.credentialType` if set. The \"none\" option is prepended.\n */\n async readCredentials(): Promise<CredentialSelectOption[]> {\n let selectOptions: CredentialSelectOption[] = [];\n try {\n const objs = await this.props.oContext.socket.getObjectViewSystem(\n 'config',\n CREDENTIALS_PREFIX,\n `${CREDENTIALS_PREFIX}香`,\n );\n selectOptions = Object.values(objs)\n .filter(\n obj =>\n !!obj &&\n (!this.props.schema.credentialType ||\n (obj.native as Record<string, any>)?.type === this.props.schema.credentialType),\n )\n .map(obj => ({\n label: ConfigCredentialSelect.getCredentialName(obj as ioBroker.Object),\n value: obj._id,\n icon: typeof obj.common?.icon === 'string' ? obj.common.icon : undefined,\n }))\n .sort((a, b) => a.label.localeCompare(b.label));\n } catch (e) {\n console.error(`Cannot read credentials: ${e}`);\n }\n\n selectOptions.unshift({ label: I18n.t(ConfigGeneric.NONE_LABEL), value: ConfigGeneric.NONE_VALUE });\n return selectOptions;\n }\n\n static getCredentialName(obj: ioBroker.Object): string {\n const name = obj.common?.name;\n let text: string;\n if (name && typeof name === 'object') {\n text = name[I18n.getLanguage()] || name.en || Object.values(name)[0] || '';\n } else {\n text = (name as string) || '';\n }\n return text || obj._id.substring(CREDENTIALS_PREFIX.length);\n }\n\n /** Template keys offered for this field, filtered by `schema.credentialType` (type-agnostic ones always shown). */\n templateKeys(): string[] {\n const credentialType = this.props.schema.credentialType;\n return Object.keys(CREDENTIAL_TEMPLATES).filter(key => {\n const template = CREDENTIAL_TEMPLATES[key];\n return !credentialType || template.type === credentialType || template.type === null;\n });\n }\n\n /** Apply a template: it defines the form, the (proposed) name, the category and the icon. */\n selectTemplate(key: string): void {\n const template = CREDENTIAL_TEMPLATES[key];\n this.setState({\n addTemplate: key,\n addName: template.name || '',\n addType: template.type || this.props.schema.credentialType || 'custom',\n addFields: {},\n addError: '',\n });\n }\n\n /** Open the create dialog, pre-selecting the first template that fits the schema's credentialType. */\n openAddDialog(): void {\n const keys = this.templateKeys();\n const addTemplate = keys[0];\n const template = CREDENTIAL_TEMPLATES[addTemplate];\n this.setState({\n addOpen: true,\n addTemplate,\n addName: template.name || '',\n addType: template.type || this.props.schema.credentialType || 'custom',\n addFields: {},\n addError: '',\n addSaving: false,\n });\n }\n\n /** Create the credential object, encrypt its secret fields, store it (with icon), then select it. */\n async createCredential(): Promise<void> {\n const template = CREDENTIAL_TEMPLATES[this.state.addTemplate || ''];\n const name = (this.state.addName || '').trim().replace(Utils.FORBIDDEN_CHARS, '_');\n if (!name) {\n this.setState({ addError: I18n.t('jc_A unique name is required') });\n return;\n }\n const id = `${CREDENTIALS_PREFIX}${name}`;\n if ((this.state.selectOptions || []).find(option => option.value === id)) {\n this.setState({ addError: I18n.t('jc_A credential with this name already exists') });\n return;\n }\n\n const form = template?.form || 'login';\n const fields = CREDENTIAL_FORMS[form];\n const addFields = this.state.addFields || {};\n if (fields.some(field => field.required && !(addFields[field.name] || '').trim())) {\n this.setState({ addError: I18n.t('jc_Please fill in all required fields') });\n return;\n }\n const type: CredentialType =\n template?.type || this.props.schema.credentialType || this.state.addType || 'custom';\n\n this.setState({ addSaving: true, addError: '' });\n try {\n // The actual socket is always an AdminConnection at runtime (only admin can write credentials);\n // `encrypt` uses the system secret, exactly as the admin \"Credentials\" dialog does.\n const socket = this.props.oContext.socket;\n const native: Record<string, any> = {\n type,\n version: CREDENTIALS_VERSION,\n encryptedFields: fields.filter(field => field.encrypted).map(field => field.name),\n };\n for (const field of fields) {\n const raw = addFields[field.name] || '';\n native[field.name] = field.encrypted && raw ? await socket.encrypt(raw) : raw;\n }\n\n const obj = {\n _id: id,\n type: 'config',\n common: { name, ...(template?.icon ? { icon: template.icon } : {}) },\n native,\n // Only the admin may read credentials.\n acl: {\n object: 0x600,\n owner: 'system.user.admin',\n ownerGroup: 'system.group.administrator',\n },\n } as unknown as ioBroker.SettableObject;\n\n await socket.setObject(id, obj);\n\n // Insert the new credential into the options (keeping \"none\" on top), then select it.\n const existing = this.state.selectOptions || [];\n const none = existing.find(option => option.value === ConfigGeneric.NONE_VALUE);\n const rest = existing.filter(option => option.value !== ConfigGeneric.NONE_VALUE);\n rest.push({ label: name, value: id, icon: template?.icon });\n rest.sort((a, b) => a.label.localeCompare(b.label));\n const selectOptions = none ? [none, ...rest] : rest;\n\n this.setState({ addOpen: false, addSaving: false, selectOptions, value: id }, () =>\n this.onChange(this.props.attr, id),\n );\n } catch (e) {\n this.setState({\n addSaving: false,\n addError: I18n.t('jc_Cannot create credential: %s', (e as Error).toString()),\n });\n }\n }\n\n renderAddDialog(): JSX.Element | null {\n if (!this.state.addOpen) {\n return null;\n }\n const template = CREDENTIAL_TEMPLATES[this.state.addTemplate || ''];\n const form = template?.form || 'login';\n const fields = CREDENTIAL_FORMS[form];\n const id = `${CREDENTIALS_PREFIX}${(this.state.addName || '').trim().replace(Utils.FORBIDDEN_CHARS, '_')}`;\n // The category can only be chosen for type-agnostic templates when the schema doesn't pin a type.\n const showCategory = !this.props.schema.credentialType && template?.type === null;\n\n return (\n <Dialog\n open\n maxWidth=\"sm\"\n fullWidth\n onClose={() => this.setState({ addOpen: false })}\n >\n <DialogTitle>{I18n.t('jc_Add credential')}</DialogTitle>\n <DialogContent style={{ display: 'flex', flexDirection: 'column', gap: 12, paddingTop: 8 }}>\n <FormControl\n fullWidth\n variant=\"standard\"\n >\n <InputLabel shrink>{I18n.t('jc_Template')}</InputLabel>\n <Select\n variant=\"standard\"\n value={this.state.addTemplate || ''}\n onChange={e => this.selectTemplate(e.target.value)}\n >\n {this.templateKeys().map(key => (\n <MenuItem\n key={key}\n value={key}\n >\n <span style={{ display: 'flex', alignItems: 'center', gap: 8 }}>\n <img\n src={CREDENTIAL_TEMPLATES[key].icon}\n width={20}\n height={20}\n alt=\"\"\n />\n {I18n.t(CREDENTIAL_TEMPLATES[key].label)}\n </span>\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n\n {showCategory ? (\n <FormControl\n fullWidth\n variant=\"standard\"\n >\n <InputLabel shrink>{I18n.t('jc_Credential type')}</InputLabel>\n <Select\n variant=\"standard\"\n value={this.state.addType || 'custom'}\n onChange={e => this.setState({ addType: e.target.value as CredentialType })}\n >\n {CREDENTIAL_TYPES.map(type => (\n <MenuItem\n key={type}\n value={type}\n >\n {I18n.t(CREDENTIAL_TYPE_LABELS[type])}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n ) : null}\n\n <TextField\n variant=\"standard\"\n fullWidth\n label={I18n.t('jc_Name')}\n value={this.state.addName || ''}\n error={!!this.state.addError}\n helperText={this.state.addName ? id : ''}\n slotProps={{ inputLabel: { shrink: true }, htmlInput: { autoComplete: 'off' } }}\n onChange={e => this.setState({ addName: e.target.value, addError: '' })}\n />\n\n {fields.map(field => (\n <TextField\n key={field.name}\n variant=\"standard\"\n fullWidth\n type={field.type === 'password' ? 'password' : 'text'}\n required={field.required}\n label={I18n.t(field.label)}\n value={this.state.addFields?.[field.name] || ''}\n slotProps={{\n inputLabel: { shrink: true },\n htmlInput: { autoComplete: field.type === 'password' ? 'new-password' : 'off' },\n }}\n onChange={e =>\n this.setState({\n addFields: { ...(this.state.addFields || {}), [field.name]: e.target.value },\n addError: '',\n })\n }\n />\n ))}\n\n {this.state.addError ? <Alert severity=\"error\">{this.state.addError}</Alert> : null}\n </DialogContent>\n <DialogActions>\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={!!this.state.addSaving || !(this.state.addName || '').trim()}\n startIcon={<CheckIcon />}\n onClick={() => this.createCredential()}\n >\n {I18n.t('jc_Create')}\n </Button>\n <Button\n variant=\"contained\"\n color=\"grey\"\n disabled={!!this.state.addSaving}\n startIcon={<CloseIcon />}\n onClick={() => this.setState({ addOpen: false })}\n >\n {I18n.t('jc_Cancel')}\n </Button>\n </DialogActions>\n </Dialog>\n );\n }\n\n renderItem(error: unknown, disabled: boolean /* , defaultValue */): JSX.Element | null {\n if (!this.state.selectOptions) {\n return null;\n }\n\n const item = this.state.selectOptions?.find(_item => _item.value === this.state.value);\n // The stored value could point to a meanwhile deleted credential\n const unknownValue =\n this.state.value && this.state.value !== ConfigGeneric.NONE_VALUE && !item ? this.state.value : null;\n // if at least one option has an icon, options without icon get a placeholder for alignment\n const anyIcon = this.state.selectOptions.some(option => !!option.icon);\n // creation can be suppressed per schema (`disableCreation`)\n const canCreate = !this.props.schema.disableCreation;\n\n return (\n <div style={{ display: 'flex', alignItems: 'flex-end', gap: 4, width: '100%' }}>\n <FormControl\n style={{ flex: 1, minWidth: 0 }}\n variant=\"standard\"\n >\n {this.props.schema.label ? (\n <InputLabel shrink>{this.getText(this.props.schema.label)}</InputLabel>\n ) : null}\n <Select\n variant=\"standard\"\n error={!!error || !!unknownValue}\n displayEmpty\n disabled={!!disabled}\n value={this.state.value || ConfigGeneric.NONE_VALUE}\n renderValue={() =>\n unknownValue\n ? unknownValue\n : renderCredentialItem(\n item,\n this.getText(item?.label, this.props.schema.noTranslation !== false),\n anyIcon,\n )\n }\n onChange={e =>\n this.setState(\n { value: e.target.value === ConfigGeneric.NONE_VALUE ? '' : e.target.value },\n () => this.onChange(this.props.attr, this.state.value),\n )\n }\n >\n {this.state.selectOptions?.map(item_ => (\n <MenuItem\n key={item_.value}\n value={item_.value}\n style={item_.value === ConfigGeneric.NONE_VALUE ? { opacity: 0.5 } : {}}\n >\n {renderCredentialItem(\n item_,\n this.getText(item_.label, this.props.schema.noTranslation !== false),\n anyIcon,\n )}\n </MenuItem>\n ))}\n </Select>\n {this.props.schema.help ? (\n <FormHelperText>\n {this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n </FormHelperText>\n ) : null}\n </FormControl>\n {canCreate ? (\n <IconButton\n size=\"small\"\n disabled={!!disabled}\n title={I18n.t('jc_Add credential')}\n onClick={() => this.openAddDialog()}\n >\n <AddIcon />\n </IconButton>\n ) : null}\n {this.renderAddDialog()}\n </div>\n );\n }\n}\n"]}