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

nest new entries and message updates better #1595

Merged
merged 3 commits into from
Jun 30, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@
[original]="original?.[entry.key]"
[unionSpec]="spec.type === 'union' ? spec : undefined"
(onExpand)="resize(entry.key)"
(hasNewOptions)="setHasNew(entry.key)"
></form-object>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class FormObjectComponent {
@Input() original?: { [key: string]: any }
@Output() onInputChange = new EventEmitter<void>()
@Output() onExpand = new EventEmitter<void>()
@Output() hasNewOptions = new EventEmitter<void>()
warningAck: { [key: string]: boolean } = {}
unmasked: { [key: string]: boolean } = {}
objectDisplay: {
Expand Down Expand Up @@ -76,26 +77,17 @@ export class FormObjectComponent {
}
})
} else if (['object', 'union'].includes(spec.type)) {
let hasNewOptions = false

// We can only really show new children for objects, not unions.
if (spec.type === 'object') {
hasNewOptions = Object.keys(spec.spec).some(childKey => {
const parentValue = this.original?.[key]
return !!parentValue && parentValue[childKey] === undefined
})
} else if (spec.type === 'union') {
// @TODO
hasNewOptions = false
}

this.objectDisplay[key] = {
expanded: false,
height: '0px',
hasNewOptions,
hasNewOptions: false,
}
}
})

if (Object.values(this.original || {}).some(v => v === undefined)) {
this.hasNewOptions.emit()
}
}

getEnumListDisplay(arr: string[], spec: ListValueSpecOf<'enum'>): string {
Expand Down Expand Up @@ -213,6 +205,13 @@ export class FormObjectComponent {
this.onInputChange.emit()
}

setHasNew(key: string) {
this.hasNewOptions.emit()
setTimeout(() => {
this.objectDisplay[key].hasNewOptions = true
}, 100)
}

handleBooleanChange(key: string, spec: ValueSpecBoolean) {
if (spec.warning) {
const current = this.formGroup.get(key)?.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@
</ion-item>

<ng-template #noError>
<ion-item
<h2
*ngIf="hasConfig && !pkg.installed?.status?.configured && !configForm.dirty"
class="ion-padding-bottom"
>
<ion-label>
<ion-text color="success"
>To use the default config for {{ pkg.manifest.title }}, click
"Save" below.</ion-text
>
</ion-label>
</ion-item>
<ion-text color="success">
<span *ngIf="!original; else hasOriginal">
{{ pkg.manifest.title }} has been automatically configured with
recommended defaults. Make whatever changes you want, then click
"Save".
</span>
<ng-template #hasOriginal>
<span *ngIf="hasNewOptions"> New config options! </span>
</ng-template>
</ion-text>
</h2>

<!-- auto-config -->
<ion-item
Expand Down Expand Up @@ -82,6 +87,7 @@ <h2 style="display: flex; align-items: center">
[formGroup]="configForm"
[current]="configForm.value"
[original]="original"
(hasNewOptions)="hasNewOptions = true"
></form-object>
</form>
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class AppConfigPage {
configForm: FormGroup
original: object
hasConfig = false
hasNewOptions = false
saving = false
loadingError: string | IonicSafeString

Expand All @@ -61,7 +62,7 @@ export class AppConfigPage {

if (!this.hasConfig) return

let oldConfig: object
let oldConfig: object | null
let newConfig: object | undefined
let spec: ConfigSpec
let patch: Operation[] | undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
color="primary"
></ion-spinner>
<ng-template #bulb>
<div class="bulb" [style.background-color]="color$ | async"></div>
<div
class="bulb"
[style.background-color]="
(disconnected$ | async)
? 'var(--ion-color-dark)'
: 'var(--ion-color-' + this.pkg.primaryRendering.color + ')'
"
></div>
</ng-template>
</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ export class AppListIconComponent {
@Input()
pkg: PkgInfo

color$ = this.connectionService.watchDisconnected$().pipe(
map(disconnected => {
return disconnected
? 'var(--ion-color-dark)'
: 'var(--ion-color-' + this.pkg.primaryRendering.color + ')'
}),
)
disconnected$ = this.connectionService.watchDisconnected$()

constructor(private readonly connectionService: ConnectionService) {}
}