diff --git a/src/Explorer/Tabs/QueryTablesTab/QueryTableEntityClause.tsx b/src/Explorer/Tabs/QueryTablesTab/QueryTableEntityClause.tsx index 144229f96..d485d2abc 100644 --- a/src/Explorer/Tabs/QueryTablesTab/QueryTableEntityClause.tsx +++ b/src/Explorer/Tabs/QueryTablesTab/QueryTableEntityClause.tsx @@ -13,6 +13,7 @@ import { import React, { FunctionComponent } from "react"; import AddIcon from "../../../../images/Add.svg"; import CancelIcon from "../../../../images/cancel.svg"; +import { userContext } from "../../../UserContext"; import { IOption } from "./QueryTableTabUtils"; const dropdownStyles: Partial = { dropdown: { width: 100 } }; @@ -73,6 +74,15 @@ export const QueryTableEntityClause: FunctionComponent { + if (userContext.apiType === "Cassandra") { + return true; + } else if (selectedField === "PartitionKey" || selectedField === "RowKey" || selectedField === "Timestamp") { + return true; + } + return false; + }; + return ( <> @@ -115,7 +125,7 @@ export const QueryTableEntityClause: FunctionComponent { this.allQueryTableRows.push({ @@ -529,16 +532,73 @@ class QueryTablesTabComponent extends Component { const { tableEntityListViewModel } = this.state; tableEntityListViewModel.renderNextPageAndupdateCache(); + let headers: string[] = []; + let documents: any = {}; + if (userContext.apiType === "Cassandra") { + const query = `SELECT * FROM ${getQuotedCqlIdentifier( + this.props.queryTablesTab.collection.databaseId + )}.${getQuotedCqlIdentifier(this.props.queryTablesTab.collection.id())}`; + documents = await this.props.queryTablesTab.container.tableDataClient.queryDocuments( + this.props.queryTablesTab.collection, + query, + true + ); + headers = this.getFormattedHeaders(documents.Results); + this.setupIntialEntities(documents.Results, headers, isInitialLoad); + } else { + const { collection } = this.props; + documents = await this.getDocuments(collection, "Select * from c"); + headers = this.getFormattedHeaders(documents.Results); + this.setupIntialEntities(documents.Results, headers, isInitialLoad); + } - // setTimeout(() => { - // console.log( - // "🚀 ~ file: QueryTablesTabComponent.tsx ~ line 296 ~ QueryTablesTabComponent ~ componentDidMount ~ componentDidMount", - // this.state.tableEntityListViewModel.items() + // this.columns = []; + // headers.map((header) => { + // this.columns.push({ + // key: header, + // name: header, + // minWidth: 100, + // maxWidth: 200, + // data: "string", + // fieldName: header, + // isResizable: true, + // isSorted: true, + // isSortedDescending: false, + // sortAscendingAriaLabel: "Sorted A to Z", + // sortDescendingAriaLabel: "Sorted Z to A", + // }); + // }); + + // const documentItems = this.generateDetailsList(documents.Results); + // // const queryTableRowsClone = [...queryTableRows]; + // // queryTableRowsClone[0].fieldOptions = getformattedOptions(headers); + // this.setState( + // { + // columns: this.columns, + // headers, + // operators: this.state.queryViewModel.queryBuilderViewModel().operators(), + // isLoading: false, + // items: documentItems, + // entities: documents.Results, + // originalItems: documentItems, + // queryText: this.state.queryViewModel.queryText(), + // }, + // () => { + // if (isInitialLoad) { + // this.loadFilterExample(); + // // this.setDefaultItemSelection(); + // } + // } // ); - // const { queryTableRows } = this.state; - const { collection } = this.props; - const documents = await this.getDocuments(collection, "Select * from c"); - const headers = this.getFormattedHeaders(documents.Results); + + //If + } + + private setupIntialEntities = ( + entities: Entities.ITableEntity[], + headers: string[], + isInitialLoad: boolean + ): void => { this.columns = []; headers.map((header) => { this.columns.push({ @@ -556,7 +616,7 @@ class QueryTablesTabComponent extends Component { const selectedHeadersUnion: string[] = DataTableUtilities.getPropertyIntersectionFromTableEntities( @@ -980,14 +1038,23 @@ class QueryTablesTabComponent extends Component