offer bug

This commit is contained in:
sunghyunkang1111 2024-04-25 18:35:01 -05:00
parent 6894020faa
commit dfe7b645cd
7 changed files with 30 additions and 8 deletions

View File

@ -66,6 +66,7 @@ export interface MongoNotificationMessage {
export const hasDatabaseSharedThroughput = (collection: ViewModels.Collection): boolean => { export const hasDatabaseSharedThroughput = (collection: ViewModels.Collection): boolean => {
const database: ViewModels.Database = collection.getDatabase(); const database: ViewModels.Database = collection.getDatabase();
console.log(database?.isDatabaseShared(), collection.offer());
return database?.isDatabaseShared() && !collection.offer(); return database?.isDatabaseShared() && !collection.offer();
}; };

View File

@ -98,7 +98,11 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
// Only call when expand has actually changed // Only call when expand has actually changed
if (this.state.isExpanded !== prevState.isExpanded) { if (this.state.isExpanded !== prevState.isExpanded) {
if (this.state.isExpanded) { if (this.state.isExpanded) {
this.props.node.onExpanded && setTimeout(this.props.node.onExpanded, TreeNodeComponent.callbackDelayMS); console.log("IN HERE");
this.props.node.onExpanded &&
setTimeout(async () => {
await this.props.node.onExpanded();
}, TreeNodeComponent.callbackDelayMS);
} else { } else {
this.props.node.onCollapsed && setTimeout(this.props.node.onCollapsed, TreeNodeComponent.callbackDelayMS); this.props.node.onCollapsed && setTimeout(this.props.node.onCollapsed, TreeNodeComponent.callbackDelayMS);
} }

View File

@ -336,7 +336,8 @@ exports[`AddCollectionPanel should render Default properly 1`] = `
directionalHint={4} directionalHint={4}
> >
<Icon <Icon
ariaLabel="Enable analytical store capability to perform near real-time analytics on your operational data, without impacting the performance of transactional workloads." ariaLabel="Enable analytical store capability to perform near real-time analytics on your operational data, without
impacting the performance of transactional workloads."
className="panelInfoIcon" className="panelInfoIcon"
iconName="Info" iconName="Info"
tabIndex={0} tabIndex={0}

View File

@ -109,6 +109,8 @@ export const QueryResultSection: React.FC<QueryResultProps> = ({
: JSON.stringify(queryResults.documents, undefined, 4) : JSON.stringify(queryResults.documents, undefined, 4)
: ""; : "";
console.log("QUERY RESULT: ", queryResultsString);
const onErrorDetailsClick = (): boolean => { const onErrorDetailsClick = (): boolean => {
useNotificationConsole.getState().expandConsole(); useNotificationConsole.getState().expandConsole();

View File

@ -357,6 +357,7 @@ export default class QueryTabComponent extends React.Component<IQueryTabComponen
firstItemIndex, firstItemIndex,
queryDocuments, queryDocuments,
); );
console.log("SETTING QUERY RESULTS", queryResults);
this.setState({ queryResults, error: "" }); this.setState({ queryResults, error: "" });
} catch (error) { } catch (error) {
this.props.tabsBaseInstance.isExecutionError(true); this.props.tabsBaseInstance.isExecutionError(true);

View File

@ -264,12 +264,16 @@ export default class Collection implements ViewModels.Collection {
}); });
} }
public expandCollection(): void { public async expandCollection(): Promise<void> {
if (this.isCollectionExpanded()) { if (this.isCollectionExpanded()) {
return; return;
} }
const throughputCap = userContext.databaseAccount?.properties.capacity?.totalThroughputLimit;
throughputCap && throughputCap !== -1 ? await useDatabases.getState().loadAllOffers() : await this.loadOffer();
console.log("LOADED OFFERS", this.offer());
this.isCollectionExpanded(true); this.isCollectionExpanded(true);
TelemetryProcessor.trace(Action.ExpandTreeNode, ActionModifiers.Mark, { TelemetryProcessor.trace(Action.ExpandTreeNode, ActionModifiers.Mark, {
description: "Collection node", description: "Collection node",
@ -576,8 +580,8 @@ export default class Collection implements ViewModels.Collection {
public onSettingsClick = async (): Promise<void> => { public onSettingsClick = async (): Promise<void> => {
useSelectedNode.getState().setSelectedNode(this); useSelectedNode.getState().setSelectedNode(this);
const throughputCap = userContext.databaseAccount?.properties.capacity?.totalThroughputLimit; // const throughputCap = userContext.databaseAccount?.properties.capacity?.totalThroughputLimit;
throughputCap && throughputCap !== -1 ? await useDatabases.getState().loadAllOffers() : await this.loadOffer(); // throughputCap && throughputCap !== -1 ? await useDatabases.getState().loadAllOffers() : await this.loadOffer();
this.selectedSubnodeKind(ViewModels.CollectionTabKind.Settings); this.selectedSubnodeKind(ViewModels.CollectionTabKind.Settings);
TelemetryProcessor.trace(Action.SelectItem, ActionModifiers.Mark, { TelemetryProcessor.trace(Action.SelectItem, ActionModifiers.Mark, {
description: "Settings node", description: "Settings node",

View File

@ -1,4 +1,5 @@
import { Callout, DirectionalHint, ICalloutProps, ILinkProps, Link, Stack, Text } from "@fluentui/react"; import { Callout, DirectionalHint, ICalloutProps, ILinkProps, Link, Stack, Text } from "@fluentui/react";
import { hasDatabaseSharedThroughput } from "Explorer/Controls/Settings/SettingsUtils";
import { SampleDataTree } from "Explorer/Tree/SampleDataTree"; import { SampleDataTree } from "Explorer/Tree/SampleDataTree";
import { getItemName } from "Utils/APITypeUtils"; import { getItemName } from "Utils/APITypeUtils";
import { useQueryCopilot } from "hooks/useQueryCopilot"; import { useQueryCopilot } from "hooks/useQueryCopilot";
@ -548,9 +549,11 @@ export const ResourceTree: React.FC<ResourceTreeProps> = ({ container }: Resourc
id = database.isDatabaseShared() ? "sampleSettings" : "sampleScaleSettings"; id = database.isDatabaseShared() ? "sampleSettings" : "sampleScaleSettings";
} }
console.log("RUNNING HERE", database.id(), database.offer(), collection.id(), collection.offer());
children.push({ children.push({
id, id,
label: database.isDatabaseShared() || isServerlessAccount() ? "Settings" : "Scale & Settings", label: hasDatabaseSharedThroughput(collection) || isServerlessAccount() ? "Settings" : "Scale & Settings",
onClick: collection.onSettingsClick.bind(collection), onClick: collection.onSettingsClick.bind(collection),
isSelected: () => isSelected: () =>
useSelectedNode useSelectedNode
@ -598,6 +601,7 @@ export const ResourceTree: React.FC<ResourceTreeProps> = ({ container }: Resourc
contextMenu: ResourceTreeContextMenuButtonFactory.createCollectionContextMenuButton(container, collection), contextMenu: ResourceTreeContextMenuButtonFactory.createCollectionContextMenuButton(container, collection),
onClick: () => { onClick: () => {
// Rewritten version of expandCollapseCollection // Rewritten version of expandCollapseCollection
console.log("CLICKED onClick");
useSelectedNode.getState().setSelectedNode(collection); useSelectedNode.getState().setSelectedNode(collection);
useCommandBar.getState().setContextButtons([]); useCommandBar.getState().setContextButtons([]);
refreshActiveTab( refreshActiveTab(
@ -605,13 +609,18 @@ export const ResourceTree: React.FC<ResourceTreeProps> = ({ container }: Resourc
tab.collection?.id() === collection.id() && tab.collection.databaseId === collection.databaseId, tab.collection?.id() === collection.id() && tab.collection.databaseId === collection.databaseId,
); );
}, },
onExpanded: () => { onExpanded: async () => {
console.log("CLICKED onExpanded");
await collection.expandCollection();
if (showScriptNodes) { if (showScriptNodes) {
collection.loadStoredProcedures(); collection.loadStoredProcedures();
collection.loadUserDefinedFunctions(); collection.loadUserDefinedFunctions();
collection.loadTriggers(); collection.loadTriggers();
} }
}, },
onCollapsed: () => {
collection.collapseCollection();
},
isSelected: () => useSelectedNode.getState().isDataNodeSelected(collection.databaseId, collection.id()), isSelected: () => useSelectedNode.getState().isDataNodeSelected(collection.databaseId, collection.id()),
onContextMenuOpen: () => useSelectedNode.getState().setSelectedNode(collection), onContextMenuOpen: () => useSelectedNode.getState().setSelectedNode(collection),
}; };