mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-13 11:45:15 +00:00
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
|
/**
|
||
|
* This adapter is responsible to render the QueriesGrid React component
|
||
|
* If the component signals a change through the callback passed in the properties, it must render the React component when appropriate
|
||
|
* and update any knockout observables passed from the parent.
|
||
|
*/
|
||
|
import * as ko from "knockout";
|
||
|
import * as React from "react";
|
||
|
import * as ViewModels from "../../../Contracts/ViewModels";
|
||
|
import { QueriesGridComponent, QueriesGridComponentProps } from "./QueriesGridComponent";
|
||
|
import { ReactAdapter } from "../../../Bindings/ReactBindingHandler";
|
||
|
|
||
|
export class QueriesGridComponentAdapter implements ReactAdapter {
|
||
|
public parameters: ko.Observable<number>;
|
||
|
|
||
|
constructor(private container: ViewModels.Explorer) {
|
||
|
this.parameters = ko.observable<number>(Date.now());
|
||
|
}
|
||
|
|
||
|
public renderComponent(): JSX.Element {
|
||
|
const props: QueriesGridComponentProps = {
|
||
|
queriesClient: this.container.queriesClient,
|
||
|
onQuerySelect: this.container.browseQueriesPane.loadSavedQuery,
|
||
|
containerVisible: this.container.browseQueriesPane.visible(),
|
||
|
saveQueryEnabled: this.container.canSaveQueries()
|
||
|
};
|
||
|
return <QueriesGridComponent {...props} />;
|
||
|
}
|
||
|
|
||
|
public forceRender(): void {
|
||
|
window.requestAnimationFrame(() => this.parameters(Date.now()));
|
||
|
}
|
||
|
}
|