Skip to content

Commit 1529303

Browse files
authored
Fabric native: use SDK not ARM for update offers/collections. Enable Delete Container context menu item in resource tree (#2069)
* For all control plane operations, do not use ARM for Fabric. Enable "delete container" for fabric native. * Fix unit test * Fix tre note tests with proper fabric config. Add new fabric non-readonly test.
1 parent 083bccf commit 1529303

8 files changed

+232
-35
lines changed

src/Common/dataAccess/createCollection.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ContainerRequest, ContainerResponse, DatabaseRequest, DatabaseResponse, RequestOptions } from "@azure/cosmos";
2+
import { isFabricNative } from "Platform/Fabric/FabricUtil";
23
import { AuthType } from "../../AuthType";
34
import * as DataModels from "../../Contracts/DataModels";
45
import { useDatabases } from "../../Explorer/useDatabases";
@@ -24,7 +25,7 @@ export const createCollection = async (params: DataModels.CreateCollectionParams
2425
);
2526
try {
2627
let collection: DataModels.Collection;
27-
if (userContext.authType === AuthType.AAD && !userContext.features.enableSDKoperations) {
28+
if (!isFabricNative() && userContext.authType === AuthType.AAD && !userContext.features.enableSDKoperations) {
2829
if (params.createNewDatabase) {
2930
const createDatabaseParams: DataModels.CreateDatabaseParams = {
3031
autoPilotMaxThroughput: params.autoPilotMaxThroughput,

src/Common/dataAccess/deleteCollection.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isFabric } from "Platform/Fabric/FabricUtil";
12
import { AuthType } from "../../AuthType";
23
import { userContext } from "../../UserContext";
34
import { deleteCassandraTable } from "../../Utils/arm/generatedClients/cosmos/cassandraResources";
@@ -12,7 +13,7 @@ import { handleError } from "../ErrorHandlingUtils";
1213
export async function deleteCollection(databaseId: string, collectionId: string): Promise<void> {
1314
const clearMessage = logConsoleProgress(`Deleting container ${collectionId}`);
1415
try {
15-
if (userContext.authType === AuthType.AAD && !userContext.features.enableSDKoperations) {
16+
if (userContext.authType === AuthType.AAD && !userContext.features.enableSDKoperations && !isFabric()) {
1617
await deleteCollectionWithARM(databaseId, collectionId);
1718
} else {
1819
await client().database(databaseId).container(collectionId).delete();

src/Common/dataAccess/readDatabaseOffer.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isFabric, isFabricMirroredKey } from "Platform/Fabric/FabricUtil";
1+
import { isFabric, isFabricMirroredKey, isFabricNative } from "Platform/Fabric/FabricUtil";
22
import { AuthType } from "../../AuthType";
33
import { Offer, ReadDatabaseOfferParams } from "../../Contracts/DataModels";
44
import { userContext } from "../../UserContext";
@@ -11,8 +11,9 @@ import { handleError } from "../ErrorHandlingUtils";
1111
import { readOfferWithSDK } from "./readOfferWithSDK";
1212

1313
export const readDatabaseOffer = async (params: ReadDatabaseOfferParams): Promise<Offer> => {
14-
if (isFabricMirroredKey()) {
15-
// TODO This works, but is very slow, because it requests the token, so we skip for now
14+
if (isFabricMirroredKey() || isFabricNative()) {
15+
// For Fabric Mirroring, it is slow, because it requests the token and we don't need it.
16+
// For Fabric Native, it is not supported.
1617
console.error("Skiping readDatabaseOffer for Fabric");
1718
return undefined;
1819
}

src/Common/dataAccess/updateCollection.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ContainerDefinition, RequestOptions } from "@azure/cosmos";
2+
import { isFabric } from "Platform/Fabric/FabricUtil";
23
import { AuthType } from "../../AuthType";
34
import { Collection } from "../../Contracts/DataModels";
45
import { userContext } from "../../UserContext";
@@ -36,7 +37,8 @@ export async function updateCollection(
3637
if (
3738
userContext.authType === AuthType.AAD &&
3839
!userContext.features.enableSDKoperations &&
39-
userContext.apiType !== "Tables"
40+
userContext.apiType !== "Tables" &&
41+
!isFabric()
4042
) {
4143
collection = await updateCollectionWithARM(databaseId, collectionId, newCollection);
4244
} else {

src/Common/dataAccess/updateOffer.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { OfferDefinition, RequestOptions } from "@azure/cosmos";
2+
import { isFabric } from "Platform/Fabric/FabricUtil";
23
import { AuthType } from "../../AuthType";
34
import { Offer, SDKOfferDefinition, ThroughputBucket, UpdateOfferParams } from "../../Contracts/DataModels";
45
import { userContext } from "../../UserContext";
@@ -56,7 +57,7 @@ export const updateOffer = async (params: UpdateOfferParams): Promise<Offer> =>
5657
const clearMessage = logConsoleProgress(`Updating offer for ${offerResourceText}`);
5758

5859
try {
59-
if (userContext.authType === AuthType.AAD && !userContext.features.enableSDKoperations) {
60+
if (userContext.authType === AuthType.AAD && !userContext.features.enableSDKoperations && !isFabric()) {
6061
if (params.collectionId) {
6162
updatedOffer = await updateCollectionOfferWithARM(params);
6263
} else if (userContext.apiType === "Tables") {

src/Explorer/ContextMenuButtonFactory.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export const createCollectionContextMenuButton = (
146146
});
147147
}
148148

149-
if (configContext.platform !== Platform.Fabric) {
149+
if (!isFabric() || (isFabric() && !userContext.fabricContext?.isReadOnly)) {
150150
items.push({
151151
iconSrc: DeleteCollectionIcon,
152152
onClick: (lastFocusedElement?: React.RefObject<HTMLElement>) => {

src/Explorer/Tree/__snapshots__/treeNodeUtil.test.ts.snap

+167-4
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ exports[`createDatabaseTreeNodes generates the correct tree structure for the Mo
740740
]
741741
`;
742742

743-
exports[`createDatabaseTreeNodes generates the correct tree structure for the SQL API, on Fabric 1`] = `
743+
exports[`createDatabaseTreeNodes generates the correct tree structure for the SQL API, on Fabric non read-only 1`] = `
744744
[
745745
{
746746
"children": [
@@ -753,6 +753,12 @@ exports[`createDatabaseTreeNodes generates the correct tree structure for the SQ
753753
"label": "New SQL Query",
754754
"onClick": [Function],
755755
},
756+
{
757+
"iconSrc": {},
758+
"label": "Delete Container",
759+
"onClick": [Function],
760+
"styleClass": "deleteCollectionMenuItem",
761+
},
756762
],
757763
"iconSrc": <DocumentMultipleRegular
758764
fontSize={16}
@@ -774,6 +780,12 @@ exports[`createDatabaseTreeNodes generates the correct tree structure for the SQ
774780
"label": "New SQL Query",
775781
"onClick": [Function],
776782
},
783+
{
784+
"iconSrc": {},
785+
"label": "Delete Container",
786+
"onClick": [Function],
787+
"styleClass": "deleteCollectionMenuItem",
788+
},
777789
],
778790
"iconSrc": <DocumentMultipleRegular
779791
fontSize={16}
@@ -822,6 +834,12 @@ exports[`createDatabaseTreeNodes generates the correct tree structure for the SQ
822834
"label": "New SQL Query",
823835
"onClick": [Function],
824836
},
837+
{
838+
"iconSrc": {},
839+
"label": "Delete Container",
840+
"onClick": [Function],
841+
"styleClass": "deleteCollectionMenuItem",
842+
},
825843
],
826844
"iconSrc": <DocumentMultipleRegular
827845
fontSize={16}
@@ -870,6 +888,12 @@ exports[`createDatabaseTreeNodes generates the correct tree structure for the SQ
870888
"label": "New SQL Query",
871889
"onClick": [Function],
872890
},
891+
{
892+
"iconSrc": {},
893+
"label": "Delete Container",
894+
"onClick": [Function],
895+
"styleClass": "deleteCollectionMenuItem",
896+
},
873897
],
874898
"iconSrc": <DocumentMultipleRegular
875899
fontSize={16}
@@ -915,6 +939,145 @@ exports[`createDatabaseTreeNodes generates the correct tree structure for the SQ
915939
]
916940
`;
917941

942+
exports[`createDatabaseTreeNodes generates the correct tree structure for the SQL API, on Fabric read-only 1`] = `
943+
[
944+
{
945+
"children": [
946+
{
947+
"children": undefined,
948+
"className": "collectionNode",
949+
"contextMenu": [
950+
{
951+
"iconSrc": {},
952+
"label": "New SQL Query",
953+
"onClick": [Function],
954+
},
955+
],
956+
"iconSrc": <DocumentMultipleRegular
957+
fontSize={16}
958+
/>,
959+
"isExpanded": true,
960+
"isSelected": [Function],
961+
"label": "standardCollection",
962+
"onClick": [Function],
963+
"onCollapsed": [Function],
964+
"onContextMenuOpen": [Function],
965+
"onExpanded": [Function],
966+
},
967+
{
968+
"children": undefined,
969+
"className": "collectionNode",
970+
"contextMenu": [
971+
{
972+
"iconSrc": {},
973+
"label": "New SQL Query",
974+
"onClick": [Function],
975+
},
976+
],
977+
"iconSrc": <DocumentMultipleRegular
978+
fontSize={16}
979+
/>,
980+
"isExpanded": true,
981+
"isSelected": [Function],
982+
"label": "conflictsCollection",
983+
"onClick": [Function],
984+
"onCollapsed": [Function],
985+
"onContextMenuOpen": [Function],
986+
"onExpanded": [Function],
987+
},
988+
],
989+
"className": "databaseNode",
990+
"contextMenu": undefined,
991+
"iconSrc": <DatabaseRegular
992+
fontSize={16}
993+
/>,
994+
"isExpanded": true,
995+
"isSelected": [Function],
996+
"label": "standardDb",
997+
"onCollapsed": [Function],
998+
"onContextMenuOpen": [Function],
999+
"onExpanded": [Function],
1000+
},
1001+
{
1002+
"children": [
1003+
{
1004+
"children": undefined,
1005+
"className": "collectionNode",
1006+
"contextMenu": [
1007+
{
1008+
"iconSrc": {},
1009+
"label": "New SQL Query",
1010+
"onClick": [Function],
1011+
},
1012+
],
1013+
"iconSrc": <DocumentMultipleRegular
1014+
fontSize={16}
1015+
/>,
1016+
"isExpanded": true,
1017+
"isSelected": [Function],
1018+
"label": "sampleItemsCollection",
1019+
"onClick": [Function],
1020+
"onCollapsed": [Function],
1021+
"onContextMenuOpen": [Function],
1022+
"onExpanded": [Function],
1023+
},
1024+
],
1025+
"className": "databaseNode",
1026+
"contextMenu": undefined,
1027+
"iconSrc": <DatabaseRegular
1028+
fontSize={16}
1029+
/>,
1030+
"isExpanded": true,
1031+
"isSelected": [Function],
1032+
"label": "sharedDatabase",
1033+
"onCollapsed": [Function],
1034+
"onContextMenuOpen": [Function],
1035+
"onExpanded": [Function],
1036+
},
1037+
{
1038+
"children": [
1039+
{
1040+
"children": undefined,
1041+
"className": "collectionNode",
1042+
"contextMenu": [
1043+
{
1044+
"iconSrc": {},
1045+
"label": "New SQL Query",
1046+
"onClick": [Function],
1047+
},
1048+
],
1049+
"iconSrc": <DocumentMultipleRegular
1050+
fontSize={16}
1051+
/>,
1052+
"isExpanded": true,
1053+
"isSelected": [Function],
1054+
"label": "schemaCollection",
1055+
"onClick": [Function],
1056+
"onCollapsed": [Function],
1057+
"onContextMenuOpen": [Function],
1058+
"onExpanded": [Function],
1059+
},
1060+
{
1061+
"className": "loadMoreNode",
1062+
"label": "load more",
1063+
"onClick": [Function],
1064+
},
1065+
],
1066+
"className": "databaseNode",
1067+
"contextMenu": undefined,
1068+
"iconSrc": <DatabaseRegular
1069+
fontSize={16}
1070+
/>,
1071+
"isExpanded": true,
1072+
"isSelected": [Function],
1073+
"label": "giganticDatabase",
1074+
"onCollapsed": [Function],
1075+
"onContextMenuOpen": [Function],
1076+
"onExpanded": [Function],
1077+
},
1078+
]
1079+
`;
1080+
9181081
exports[`createDatabaseTreeNodes generates the correct tree structure for the SQL API, on Portal 1`] = `
9191082
[
9201083
{
@@ -972,7 +1135,7 @@ exports[`createDatabaseTreeNodes generates the correct tree structure for the SQ
9721135
},
9731136
],
9741137
"isSelected": [Function],
975-
"label": "mockSproc3",
1138+
"label": "mockSproc4",
9761139
"onClick": [Function],
9771140
},
9781141
],
@@ -990,7 +1153,7 @@ exports[`createDatabaseTreeNodes generates the correct tree structure for the SQ
9901153
},
9911154
],
9921155
"isSelected": [Function],
993-
"label": "mockUdf3",
1156+
"label": "mockUdf4",
9941157
"onClick": [Function],
9951158
},
9961159
],
@@ -1008,7 +1171,7 @@ exports[`createDatabaseTreeNodes generates the correct tree structure for the SQ
10081171
},
10091172
],
10101173
"isSelected": [Function],
1011-
"label": "mockTrigger3",
1174+
"label": "mockTrigger4",
10121175
"onClick": [Function],
10131176
},
10141177
],

0 commit comments

Comments
 (0)