mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Arc - Fix KeyValueContainer refresh (#11077)
This commit is contained in:
@@ -11,24 +11,37 @@ import { IconPathHelper, cssStyles } from '../../constants';
|
|||||||
/** A container with a single vertical column of KeyValue pairs */
|
/** A container with a single vertical column of KeyValue pairs */
|
||||||
export class KeyValueContainer {
|
export class KeyValueContainer {
|
||||||
public container: azdata.DivContainer;
|
public container: azdata.DivContainer;
|
||||||
|
private keyToComponent: Map<string, (azdata.TextComponent | azdata.InputBoxComponent)>;
|
||||||
|
|
||||||
constructor(private modelBuilder: azdata.ModelBuilder, pairs: KeyValue[]) {
|
constructor(private modelBuilder: azdata.ModelBuilder, pairs: KeyValue[]) {
|
||||||
this.container = modelBuilder.divContainer().component();
|
this.container = modelBuilder.divContainer().component();
|
||||||
|
this.keyToComponent = new Map<string, azdata.Component>();
|
||||||
this.refresh(pairs);
|
this.refresh(pairs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Support removing KeyValues, and handle race conditions when
|
||||||
|
// adding/removing KeyValues concurrently. For now this should only be used
|
||||||
|
// when the set of keys won't change (though their values can be refreshed).
|
||||||
public refresh(pairs: KeyValue[]) {
|
public refresh(pairs: KeyValue[]) {
|
||||||
this.container.clearItems();
|
pairs.forEach(p => {
|
||||||
this.container.addItems(
|
let component = this.keyToComponent.get(p.key);
|
||||||
pairs.map(p => p.getComponent(this.modelBuilder)),
|
if (component) {
|
||||||
{ CSSStyles: { 'margin-bottom': '15px', 'min-height': '30px' } }
|
component.value = p.value;
|
||||||
);
|
} else {
|
||||||
|
component = p.getComponent(this.modelBuilder);
|
||||||
|
this.keyToComponent.set(p.key, component);
|
||||||
|
this.container.addItem(
|
||||||
|
component,
|
||||||
|
{ CSSStyles: { 'margin-bottom': '15px', 'min-height': '30px' } }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A key value pair in the KeyValueContainer */
|
/** A key value pair in the KeyValueContainer */
|
||||||
export abstract class KeyValue {
|
export abstract class KeyValue {
|
||||||
constructor(protected key: string, protected value: string) { }
|
constructor(public key: string, public value: string) { }
|
||||||
|
|
||||||
/** Returns a component representing the entire KeyValue pair */
|
/** Returns a component representing the entire KeyValue pair */
|
||||||
public getComponent(modelBuilder: azdata.ModelBuilder) {
|
public getComponent(modelBuilder: azdata.ModelBuilder) {
|
||||||
|
|||||||
@@ -383,7 +383,6 @@ export class PostgresOverviewPage extends DashboardPage {
|
|||||||
|
|
||||||
this.nodesTable!.data = this.getNodes();
|
this.nodesTable!.data = this.getNodes();
|
||||||
this.nodesTableLoading!.loading = false;
|
this.nodesTableLoading!.loading = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private handlePodsUpdated() {
|
private handlePodsUpdated() {
|
||||||
|
|||||||
Reference in New Issue
Block a user