Skip to content

Commit

Permalink
Merge pull request #557 from BalticAmadeus/556-indexes-view-in-not-wo…
Browse files Browse the repository at this point in the history
…rking

fix indexes not working
abelzis authored Mar 19, 2024
2 parents 0c992fa + cec988e commit b12f24a
Showing 3 changed files with 9 additions and 21 deletions.
9 changes: 1 addition & 8 deletions src/view/app/Indexes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
import { createRoot } from 'react-dom/client';
import { TableDetails } from '@app/model';
import './indexes.css';
import Indexes from './indexes';
import { ISettings } from '@src/common/IExtensionSettings';

declare global {
interface Window {
acquireVsCodeApi(): any;
tableDetails: TableDetails;
configuration: ISettings;
}
}

const root = createRoot(document.getElementById('root'));
root.render(
<Indexes
tableDetails={window.tableDetails}
configuration={window.configuration}
/>
);
root.render(<Indexes />);
17 changes: 6 additions & 11 deletions src/view/app/Indexes/indexes.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import * as React from 'react';
import { useState, useMemo } from 'react';
import { CommandAction, IndexRow, TableDetails } from '../model';
import { CommandAction, IndexRow } from '../model';
import DataGrid from 'react-data-grid';
import type { SortColumn } from 'react-data-grid';
import * as columnName from './column.json';
import { Logger } from '../../../common/Logger';
import { ISettings } from '../../../common/IExtensionSettings';
import { getVSCodeAPI } from '@utils/vscode';

interface IConfigProps {
tableDetails: TableDetails;
configuration: ISettings;
}
import { getVSCodeAPI, getVSCodeConfiguration } from '@utils/vscode';

type Comparator = (a: IndexRow, b: IndexRow) => number;
function getComparator(sortColumn: string): Comparator {
@@ -31,16 +25,17 @@ function rowKeyGetter(row: IndexRow) {
return row.cName;
}

function Indexes({ tableDetails, configuration }: IConfigProps) {
const [rows, setRows] = useState(tableDetails.indexes);
function Indexes() {
const [rows, setRows] = useState<IndexRow[]>([]);
const [dataLoaded, setDataLoaded] = useState(false);
const [sortColumns, setSortColumns] = useState<readonly SortColumn[]>([]);
const [selectedRows, setSelectedRows] = useState<ReadonlySet<string>>(
() => new Set()
);
const [windowHeight, setWindowHeight] = React.useState(window.innerHeight);
const logger = new Logger(configuration.logging.react);
const vscode = getVSCodeAPI();
const configuration = getVSCodeConfiguration();
const logger = new Logger(configuration.logging.react);

const windowRezise = () => {
setWindowHeight(window.innerHeight);
4 changes: 2 additions & 2 deletions src/webview/PanelViewProvider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path = require('path');
import * as vscode from 'vscode';
import { Constants } from '../common/Constants';
import { CommandAction, ICommand, TableDetails } from '../view/app/model';
import { CommandAction, ICommand } from '../view/app/model';
import { TableNode } from '../treeview/TableNode';
import { TablesListProvider } from '../treeview/TablesListProvider';
import { FavoritesProvider } from '../treeview/FavoritesProvider';
@@ -32,7 +32,7 @@ export class PanelViewProvider implements vscode.WebviewViewProvider {
};
this._view.webview.html = this.getWebviewContent();

this._view.onDidChangeVisibility((ev) => {
this._view.onDidChangeVisibility(() => {
if (this._view?.visible) {
if (this.tableNode) {
this.tableListProvider?.displayData(this.tableNode);

0 comments on commit b12f24a

Please sign in to comment.