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: add userconfig to import-export #2875

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions companion/lib/Data/ImportExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ export class DataImportExport extends CoreBase {
exp.surfaceGroups = this.surfaces.exportAllGroups(false)
}

if (!config || !isFalsey(config.userconfig)) {
exp.userconfig = this.userconfig.getAll(false)
}

return exp
}

Expand Down Expand Up @@ -548,6 +552,7 @@ export class DataImportExport extends CoreBase {
customVariables: 'custom_variables' in object,
surfaces: 'surfaces' in object,
triggers: 'triggers' in object,
userconfig: 'userconfig' in object,
}

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

// import userconfig
if (!config || config.userconfig) {
this.userconfig.setKeys(data.userconfig || {})
}

// import custom variables
if (!config || config.customVariables) {
this.variablesController.custom.replaceDefinitions(data.custom_variables || {})
Expand Down
16 changes: 16 additions & 0 deletions companion/lib/Data/UserConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,22 @@ export class DataUserConfig extends CoreBase {
})
}

/**
* Get the config settings
* @param {boolean} [clone = false] - <code>true</code> if a clone is needed instead of a link
* @returns {UserConfigModel} the config values
* @access public
*/
getAll(clone = false): UserConfigModel {
let out = this.#data

if (clone === true) {
out = cloneDeep(out)
}

return out
}

/**
* Get a specific use config setting
* @param key
Expand Down
3 changes: 2 additions & 1 deletion shared-lib/lib/Model/ExportModel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { UserConfigGridSize } from './UserConfigModel.js'
import type { UserConfigGridSize, UserConfigModel } from './UserConfigModel.js'
import type { ConnectionConfig } from './Connections.js'
import type { CustomVariablesModel } from './CustomVariableModel.js'

Expand All @@ -16,6 +16,7 @@ export interface ExportFullv4 extends ExportBase<'full'> {
instances?: ExportInstancesv4
surfaces?: unknown
surfaceGroups?: unknown
userconfig?: UserConfigModel
}

export interface ExportPageModelv4 extends ExportBase<'page'> {
Expand Down
3 changes: 3 additions & 0 deletions shared-lib/lib/Model/ImportExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface ClientExportSelection {
customVariables: boolean
connections: boolean
surfaces: boolean
userconfig: boolean

format: ExportFormat
}
Expand All @@ -25,6 +26,7 @@ export interface ClientImportSelection {
customVariables: boolean
surfaces: boolean
triggers: boolean
userconfig: boolean
}

export interface ClientPageInfo {
Expand All @@ -43,6 +45,7 @@ export interface ClientImportObject {
customVariables: boolean
surfaces: boolean
triggers: boolean | Record<string, { name: string }>
userconfig: boolean
oldPageNumber?: number
page?: ClientPageInfo
pages?: Record<number, ClientPageInfo>
Expand Down
Binary file removed webui/public/img/check.png
Binary file not shown.
7 changes: 7 additions & 0 deletions webui/public/img/check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions webui/public/img/indeterminate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions webui/src/ImportExport/Export.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const ExportWizardModal = forwardRef<ExportWizardModalRef, ExportWizardMo
surfaces: true,
triggers: true,
customVariables: true,
// userconfig: true,
userconfig: true,
format: ExportFormatDefault,
})

Expand Down Expand Up @@ -69,7 +69,7 @@ export const ExportWizardModal = forwardRef<ExportWizardModalRef, ExportWizardMo
surfaces: true,
triggers: true,
customVariables: true,
// userconfig: true,
userconfig: true,
format: ExportFormatDefault,
})

Expand Down Expand Up @@ -163,13 +163,13 @@ function ExportOptionsStep({ config, setValue }: ExportOptionsStepProps) {
label="Surfaces"
/>
</div>
{/* <div className="indent3">
<div className="indent3">
<CFormCheck
checked={config.userconfig}
onChange={(e) => setValue('userconfig', e.currentTarget.checked)}
label='Settings'
label="Settings"
/>
</div> */}
</div>

<div>
<SelectExportFormat value={config.format} setValue={(val) => setValue('format', val)} label="File format" />
Expand Down
6 changes: 3 additions & 3 deletions webui/src/ImportExport/Import/Full.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function FullImportTab({ snapshot }: FullImportTabProps) {
surfaces: true,
triggers: true,
customVariables: true,
// userconfig: true,
userconfig: true,
}))

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

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

{/* <InputCheckbox
<InputCheckbox
config={config}
allowKeys={snapshotKeys}
keyName="userconfig"
setValue={setValue}
label="Settings"
/> */}
/>

<CAlert color="info" className="margin-top">
All the connections will be imported, as they are required to be able to import any actions and feedbacks.
Expand Down
11 changes: 10 additions & 1 deletion webui/src/scss/_controls.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,20 @@
}

input[type='checkbox']:checked {
background: 0 0 url('/img/check.png') no-repeat;
background: 0 0 url('/img/check.svg');
background-repeat: no-repeat;
background-position: center;
background-size: contain;
}
input[type='checkbox']:disabled {
background: #eee;
}
input[type='checkbox']:indeterminate {
background: 0 0 url('/img/indeterminate.svg');
background-repeat: no-repeat;
background-position: center;
background-size: contain;
}
}

label.disabled {
Expand Down
Loading