diff --git a/package-lock.json b/package-lock.json index cd7b0f93e..d2dc5cbb1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15862,6 +15862,7 @@ "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, "hasInstallScript": true, "optional": true, "os": [ diff --git a/src/Common/DatabaseUtility.ts b/src/Common/DatabaseUtility.ts deleted file mode 100644 index c5b8538ff..000000000 --- a/src/Common/DatabaseUtility.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function getNewDatabaseSharedThroughputDefault(): boolean { - return false; -} diff --git a/src/Explorer/Panes/AddCollectionPanel/AddCollectionPanel.tsx b/src/Explorer/Panes/AddCollectionPanel/AddCollectionPanel.tsx index d598a3eb0..bb8fd7f24 100644 --- a/src/Explorer/Panes/AddCollectionPanel/AddCollectionPanel.tsx +++ b/src/Explorer/Panes/AddCollectionPanel/AddCollectionPanel.tsx @@ -17,7 +17,6 @@ import { } from "@fluentui/react"; import * as Constants from "Common/Constants"; import { createCollection } from "Common/dataAccess/createCollection"; -import { getNewDatabaseSharedThroughputDefault } from "Common/DatabaseUtility"; import { getErrorMessage, getErrorStack } from "Common/ErrorHandlingUtils"; import { configContext, Platform } from "ConfigContext"; import * as DataModels from "Contracts/DataModels"; @@ -77,7 +76,6 @@ export const DefaultVectorEmbeddingPolicy: DataModels.VectorEmbeddingPolicy = { export interface AddCollectionPanelState { createNewDatabase: boolean; newDatabaseId: string; - isSharedThroughputChecked: boolean; selectedDatabaseId: string; collectionId: string; enableIndexing: boolean; @@ -103,8 +101,6 @@ export interface AddCollectionPanelState { } export class AddCollectionPanel extends React.Component { - private newDatabaseThroughput: number; - private isNewDatabaseAutoscale: boolean; private collectionThroughput: number; private isCollectionAutoscale: boolean; private isCostAcknowledged: boolean; @@ -117,7 +113,6 @@ export class AddCollectionPanel extends React.Component - - {!isServerlessAccount() && ( - - , isChecked: boolean) => - this.setState({ isSharedThroughputChecked: isChecked }) - } - /> - - - - - )} - - {!isServerlessAccount() && this.state.isSharedThroughputChecked && ( - (this.newDatabaseThroughput = throughput)} - setIsAutoscale={(isAutoscale: boolean) => (this.isNewDatabaseAutoscale = isAutoscale)} - setIsThroughputCapExceeded={(isThroughputCapExceeded: boolean) => - this.setState({ isThroughputCapExceeded }) - } - onCostAcknowledgeChange={(isAcknowledge: boolean) => (this.isCostAcknowledged = isAcknowledge)} - /> - )} )} {!this.state.createNewDatabase && ( @@ -515,59 +455,57 @@ export class AddCollectionPanel extends React.Component )} - {userContext.apiType === "Mongo" && - (!this.state.isSharedThroughputChecked || - this.props.explorer.isFixedCollectionWithSharedThroughputSupported()) && ( - - - - - {t(Keys.panes.addCollection.sharding)} - - - - - - - - + + + + {t(Keys.panes.addCollection.sharding)} + + + - {t(Keys.panes.addCollection.unshardedLabel)} - - - {t(Keys.panes.addCollection.sharded)} - + - )} + + + + {t(Keys.panes.addCollection.unshardedLabel)} + + + {t(Keys.panes.addCollection.sharded)} + + + )} {this.state.isSharded && ( @@ -1191,7 +1129,7 @@ export class AddCollectionPanel extends React.Component CollectionCreation.DefaultCollectionRUs100K && !this.isCostAcknowledged) { - const errorMessage = this.isNewDatabaseAutoscale + const errorMessage = this.isCollectionAutoscale ? t(Keys.panes.addCollection.acknowledgeSpendErrorMonthly) : t(Keys.panes.addCollection.acknowledgeSpendErrorDaily); this.setState({ errorMessage }); @@ -1379,9 +1315,7 @@ export class AddCollectionPanel extends React.Component - - - - - - = ({ buttonElement, }: AddDatabasePaneProps) => { const closeSidePanel = useSidePanel((state) => state.closeSidePanel); - let throughput: number; - let isAutoscaleSelected: boolean; - let isCostAcknowledged: boolean; const { subscriptionType } = userContext; const isCassandraAccount: boolean = userContext.apiType === "Cassandra"; const databaseLabel: string = isCassandraAccount ? "keyspace" : "database"; @@ -49,23 +41,15 @@ export const AddDatabasePanel: FunctionComponent = ({ const [databaseId, setDatabaseId] = useState(""); const databaseIdTooltipText = t(Keys.panes.addDatabase.databaseTooltip, { databaseLabel, collectionsLabel }); - const databaseLevelThroughputTooltipText = t(Keys.panes.addDatabase.shareThroughputTooltip, { - databaseLabel, - collectionsLabel, - }); - const [databaseCreateNewShared, setDatabaseCreateNewShared] = useState( - getNewDatabaseSharedThroughputDefault(), - ); const [formErrors, setFormErrors] = useState(""); const [isExecuting, setIsExecuting] = useState(false); - const [isThroughputCapExceeded, setIsThroughputCapExceeded] = useState(false); const isFreeTierAccount: boolean = userContext.databaseAccount?.properties?.enableFreeTier; const addDatabasePaneMessage = { database: { id: databaseId, - shared: databaseCreateNewShared, + shared: false, }, subscriptionType: SubscriptionType[subscriptionType], subscriptionQuotaId: userContext.quotaId, @@ -76,9 +60,7 @@ export const AddDatabasePanel: FunctionComponent = ({ const addDatabasePaneOpenMessage = { subscriptionType: SubscriptionType[subscriptionType], subscriptionQuotaId: userContext.quotaId, - defaultsCheck: { - throughput, - }, + defaultsCheck: {}, dataExplorerArea: Constants.Areas.ContextualPane, }; TelemetryProcessor.trace(Action.CreateDatabase, ActionModifiers.Open, addDatabasePaneOpenMessage); @@ -88,13 +70,8 @@ export const AddDatabasePanel: FunctionComponent = ({ }, []); const onSubmit = () => { - if (!_isValid()) { - return; - } - const addDatabasePaneStartMessage = { ...addDatabasePaneMessage, - throughput, }; const startKey: number = TelemetryProcessor.traceStart(Action.CreateDatabase, addDatabasePaneStartMessage); setFormErrors(""); @@ -102,69 +79,41 @@ export const AddDatabasePanel: FunctionComponent = ({ const createDatabaseParams: DataModels.CreateDatabaseParams = { databaseId: addDatabasePaneStartMessage.database.id, - databaseLevelThroughput: addDatabasePaneStartMessage.database.shared, + databaseLevelThroughput: false, }; - if (isAutoscaleSelected) { - createDatabaseParams.autoPilotMaxThroughput = addDatabasePaneStartMessage.throughput; - } else { - createDatabaseParams.offerThroughput = addDatabasePaneStartMessage.throughput; - } createDatabase(createDatabaseParams).then( () => { - _onCreateDatabaseSuccess(throughput, startKey); + _onCreateDatabaseSuccess(startKey); }, (error: string) => { - _onCreateDatabaseFailure(error, throughput, startKey); + _onCreateDatabaseFailure(error, startKey); }, ); }; - const _onCreateDatabaseSuccess = (offerThroughput: number, startKey: number): void => { + const _onCreateDatabaseSuccess = (startKey: number): void => { setIsExecuting(false); closeSidePanel(); container.refreshAllDatabases(); const addDatabasePaneSuccessMessage = { ...addDatabasePaneMessage, - offerThroughput, }; TelemetryProcessor.traceSuccess(Action.CreateDatabase, addDatabasePaneSuccessMessage, startKey); }; - const _onCreateDatabaseFailure = (error: string, offerThroughput: number, startKey: number): void => { + const _onCreateDatabaseFailure = (error: string, startKey: number): void => { setIsExecuting(false); const errorMessage = getErrorMessage(error); setFormErrors(errorMessage); const addDatabasePaneFailedMessage = { ...addDatabasePaneMessage, - offerThroughput, error: errorMessage, errorStack: getErrorStack(error), }; TelemetryProcessor.traceFailure(Action.CreateDatabase, addDatabasePaneFailedMessage, startKey); }; - const _isValid = (): boolean => { - // TODO add feature flag that disables validation for customers with custom accounts - if (isAutoscaleSelected) { - if (!AutoPilotUtils.isValidAutoPilotThroughput(throughput)) { - setFormErrors(t(Keys.panes.addDatabase.greaterThanError, { minValue: AutoPilotUtils.autoPilotThroughput1K })); - return false; - } - } - - if (throughput > SharedConstants.CollectionCreation.DefaultCollectionRUs100K && !isCostAcknowledged) { - setFormErrors( - isAutoscaleSelected - ? t(Keys.panes.addDatabase.acknowledgeSpendErrorMonthly) - : t(Keys.panes.addDatabase.acknowledgeSpendErrorDaily), - ); - return false; - } - - return true; - }; - const handleonChangeDBId = React.useCallback( (event: React.FormEvent, newValue?: string) => { setDatabaseId(newValue || ""); @@ -176,7 +125,6 @@ export const AddDatabasePanel: FunctionComponent = ({ formError: formErrors, isExecuting, submitButtonText: t(Keys.common.ok), - isSubmitButtonDisabled: isThroughputCapExceeded, onSubmit, }; @@ -224,42 +172,7 @@ export const AddDatabasePanel: FunctionComponent = ({ data-lpignore={true} data-1p-ignore={true} /> - - {!isServerlessAccount() && ( - - setDatabaseCreateNewShared(!databaseCreateNewShared)} - /> - {databaseLevelThroughputTooltipText} - - )} - - {!isServerlessAccount() && databaseCreateNewShared && ( - (throughput = newThroughput)} - setIsAutoscale={(isAutoscale: boolean) => (isAutoscaleSelected = isAutoscale)} - setIsThroughputCapExceeded={(isCapExceeded: boolean) => setIsThroughputCapExceeded(isCapExceeded)} - onCostAcknowledgeChange={(isAcknowledged: boolean) => (isCostAcknowledged = isAcknowledged)} - /> - )} ); diff --git a/src/Explorer/Panes/AddDatabasePanel/__snapshots__/AddDatabasePanel.test.tsx.snap b/src/Explorer/Panes/AddDatabasePanel/__snapshots__/AddDatabasePanel.test.tsx.snap index 6d53644ab..c9ab614a6 100644 --- a/src/Explorer/Panes/AddDatabasePanel/__snapshots__/AddDatabasePanel.test.tsx.snap +++ b/src/Explorer/Panes/AddDatabasePanel/__snapshots__/AddDatabasePanel.test.tsx.snap @@ -4,7 +4,6 @@ exports[`AddDatabasePane Pane should render Default properly 1`] = ` @@ -61,42 +60,6 @@ exports[`AddDatabasePane Pane should render Default properly 1`] = ` type="text" value="" /> - - - - Provisioned throughput at the database level will be shared across all collections within the database. - - diff --git a/src/Explorer/Panes/CassandraAddCollectionPane/CassandraAddCollectionPane.test.tsx b/src/Explorer/Panes/CassandraAddCollectionPane/CassandraAddCollectionPane.test.tsx index 67944d7ab..4391be995 100644 --- a/src/Explorer/Panes/CassandraAddCollectionPane/CassandraAddCollectionPane.test.tsx +++ b/src/Explorer/Panes/CassandraAddCollectionPane/CassandraAddCollectionPane.test.tsx @@ -15,7 +15,7 @@ describe("Cassandra add collection pane test", () => { it("should render default properly", () => { expect(screen.getByRole("radio", { name: "Create new keyspace", checked: true })).toBeDefined(); - expect(screen.getByRole("checkbox", { name: "Provision shared throughput", checked: false })).toBeDefined(); + expect(screen.queryByRole("checkbox", { name: "Provision shared throughput" })).toBeNull(); }); it("click on use existing", () => { diff --git a/src/Explorer/Panes/CassandraAddCollectionPane/CassandraAddCollectionPane.tsx b/src/Explorer/Panes/CassandraAddCollectionPane/CassandraAddCollectionPane.tsx index 525373d64..dcbcdf379 100644 --- a/src/Explorer/Panes/CassandraAddCollectionPane/CassandraAddCollectionPane.tsx +++ b/src/Explorer/Panes/CassandraAddCollectionPane/CassandraAddCollectionPane.tsx @@ -1,4 +1,4 @@ -import { Checkbox, Dropdown, IDropdownOption, Link, Stack, Text, TextField } from "@fluentui/react"; +import { Dropdown, IDropdownOption, Link, Stack, Text, TextField } from "@fluentui/react"; import * as Constants from "Common/Constants"; import { getErrorMessage, getErrorStack } from "Common/ErrorHandlingUtils"; import { InfoTooltip } from "Common/Tooltip/InfoTooltip"; @@ -27,8 +27,6 @@ export const CassandraAddCollectionPane: FunctionComponent { - let newKeySpaceThroughput: number; - let isNewKeySpaceAutoscale: boolean; let tableThroughput: number; let isTableAutoscale: boolean; let isCostAcknowledged: boolean; @@ -52,7 +50,7 @@ export const CassandraAddCollectionPane: FunctionComponent { - const throughput = keyspaceCreateNew ? newKeySpaceThroughput : tableThroughput; + const throughput = tableThroughput; const keyspaceId = keyspaceCreateNew ? newKeyspaceId : existingKeyspaceId; if (throughput > SharedConstants.CollectionCreation.DefaultCollectionRUs100K && !isCostAcknowledged) { - const errorMessage = - isNewKeySpaceAutoscale || isTableAutoscale - ? t(Keys.panes.addCollection.acknowledgeSpendErrorMonthly) - : t(Keys.panes.addCollection.acknowledgeSpendErrorDaily); + const errorMessage = isTableAutoscale + ? t(Keys.panes.addCollection.acknowledgeSpendErrorMonthly) + : t(Keys.panes.addCollection.acknowledgeSpendErrorDaily); setFormError(errorMessage); return; } setIsExecuting(true); - const autoPilotCommand = `cosmosdb_autoscale_max_throughput`; const createKeyspaceQueryPrefix = `CREATE KEYSPACE ${keyspaceId.trim()} WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 }`; - const createKeyspaceQuery: string = isKeyspaceShared - ? isNewKeySpaceAutoscale - ? `${createKeyspaceQueryPrefix} AND ${autoPilotCommand}=${newKeySpaceThroughput};` - : `${createKeyspaceQueryPrefix} AND cosmosdb_provisioned_throughput=${newKeySpaceThroughput};` - : `${createKeyspaceQueryPrefix};`; + const createKeyspaceQuery = `${createKeyspaceQueryPrefix};`; let tableQuery: string; + const autoPilotCommand = `cosmosdb_autoscale_max_throughput`; const createTableQueryPrefix = `CREATE TABLE ${keyspaceId}.${tableId.trim()} ${userTableQuery}`; if (tableThroughput) { @@ -177,7 +170,6 @@ export const CassandraAddCollectionPane: FunctionComponent { setKeyspaceCreateNew(true); - setIsKeyspaceShared(false); setExistingKeyspaceId(""); }} /> @@ -192,7 +184,6 @@ export const CassandraAddCollectionPane: FunctionComponent { setKeyspaceCreateNew(false); - setIsKeyspaceShared(false); }} /> {t(Keys.panes.addCollection.useExisting)} @@ -214,25 +205,6 @@ export const CassandraAddCollectionPane: FunctionComponent - - {!isServerlessAccount() && ( - - , isChecked: boolean) => setIsKeyspaceShared(isChecked)} - /> - - Provisioned throughput at the keyspace level will be shared across unlimited number of tables within - the keyspace - - - )} )} @@ -256,21 +228,6 @@ export const CassandraAddCollectionPane: FunctionComponent )} - - {!isServerlessAccount() && keyspaceCreateNew && isKeyspaceShared && ( - (newKeySpaceThroughput = throughput)} - setIsAutoscale={(isAutoscale: boolean) => (isNewKeySpaceAutoscale = isAutoscale)} - setIsThroughputCapExceeded={(isCapExceeded: boolean) => setIsThroughputCapExceeded(isCapExceeded)} - onCostAcknowledgeChange={(isAcknowledged: boolean) => (isCostAcknowledged = isAcknowledged)} - /> - )} @@ -328,7 +285,7 @@ export const CassandraAddCollectionPane: FunctionComponent{t(Keys.panes.cassandraAddCollection.provisionDedicatedThroughputTooltip)} )} - {!isServerlessAccount() && (!isKeyspaceShared || dedicateTableThroughput) && ( + {!isServerlessAccount() && (keyspaceCreateNew || !isKeyspaceShared || dedicateTableThroughput) && (