Skip to content

Commit bd92ee1

Browse files
committed
feat: add userconfig to import-export
1 parent 88b39e8 commit bd92ee1

File tree

6 files changed

+39
-9
lines changed

6 files changed

+39
-9
lines changed

companion/lib/Data/ImportExport.js

+10
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,10 @@ class DataImportExport extends CoreBase {
377377
exp.surfaceGroups = this.surfaces.exportAllGroups(false)
378378
}
379379

380+
if (!config || !isFalsey(config.userconfig)) {
381+
exp.userconfig = this.userconfig.getAll(false)
382+
}
383+
380384
return exp
381385
}
382386

@@ -619,6 +623,7 @@ class DataImportExport extends CoreBase {
619623
customVariables: 'custom_variables' in object,
620624
surfaces: 'surfaces' in object,
621625
triggers: 'triggers' in object,
626+
userconfig: 'userconfig' in object,
622627
}
623628

624629
for (const [instanceId, instance] of Object.entries(object.instances || {})) {
@@ -745,6 +750,11 @@ class DataImportExport extends CoreBase {
745750
// Destroy old stuff
746751
await this.#reset(undefined, !config || config.buttons)
747752

753+
// import userconfig
754+
if (!config || config.userconfig) {
755+
this.userconfig.setKeys(data.userconfig || {})
756+
}
757+
748758
// import custom variables
749759
if (!config || config.customVariables) {
750760
this.instance.variable.custom.replaceDefinitions(data.custom_variables || {})

companion/lib/Data/UserConfig.js

+17
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,23 @@ class DataUserConfig extends CoreBase {
280280
})
281281
}
282282

283+
/**
284+
* Get the config settings
285+
* @param {boolean} [clone = false] - <code>true</code> if a clone is needed instead of a link
286+
* @returns {any} the config values
287+
* @access public
288+
*/
289+
getAll(clone = false) {
290+
// @ts-ignore
291+
let out = this.data
292+
293+
if (clone === true) {
294+
out = cloneDeep(out)
295+
}
296+
297+
return out
298+
}
299+
283300
/**
284301
* Get a specific use config setting
285302
* @param {string} key

shared-lib/lib/Model/ExportModel.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { UserConfigGridSize } from './UserConfigModel.js'
1+
import type { UserConfigGridSize, UserConfigModel } from './UserConfigModel.js'
22
import type { ConnectionConfig } from './Connections.js'
33
import type { CustomVariablesModel } from './CustomVariableModel.js'
44

@@ -16,6 +16,7 @@ export interface ExportFullv4 extends ExportBase<'full'> {
1616
instances?: ExportInstancesv4
1717
surfaces?: unknown
1818
surfaceGroups?: unknown
19+
userconfig?: UserConfigModel
1920
}
2021

2122
export interface ExportPageModelv4 extends ExportBase<'page'> {

shared-lib/lib/Model/ImportExport.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface ClientExportSelection {
1616
customVariables: boolean
1717
connections: boolean
1818
surfaces: boolean
19-
19+
userconfig: boolean
2020
format: ExportFormat
2121
}
2222

@@ -25,6 +25,7 @@ export interface ClientImportSelection {
2525
customVariables: boolean
2626
surfaces: boolean
2727
triggers: boolean
28+
userconfig: boolean
2829
}
2930

3031
export interface ClientPageInfo {
@@ -43,6 +44,7 @@ export interface ClientImportObject {
4344
customVariables: boolean
4445
surfaces: boolean
4546
triggers: boolean | Record<string, { name: string }>
47+
userconfig: boolean
4648
oldPageNumber?: number
4749
page?: ClientPageInfo
4850
pages?: Record<number, ClientPageInfo>

webui/src/ImportExport/Export.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const ExportWizardModal = forwardRef<ExportWizardModalRef, ExportWizardMo
1919
surfaces: true,
2020
triggers: true,
2121
customVariables: true,
22-
// userconfig: true,
22+
userconfig: true,
2323
format: ExportFormatDefault,
2424
})
2525

@@ -69,7 +69,7 @@ export const ExportWizardModal = forwardRef<ExportWizardModalRef, ExportWizardMo
6969
surfaces: true,
7070
triggers: true,
7171
customVariables: true,
72-
// userconfig: true,
72+
userconfig: true,
7373
format: ExportFormatDefault,
7474
})
7575

@@ -177,7 +177,7 @@ function ExportOptionsStep({ config, setValue }: ExportOptionsStepProps) {
177177
<CLabel htmlFor="wizard_surfaces">Surfaces</CLabel>
178178
</div>
179179
</div>
180-
{/* <div className="indent3">
180+
<div className="indent3">
181181
<div className="form-check form-check-inline mr-1">
182182
<CInputCheckbox
183183
id="wizard_userconfig"
@@ -186,7 +186,7 @@ function ExportOptionsStep({ config, setValue }: ExportOptionsStepProps) {
186186
/>
187187
<CLabel htmlFor="wizard_userconfig">Settings</CLabel>
188188
</div>
189-
</div> */}
189+
</div>
190190

191191
<div className="indent3">
192192
<div className="form-check form-check-inline mr-1">

webui/src/ImportExport/Import/Full.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function FullImportTab({ snapshot }: FullImportTabProps) {
136136
surfaces: true,
137137
triggers: true,
138138
customVariables: true,
139-
// userconfig: true,
139+
userconfig: true,
140140
}))
141141

142142
const validConfigKeys = Object.entries(config).filter(([k, v]) => v && snapshotKeys.includes(k))
@@ -208,13 +208,13 @@ function FullImportTab({ snapshot }: FullImportTabProps) {
208208

209209
<InputCheckbox config={config} allowKeys={snapshotKeys} keyName="surfaces" setValue={setValue} label="Surfaces" />
210210

211-
{/* <InputCheckbox
211+
<InputCheckbox
212212
config={config}
213213
allowKeys={snapshotKeys}
214214
keyName="userconfig"
215215
setValue={setValue}
216216
label="Settings"
217-
/> */}
217+
/>
218218

219219
<CAlert color="info">
220220
All the connections will be imported, as they are required to be able to import any actions and feedbacks.

0 commit comments

Comments
 (0)