Make datalist for filter unique per database/container combination
This commit is contained in:
parent
4fda518a3f
commit
bf1474e101
|
@ -19,7 +19,7 @@ import {
|
|||
getSaveExistingDocumentButtonState,
|
||||
getSaveNewDocumentButtonState,
|
||||
getTabsButtons,
|
||||
showPartitionKey,
|
||||
showPartitionKey
|
||||
} from "Explorer/Tabs/DocumentsTabV2/DocumentsTabV2";
|
||||
import { ReactWrapper, ShallowWrapper, mount, shallow } from "enzyme";
|
||||
import * as ko from "knockout";
|
||||
|
@ -68,7 +68,7 @@ jest.mock("Explorer/Controls/Dialog", () => ({
|
|||
useDialog: {
|
||||
getState: jest.fn(() => ({
|
||||
showOkCancelModalDialog: (title: string, subText: string, okLabel: string, onOk: () => void) => onOk(),
|
||||
showOkModalDialog: () => {},
|
||||
showOkModalDialog: () => { },
|
||||
})),
|
||||
},
|
||||
}));
|
||||
|
@ -474,3 +474,9 @@ describe("Documents tab (noSql API)", () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Documents tab", () => {
|
||||
it("should add strings to array without duplicate", () => {
|
||||
addStringsNoDuplicates(test this);
|
||||
});
|
||||
});
|
|
@ -459,6 +459,8 @@ export interface IDocumentsTabComponentProps {
|
|||
isTabActive: boolean;
|
||||
}
|
||||
|
||||
const getUniqueId = (collection: ViewModels.CollectionBase): string => `${collection.databaseId}-${collection.id()}`;
|
||||
|
||||
const defaultSqlFilters = ['WHERE c.id = "foo"', "ORDER BY c._ts DESC", 'WHERE c.id = "foo" ORDER BY c._ts DESC'];
|
||||
const defaultMongoFilters = ['{"id":"foo"}', "{ qty: { $gte: 20 } }"];
|
||||
|
||||
|
@ -1756,7 +1758,7 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
|
|||
id="filterInput"
|
||||
ref={filterInput}
|
||||
type="text"
|
||||
list="filtersList"
|
||||
list={`filtersList-${getUniqueId(_collection)}`}
|
||||
className={`${filterContent.length === 0 ? "placeholderVisible" : ""}`}
|
||||
style={{ width: "100%" }}
|
||||
title="Type a query predicate or choose one from the list."
|
||||
|
@ -1772,7 +1774,7 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
|
|||
onBlur={() => setIsFilterFocused(false)}
|
||||
/>
|
||||
|
||||
<datalist id="filtersList">
|
||||
<datalist id={`filtersList-${getUniqueId(_collection)}`}>
|
||||
{addStringsNoDuplicate(
|
||||
lastFilterContents,
|
||||
isPreferredApiMongoDB ? defaultMongoFilters : defaultSqlFilters,
|
||||
|
|
Loading…
Reference in New Issue