mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-01 13:46:41 +00:00
Fix resourceTokenPartitionKey code
This commit is contained in:
parent
0de2d6d899
commit
cf8533dea6
@ -48,6 +48,7 @@ export class DocumentsTabV2 extends TabsBase {
|
||||
public partitionKey: DataModels.PartitionKey;
|
||||
private documentIds: DocumentId[];
|
||||
private title: string;
|
||||
private resourceTokenPartitionKey: string;
|
||||
|
||||
constructor(options: ViewModels.DocumentsTabOptions) {
|
||||
super(options);
|
||||
@ -55,6 +56,7 @@ export class DocumentsTabV2 extends TabsBase {
|
||||
this.documentIds = options.documentIds();
|
||||
this.title = options.title;
|
||||
this.partitionKey = options.partitionKey;
|
||||
this.resourceTokenPartitionKey = options.resourceTokenPartitionKey;
|
||||
}
|
||||
|
||||
public render(): JSX.Element {
|
||||
@ -71,6 +73,7 @@ export class DocumentsTabV2 extends TabsBase {
|
||||
partitionKey={this.partitionKey}
|
||||
onLoadStartKey={this.onLoadStartKey}
|
||||
tabTitle={this.title}
|
||||
resourceTokenPartitionKey={this.resourceTokenPartitionKey}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@ -96,6 +99,7 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
||||
partitionKey: DataModels.PartitionKey;
|
||||
onLoadStartKey: number;
|
||||
tabTitle: string;
|
||||
resourceTokenPartitionKey?: string;
|
||||
}> = (props) => {
|
||||
const [isFilterCreated, setIsFilterCreated] = useState<boolean>(true);
|
||||
const [isFilterExpanded, setIsFilterExpanded] = useState<boolean>(false);
|
||||
@ -115,7 +119,6 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
||||
applyFilterButtonPressed: boolean;
|
||||
}>(undefined);
|
||||
const [queryAbortController, setQueryAbortController] = useState<AbortController>(undefined);
|
||||
const [resourceTokenPartitionKey, setResourceTokenPartitionKey] = useState<string>(undefined); // TODO: Make this a constant is setter getting called
|
||||
const [isQueryCopilotSampleContainer, setIsQueryCopilotSampleContainer] = useState<boolean>(false); // TODO: Make this a constant is setter getting called
|
||||
const [cancelQueryTimeoutID, setCancelQueryTimeoutID] = useState<NodeJS.Timeout>(undefined);
|
||||
|
||||
@ -540,8 +543,8 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
||||
? `the selected ${selectedRows.size} items`
|
||||
: "the selected item"
|
||||
: isPlural
|
||||
? `the selected ${selectedRows.size} documents`
|
||||
: "the selected document";
|
||||
? `the selected ${selectedRows.size} documents`
|
||||
: "the selected document";
|
||||
const msg = `Are you sure you want to delete ${documentName}?`;
|
||||
|
||||
useDialog.getState().showOkCancelModalDialog(
|
||||
@ -648,8 +651,8 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
||||
// TODO: Property 'enableCrossPartitionQuery' does not exist on type 'FeedOptions'.
|
||||
options.enableCrossPartitionQuery = HeadersUtility.shouldEnableCrossPartitionKey();
|
||||
|
||||
if (resourceTokenPartitionKey) {
|
||||
options.partitionKey = resourceTokenPartitionKey;
|
||||
if (props.resourceTokenPartitionKey) {
|
||||
options.partitionKey = props.resourceTokenPartitionKey;
|
||||
}
|
||||
// Fixes compile error error TS2741: Property 'throwIfAborted' is missing in type 'AbortSignal' but required in type 'import("/home/runner/work/cosmos-explorer/cosmos-explorer/node_modules/node-abort-controller/index").AbortSignal'.
|
||||
options.abortSignal = _queryAbortController.signal;
|
||||
@ -1465,7 +1468,7 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
||||
<button
|
||||
className="filterbtnstyle queryButton"
|
||||
onClick={onShowFilterClick}
|
||||
/*data-bind="click: onShowFilterClick"*/
|
||||
/*data-bind="click: onShowFilterClick"*/
|
||||
>
|
||||
Edit Filter
|
||||
</button>
|
||||
@ -1515,7 +1518,7 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
||||
}
|
||||
value={filterContent}
|
||||
onChange={(e) => setFilterContent(e.target.value)}
|
||||
/*
|
||||
/*
|
||||
data-bind="
|
||||
W attr:{
|
||||
placeholder:isPreferredApiMongoDB?'Type a query predicate (e.g., {´a´:´foo´}), or choose one from the drop down list, or leave empty to query all documents.':'Type a query predicate (e.g., WHERE c.id=´1´), or choose one from the drop down list, or leave empty to query all documents.'
|
||||
@ -1568,7 +1571,7 @@ textInput: filterContent"
|
||||
tabIndex={0}
|
||||
onClick={onHideFilterClick}
|
||||
onKeyDown={onCloseButtonKeyDown}
|
||||
/*data-bind="click: onHideFilterClick, event: { keydown: onCloseButtonKeyDown }"*/
|
||||
/*data-bind="click: onHideFilterClick, event: { keydown: onCloseButtonKeyDown }"*/
|
||||
>
|
||||
<img src={CloseIcon} style={{ height: 14, width: 14 }} alt="Hide filter" />
|
||||
</span>
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { DocumentsTabV2 } from "Explorer/Tabs/DocumentsTabV2/DocumentsTabV2";
|
||||
import * as ko from "knockout";
|
||||
import * as Constants from "../../Common/Constants";
|
||||
import * as DataModels from "../../Contracts/DataModels";
|
||||
@ -7,7 +8,6 @@ import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { userContext } from "../../UserContext";
|
||||
import { useTabs } from "../../hooks/useTabs";
|
||||
import Explorer from "../Explorer";
|
||||
import DocumentsTab from "../Tabs/DocumentsTab";
|
||||
import { NewQueryTab } from "../Tabs/QueryTab/QueryTab";
|
||||
import TabsBase from "../Tabs/TabsBase";
|
||||
import { useDatabases } from "../useDatabases";
|
||||
@ -118,15 +118,15 @@ export default class ResourceTokenCollection implements ViewModels.CollectionBas
|
||||
dataExplorerArea: Constants.Areas.ResourceTree,
|
||||
});
|
||||
|
||||
const documentsTabs: DocumentsTab[] = useTabs
|
||||
const documentsTabs: DocumentsTabV2[] = useTabs
|
||||
.getState()
|
||||
.getTabs(
|
||||
ViewModels.CollectionTabKind.Documents,
|
||||
(tab: TabsBase) =>
|
||||
tab.collection?.id() === this.id() &&
|
||||
(tab.collection as ViewModels.CollectionBase).databaseId === this.databaseId,
|
||||
) as DocumentsTab[];
|
||||
let documentsTab: DocumentsTab = documentsTabs && documentsTabs[0];
|
||||
) as DocumentsTabV2[];
|
||||
let documentsTab: DocumentsTabV2 = documentsTabs && documentsTabs[0];
|
||||
|
||||
if (documentsTab) {
|
||||
useTabs.getState().activateTab(documentsTab);
|
||||
@ -139,7 +139,7 @@ export default class ResourceTokenCollection implements ViewModels.CollectionBas
|
||||
tabTitle: "Items",
|
||||
});
|
||||
|
||||
documentsTab = new DocumentsTab({
|
||||
documentsTab = new DocumentsTabV2({
|
||||
partitionKey: this.partitionKey,
|
||||
resourceTokenPartitionKey: userContext.parsedResourceToken?.partitionKey,
|
||||
documentIds: ko.observableArray<DocumentId>([]),
|
||||
|
Loading…
x
Reference in New Issue
Block a user