Skip to content

Commit 301d586

Browse files
committed
feat: add userconfig to import-export
1 parent 088e282 commit 301d586

File tree

6 files changed

+39
-9
lines changed

6 files changed

+39
-9
lines changed

companion/lib/Data/ImportExport.ts

+10
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,10 @@ export class DataImportExport extends CoreBase {
344344
exp.surfaceGroups = this.surfaces.exportAllGroups(false)
345345
}
346346

347+
if (!config || !isFalsey(config.userconfig)) {
348+
exp.userconfig = this.userconfig.getAll(false)
349+
}
350+
347351
return exp
348352
}
349353

@@ -548,6 +552,7 @@ export class DataImportExport extends CoreBase {
548552
customVariables: 'custom_variables' in object,
549553
surfaces: 'surfaces' in object,
550554
triggers: 'triggers' in object,
555+
userconfig: 'userconfig' in object,
551556
}
552557

553558
for (const [instanceId, instance] of Object.entries(object.instances || {})) {
@@ -634,6 +639,11 @@ export class DataImportExport extends CoreBase {
634639
// Destroy old stuff
635640
await this.#reset(undefined, !config || config.buttons)
636641

642+
// import userconfig
643+
if (!config || config.userconfig) {
644+
this.userconfig.setKeys(data.userconfig || {})
645+
}
646+
637647
// import custom variables
638648
if (!config || config.customVariables) {
639649
this.variablesController.custom.replaceDefinitions(data.custom_variables || {})

companion/lib/Data/UserConfig.ts

+16
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,22 @@ export class DataUserConfig extends CoreBase {
276276
})
277277
}
278278

279+
/**
280+
* Get the config settings
281+
* @param {boolean} [clone = false] - <code>true</code> if a clone is needed instead of a link
282+
* @returns {UserConfigModel} the config values
283+
* @access public
284+
*/
285+
getAll(clone = false): UserConfigModel {
286+
let out = this.#data
287+
288+
if (clone === true) {
289+
out = cloneDeep(out)
290+
}
291+
292+
return out
293+
}
294+
279295
/**
280296
* Get a specific use config setting
281297
* @param 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
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface ClientExportSelection {
1616
customVariables: boolean
1717
connections: boolean
1818
surfaces: boolean
19+
userconfig: boolean
1920

2021
format: ExportFormat
2122
}
@@ -25,6 +26,7 @@ export interface ClientImportSelection {
2526
customVariables: boolean
2627
surfaces: boolean
2728
triggers: boolean
29+
userconfig: boolean
2830
}
2931

3032
export interface ClientPageInfo {
@@ -43,6 +45,7 @@ export interface ClientImportObject {
4345
customVariables: boolean
4446
surfaces: boolean
4547
triggers: boolean | Record<string, { name: string }>
48+
userconfig: boolean
4649
oldPageNumber?: number
4750
page?: ClientPageInfo
4851
pages?: Record<number, ClientPageInfo>

webui/src/ImportExport/Export.tsx

+5-5
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

@@ -163,13 +163,13 @@ function ExportOptionsStep({ config, setValue }: ExportOptionsStepProps) {
163163
label="Surfaces"
164164
/>
165165
</div>
166-
{/* <div className="indent3">
166+
<div className="indent3">
167167
<CFormCheck
168168
checked={config.userconfig}
169169
onChange={(e) => setValue('userconfig', e.currentTarget.checked)}
170-
label='Settings'
170+
label="Settings"
171171
/>
172-
</div> */}
172+
</div>
173173

174174
<div>
175175
<SelectExportFormat value={config.format} setValue={(val) => setValue('format', val)} label="File format" />

webui/src/ImportExport/Import/Full.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function FullImportTab({ snapshot }: FullImportTabProps) {
134134
surfaces: true,
135135
triggers: true,
136136
customVariables: true,
137-
// userconfig: true,
137+
userconfig: true,
138138
}))
139139

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

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

209-
{/* <InputCheckbox
209+
<InputCheckbox
210210
config={config}
211211
allowKeys={snapshotKeys}
212212
keyName="userconfig"
213213
setValue={setValue}
214214
label="Settings"
215-
/> */}
215+
/>
216216

217217
<CAlert color="info" className="margin-top">
218218
All the connections will be imported, as they are required to be able to import any actions and feedbacks.

0 commit comments

Comments
 (0)