mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-08 09:15:12 +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;
|
public partitionKey: DataModels.PartitionKey;
|
||||||
private documentIds: DocumentId[];
|
private documentIds: DocumentId[];
|
||||||
private title: string;
|
private title: string;
|
||||||
|
private resourceTokenPartitionKey: string;
|
||||||
|
|
||||||
constructor(options: ViewModels.DocumentsTabOptions) {
|
constructor(options: ViewModels.DocumentsTabOptions) {
|
||||||
super(options);
|
super(options);
|
||||||
@ -55,6 +56,7 @@ export class DocumentsTabV2 extends TabsBase {
|
|||||||
this.documentIds = options.documentIds();
|
this.documentIds = options.documentIds();
|
||||||
this.title = options.title;
|
this.title = options.title;
|
||||||
this.partitionKey = options.partitionKey;
|
this.partitionKey = options.partitionKey;
|
||||||
|
this.resourceTokenPartitionKey = options.resourceTokenPartitionKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(): JSX.Element {
|
public render(): JSX.Element {
|
||||||
@ -71,6 +73,7 @@ export class DocumentsTabV2 extends TabsBase {
|
|||||||
partitionKey={this.partitionKey}
|
partitionKey={this.partitionKey}
|
||||||
onLoadStartKey={this.onLoadStartKey}
|
onLoadStartKey={this.onLoadStartKey}
|
||||||
tabTitle={this.title}
|
tabTitle={this.title}
|
||||||
|
resourceTokenPartitionKey={this.resourceTokenPartitionKey}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -96,6 +99,7 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
|||||||
partitionKey: DataModels.PartitionKey;
|
partitionKey: DataModels.PartitionKey;
|
||||||
onLoadStartKey: number;
|
onLoadStartKey: number;
|
||||||
tabTitle: string;
|
tabTitle: string;
|
||||||
|
resourceTokenPartitionKey?: string;
|
||||||
}> = (props) => {
|
}> = (props) => {
|
||||||
const [isFilterCreated, setIsFilterCreated] = useState<boolean>(true);
|
const [isFilterCreated, setIsFilterCreated] = useState<boolean>(true);
|
||||||
const [isFilterExpanded, setIsFilterExpanded] = useState<boolean>(false);
|
const [isFilterExpanded, setIsFilterExpanded] = useState<boolean>(false);
|
||||||
@ -115,7 +119,6 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
|||||||
applyFilterButtonPressed: boolean;
|
applyFilterButtonPressed: boolean;
|
||||||
}>(undefined);
|
}>(undefined);
|
||||||
const [queryAbortController, setQueryAbortController] = useState<AbortController>(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 [isQueryCopilotSampleContainer, setIsQueryCopilotSampleContainer] = useState<boolean>(false); // TODO: Make this a constant is setter getting called
|
||||||
const [cancelQueryTimeoutID, setCancelQueryTimeoutID] = useState<NodeJS.Timeout>(undefined);
|
const [cancelQueryTimeoutID, setCancelQueryTimeoutID] = useState<NodeJS.Timeout>(undefined);
|
||||||
|
|
||||||
@ -540,8 +543,8 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
|||||||
? `the selected ${selectedRows.size} items`
|
? `the selected ${selectedRows.size} items`
|
||||||
: "the selected item"
|
: "the selected item"
|
||||||
: isPlural
|
: isPlural
|
||||||
? `the selected ${selectedRows.size} documents`
|
? `the selected ${selectedRows.size} documents`
|
||||||
: "the selected document";
|
: "the selected document";
|
||||||
const msg = `Are you sure you want to delete ${documentName}?`;
|
const msg = `Are you sure you want to delete ${documentName}?`;
|
||||||
|
|
||||||
useDialog.getState().showOkCancelModalDialog(
|
useDialog.getState().showOkCancelModalDialog(
|
||||||
@ -648,8 +651,8 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
|||||||
// TODO: Property 'enableCrossPartitionQuery' does not exist on type 'FeedOptions'.
|
// TODO: Property 'enableCrossPartitionQuery' does not exist on type 'FeedOptions'.
|
||||||
options.enableCrossPartitionQuery = HeadersUtility.shouldEnableCrossPartitionKey();
|
options.enableCrossPartitionQuery = HeadersUtility.shouldEnableCrossPartitionKey();
|
||||||
|
|
||||||
if (resourceTokenPartitionKey) {
|
if (props.resourceTokenPartitionKey) {
|
||||||
options.partitionKey = 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'.
|
// 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;
|
options.abortSignal = _queryAbortController.signal;
|
||||||
@ -1465,7 +1468,7 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
|||||||
<button
|
<button
|
||||||
className="filterbtnstyle queryButton"
|
className="filterbtnstyle queryButton"
|
||||||
onClick={onShowFilterClick}
|
onClick={onShowFilterClick}
|
||||||
/*data-bind="click: onShowFilterClick"*/
|
/*data-bind="click: onShowFilterClick"*/
|
||||||
>
|
>
|
||||||
Edit Filter
|
Edit Filter
|
||||||
</button>
|
</button>
|
||||||
@ -1515,7 +1518,7 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
|||||||
}
|
}
|
||||||
value={filterContent}
|
value={filterContent}
|
||||||
onChange={(e) => setFilterContent(e.target.value)}
|
onChange={(e) => setFilterContent(e.target.value)}
|
||||||
/*
|
/*
|
||||||
data-bind="
|
data-bind="
|
||||||
W attr:{
|
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.'
|
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}
|
tabIndex={0}
|
||||||
onClick={onHideFilterClick}
|
onClick={onHideFilterClick}
|
||||||
onKeyDown={onCloseButtonKeyDown}
|
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" />
|
<img src={CloseIcon} style={{ height: 14, width: 14 }} alt="Hide filter" />
|
||||||
</span>
|
</span>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { DocumentsTabV2 } from "Explorer/Tabs/DocumentsTabV2/DocumentsTabV2";
|
||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import * as Constants from "../../Common/Constants";
|
import * as Constants from "../../Common/Constants";
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
@ -7,7 +8,6 @@ import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
|||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
import { useTabs } from "../../hooks/useTabs";
|
import { useTabs } from "../../hooks/useTabs";
|
||||||
import Explorer from "../Explorer";
|
import Explorer from "../Explorer";
|
||||||
import DocumentsTab from "../Tabs/DocumentsTab";
|
|
||||||
import { NewQueryTab } from "../Tabs/QueryTab/QueryTab";
|
import { NewQueryTab } from "../Tabs/QueryTab/QueryTab";
|
||||||
import TabsBase from "../Tabs/TabsBase";
|
import TabsBase from "../Tabs/TabsBase";
|
||||||
import { useDatabases } from "../useDatabases";
|
import { useDatabases } from "../useDatabases";
|
||||||
@ -118,15 +118,15 @@ export default class ResourceTokenCollection implements ViewModels.CollectionBas
|
|||||||
dataExplorerArea: Constants.Areas.ResourceTree,
|
dataExplorerArea: Constants.Areas.ResourceTree,
|
||||||
});
|
});
|
||||||
|
|
||||||
const documentsTabs: DocumentsTab[] = useTabs
|
const documentsTabs: DocumentsTabV2[] = useTabs
|
||||||
.getState()
|
.getState()
|
||||||
.getTabs(
|
.getTabs(
|
||||||
ViewModels.CollectionTabKind.Documents,
|
ViewModels.CollectionTabKind.Documents,
|
||||||
(tab: TabsBase) =>
|
(tab: TabsBase) =>
|
||||||
tab.collection?.id() === this.id() &&
|
tab.collection?.id() === this.id() &&
|
||||||
(tab.collection as ViewModels.CollectionBase).databaseId === this.databaseId,
|
(tab.collection as ViewModels.CollectionBase).databaseId === this.databaseId,
|
||||||
) as DocumentsTab[];
|
) as DocumentsTabV2[];
|
||||||
let documentsTab: DocumentsTab = documentsTabs && documentsTabs[0];
|
let documentsTab: DocumentsTabV2 = documentsTabs && documentsTabs[0];
|
||||||
|
|
||||||
if (documentsTab) {
|
if (documentsTab) {
|
||||||
useTabs.getState().activateTab(documentsTab);
|
useTabs.getState().activateTab(documentsTab);
|
||||||
@ -139,7 +139,7 @@ export default class ResourceTokenCollection implements ViewModels.CollectionBas
|
|||||||
tabTitle: "Items",
|
tabTitle: "Items",
|
||||||
});
|
});
|
||||||
|
|
||||||
documentsTab = new DocumentsTab({
|
documentsTab = new DocumentsTabV2({
|
||||||
partitionKey: this.partitionKey,
|
partitionKey: this.partitionKey,
|
||||||
resourceTokenPartitionKey: userContext.parsedResourceToken?.partitionKey,
|
resourceTokenPartitionKey: userContext.parsedResourceToken?.partitionKey,
|
||||||
documentIds: ko.observableArray<DocumentId>([]),
|
documentIds: ko.observableArray<DocumentId>([]),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user