mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-29 17:06:58 +00:00
Make datalist for filter unique per database/container combination
This commit is contained in:
parent
4fda518a3f
commit
bf1474e101
@ -19,7 +19,7 @@ import {
|
|||||||
getSaveExistingDocumentButtonState,
|
getSaveExistingDocumentButtonState,
|
||||||
getSaveNewDocumentButtonState,
|
getSaveNewDocumentButtonState,
|
||||||
getTabsButtons,
|
getTabsButtons,
|
||||||
showPartitionKey,
|
showPartitionKey
|
||||||
} from "Explorer/Tabs/DocumentsTabV2/DocumentsTabV2";
|
} from "Explorer/Tabs/DocumentsTabV2/DocumentsTabV2";
|
||||||
import { ReactWrapper, ShallowWrapper, mount, shallow } from "enzyme";
|
import { ReactWrapper, ShallowWrapper, mount, shallow } from "enzyme";
|
||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
@ -68,7 +68,7 @@ jest.mock("Explorer/Controls/Dialog", () => ({
|
|||||||
useDialog: {
|
useDialog: {
|
||||||
getState: jest.fn(() => ({
|
getState: jest.fn(() => ({
|
||||||
showOkCancelModalDialog: (title: string, subText: string, okLabel: string, onOk: () => void) => onOk(),
|
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;
|
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 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 } }"];
|
const defaultMongoFilters = ['{"id":"foo"}', "{ qty: { $gte: 20 } }"];
|
||||||
|
|
||||||
@ -1756,7 +1758,7 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
|
|||||||
id="filterInput"
|
id="filterInput"
|
||||||
ref={filterInput}
|
ref={filterInput}
|
||||||
type="text"
|
type="text"
|
||||||
list="filtersList"
|
list={`filtersList-${getUniqueId(_collection)}`}
|
||||||
className={`${filterContent.length === 0 ? "placeholderVisible" : ""}`}
|
className={`${filterContent.length === 0 ? "placeholderVisible" : ""}`}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
title="Type a query predicate or choose one from the list."
|
title="Type a query predicate or choose one from the list."
|
||||||
@ -1772,7 +1774,7 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
|
|||||||
onBlur={() => setIsFilterFocused(false)}
|
onBlur={() => setIsFilterFocused(false)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<datalist id="filtersList">
|
<datalist id={`filtersList-${getUniqueId(_collection)}`}>
|
||||||
{addStringsNoDuplicate(
|
{addStringsNoDuplicate(
|
||||||
lastFilterContents,
|
lastFilterContents,
|
||||||
isPreferredApiMongoDB ? defaultMongoFilters : defaultSqlFilters,
|
isPreferredApiMongoDB ? defaultMongoFilters : defaultSqlFilters,
|
||||||
|
Loading…
Reference in New Issue
Block a user