diff --git a/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabStateUtil.ts b/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabStateUtil.ts index fb01bdc54..80ca16e72 100644 --- a/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabStateUtil.ts +++ b/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabStateUtil.ts @@ -11,11 +11,13 @@ export enum SubComponentName { ColumnSizes = "ColumnSizes", FilterHistory = "FilterHistory", MainTabDivider = "MainTabDivider", + ColumnsSelection = "ColumnsSelection", } export type ColumnSizesMap = { [columnId: string]: WidthDefinition }; export type WidthDefinition = { idealWidth?: number; minWidth?: number }; export type TabDivider = { leftPaneWidthPercent: number }; +export type ColumnsSelection = { selectedColumnIds: string[] }; /** * diff --git a/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.test.tsx b/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.test.tsx index 0ab116f63..ab6c8ee70 100644 --- a/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.test.tsx +++ b/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.test.tsx @@ -69,7 +69,7 @@ jest.mock("Explorer/Controls/Dialog", () => ({ useDialog: { getState: jest.fn(() => ({ showOkCancelModalDialog: (title: string, subText: string, okLabel: string, onOk: () => void) => onOk(), - showOkModalDialog: () => { }, + showOkModalDialog: () => {}, })), }, })); @@ -92,11 +92,13 @@ async function waitForComponentToPaint

(wrapper: ReactWrapper

| S describe("Documents tab (noSql API)", () => { describe("buildQuery", () => { it("should generate the right select query for SQL API", () => { - expect(buildQuery(false, "", ['pk'], { - paths: ['pk'], - kind: 'Hash', - version: 2, - })).toContain("select"); + expect( + buildQuery(false, "", ["pk"], { + paths: ["pk"], + kind: "Hash", + version: 2, + }), + ).toContain("select"); }); }); diff --git a/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx b/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx index 23c0b7671..4333b138e 100644 --- a/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx +++ b/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx @@ -470,6 +470,15 @@ export const showPartitionKey = (collection: ViewModels.CollectionBase, isPrefer }; // Export to expose to unit tests +/** + * Build default query + * @param isMongo true if mongo api + * @param filter + * @param partitionKeyProperties optional for mongo + * @param partitionKey optional for mongo + * @param additionalField + * @returns + */ export const buildQuery = ( isMongo: boolean, filter: string, @@ -647,11 +656,12 @@ export const DocumentsTabComponent: React.FunctionComponent { - const columnsIds = ["id"]; + const defaultColumnsIds = ["id"]; if (showPartitionKey(_collection, isPreferredApiMongoDB)) { - columnsIds.push(...partitionKeyPropertyHeaders); + defaultColumnsIds.push(...partitionKeyPropertyHeaders); } - return columnsIds; + + return readSubComponentState(SubComponentName.ColumnsSelection, _collection, defaultColumnsIds); }; const [selectedColumnIds, setSelectedColumnIds] = useState(getInitialColumnSelection); @@ -987,15 +997,15 @@ export const DocumentsTabComponent: React.FunctionComponent { - if (deletedCount === toDeleteDocumentIds.length && isAcknowledged) { - return toDeleteDocumentIds; - } - throw new Error(`Delete failed with deletedCount: ${deletedCount} and isAcknowledged: ${isAcknowledged}`); - }); + _collection.databaseId, + _collection as ViewModels.Collection, + toDeleteDocumentIds, + ).then(({ deletedCount, isAcknowledged }) => { + if (deletedCount === toDeleteDocumentIds.length && isAcknowledged) { + return toDeleteDocumentIds; + } + throw new Error(`Delete failed with deletedCount: ${deletedCount} and isAcknowledged: ${isAcknowledged}`); + }); return deletePromise .then( @@ -1068,8 +1078,8 @@ export const DocumentsTabComponent: React.FunctionComponent