Compare commits

...

4 Commits

Author SHA1 Message Date
sunilyadav840
49e09ab677 Merge branch 'master' 2021-07-26 17:58:00 +05:30
victor-meng
a8bc821dec Add initializeGitHubRepos function in useNotebooks store (#957) 2021-07-23 18:44:24 -07:00
victor-meng
1394aae944 Fix validateCollectionId for new tables account (#958) 2021-07-23 18:44:16 -07:00
sunilyadav840
18bb22eab8 Fixed typescript strict issue of ResourceTokenUtils, CostEnstimatedText Draggable files 2021-05-17 16:09:40 +05:30
9 changed files with 61 additions and 17 deletions

View File

@@ -28,8 +28,9 @@ export const CostEstimateText: FunctionComponent<CostEstimateTextProps> = ({
} }
const serverId: string = userContext.portalEnv; const serverId: string = userContext.portalEnv;
const { enableMultipleWriteLocations } = databaseAccount.properties;
const numberOfRegions: number = databaseAccount.properties.readLocations?.length || 1; const numberOfRegions: number = databaseAccount.properties.readLocations?.length || 1;
const multimasterEnabled: boolean = databaseAccount.properties.enableMultipleWriteLocations; const multimasterEnabled: boolean = enableMultipleWriteLocations ? enableMultipleWriteLocations : false;
const hourlyPrice: number = computeRUUsagePriceHourly({ const hourlyPrice: number = computeRUUsagePriceHourly({
serverId, serverId,
requestUnits, requestUnits,

View File

@@ -29,6 +29,7 @@ import { SnapshotRequest } from "./NotebookComponent/types";
import { NotebookContainerClient } from "./NotebookContainerClient"; import { NotebookContainerClient } from "./NotebookContainerClient";
import { NotebookContentClient } from "./NotebookContentClient"; import { NotebookContentClient } from "./NotebookContentClient";
import { SchemaAnalyzerNotebook } from "./SchemaAnalyzer/SchemaAnalyzerUtils"; import { SchemaAnalyzerNotebook } from "./SchemaAnalyzer/SchemaAnalyzerUtils";
import { useNotebook } from "./useNotebook";
type NotebookPaneContent = string | ImmutableNotebook; type NotebookPaneContent = string | ImmutableNotebook;
@@ -110,6 +111,7 @@ export default class NotebookManager {
this.junoClient.subscribeToPinnedRepos((pinnedRepos) => { this.junoClient.subscribeToPinnedRepos((pinnedRepos) => {
this.params.resourceTree.initializeGitHubRepos(pinnedRepos); this.params.resourceTree.initializeGitHubRepos(pinnedRepos);
this.params.resourceTree.triggerRender(); this.params.resourceTree.triggerRender();
useNotebook.getState().initializeGitHubRepos(pinnedRepos);
}); });
this.refreshPinnedRepos(); this.refreshPinnedRepos();
} }

View File

@@ -11,7 +11,6 @@ import {
DropTargetConnector, DropTargetConnector,
DropTargetMonitor, DropTargetMonitor,
} from "react-dnd"; } from "react-dnd";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { Dispatch } from "redux"; import { Dispatch } from "redux";
import styled, { StyledComponent } from "styled-components"; import styled, { StyledComponent } from "styled-components";
@@ -109,7 +108,7 @@ const DragHandleAnchor = styled.div`
position: relative; position: relative;
`; `;
export function isDragUpper(props: Props, monitor: DropTargetMonitor, el: HTMLElement): boolean { export function isDragUpper(_props: Props, monitor: DropTargetMonitor, el: HTMLElement): boolean {
const hoverBoundingRect = el.getBoundingClientRect(); const hoverBoundingRect = el.getBoundingClientRect();
const hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2; const hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;
@@ -223,7 +222,7 @@ export class DraggableCellView extends React.Component<Props & DnDSourceProps &
const source = DragSource<Props, DnDSourceProps>("CELL", cellSource, collectSource); const source = DragSource<Props, DnDSourceProps>("CELL", cellSource, collectSource);
const target = DropTarget<Props, DnDTargetProps>("CELL", cellTarget, collectTarget); const target = DropTarget<Props, DnDTargetProps>("CELL", cellTarget, collectTarget);
export const makeMapDispatchToProps = (initialDispatch: Dispatch) => { export const makeMapDispatchToProps = (_initialDispatch: Dispatch) => {
const mapDispatchToProps = (dispatch: Dispatch) => ({ const mapDispatchToProps = (dispatch: Dispatch) => ({
moveCell: (payload: actions.MoveCell["payload"]) => dispatch(actions.moveCell(payload)), moveCell: (payload: actions.MoveCell["payload"]) => dispatch(actions.moveCell(payload)),
focusCell: (payload: actions.FocusCell["payload"]) => dispatch(actions.focusCell(payload)), focusCell: (payload: actions.FocusCell["payload"]) => dispatch(actions.focusCell(payload)),

View File

@@ -6,10 +6,12 @@ import { getErrorMessage } from "../../Common/ErrorHandlingUtils";
import * as Logger from "../../Common/Logger"; import * as Logger from "../../Common/Logger";
import { configContext } from "../../ConfigContext"; import { configContext } from "../../ConfigContext";
import * as DataModels from "../../Contracts/DataModels"; import * as DataModels from "../../Contracts/DataModels";
import { IPinnedRepo } from "../../Juno/JunoClient";
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants"; import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import { userContext } from "../../UserContext"; import { userContext } from "../../UserContext";
import { getAuthorizationHeader } from "../../Utils/AuthorizationUtils"; import { getAuthorizationHeader } from "../../Utils/AuthorizationUtils";
import * as GitHubUtils from "../../Utils/GitHubUtils";
import { NotebookContentItem, NotebookContentItemType } from "./NotebookContentItem"; import { NotebookContentItem, NotebookContentItemType } from "./NotebookContentItem";
import NotebookManager from "./NotebookManager"; import NotebookManager from "./NotebookManager";
@@ -39,6 +41,7 @@ interface NotebookState {
updateNotebookItem: (item: NotebookContentItem) => void; updateNotebookItem: (item: NotebookContentItem) => void;
deleteNotebookItem: (item: NotebookContentItem) => void; deleteNotebookItem: (item: NotebookContentItem) => void;
initializeNotebooksTree: (notebookManager: NotebookManager) => Promise<void>; initializeNotebooksTree: (notebookManager: NotebookManager) => Promise<void>;
initializeGitHubRepos: (pinnedRepos: IPinnedRepo[]) => void;
} }
export const useNotebook: UseStore<NotebookState> = create((set, get) => ({ export const useNotebook: UseStore<NotebookState> = create((set, get) => ({
@@ -202,4 +205,31 @@ export const useNotebook: UseStore<NotebookState> = create((set, get) => ({
} }
} }
}, },
initializeGitHubRepos: (pinnedRepos: IPinnedRepo[]): void => {
const gitHubNotebooksContentRoot = cloneDeep(get().gitHubNotebooksContentRoot);
if (gitHubNotebooksContentRoot) {
gitHubNotebooksContentRoot.children = [];
pinnedRepos?.forEach((pinnedRepo) => {
const repoFullName = GitHubUtils.toRepoFullName(pinnedRepo.owner, pinnedRepo.name);
const repoTreeItem: NotebookContentItem = {
name: repoFullName,
path: "PsuedoDir",
type: NotebookContentItemType.Directory,
children: [],
};
pinnedRepo.branches.forEach((branch) => {
repoTreeItem.children.push({
name: branch.name,
path: GitHubUtils.toContentUri(pinnedRepo.owner, pinnedRepo.name, branch.name, ""),
type: NotebookContentItemType.Directory,
});
});
gitHubNotebooksContentRoot.children.push(repoTreeItem);
});
set({ gitHubNotebooksContentRoot });
}
},
})); }));

View File

@@ -2,6 +2,7 @@ import _ from "underscore";
import create, { UseStore } from "zustand"; import create, { UseStore } from "zustand";
import * as Constants from "../Common/Constants"; import * as Constants from "../Common/Constants";
import * as ViewModels from "../Contracts/ViewModels"; import * as ViewModels from "../Contracts/ViewModels";
import { userContext } from "../UserContext";
import { useSelectedNode } from "./useSelectedNode"; import { useSelectedNode } from "./useSelectedNode";
interface DatabasesState { interface DatabasesState {
@@ -136,6 +137,11 @@ export const useDatabases: UseStore<DatabasesState> = create((set, get) => ({
}, },
validateCollectionId: async (databaseId: string, collectionId: string): Promise<boolean> => { validateCollectionId: async (databaseId: string, collectionId: string): Promise<boolean> => {
const database = get().databases.find((db) => db.id() === databaseId); const database = get().databases.find((db) => db.id() === databaseId);
// For a new tables account, database is undefined when creating the first table
if (!database && userContext.apiType === "Tables") {
return true;
}
await database.loadCollections(); await database.loadCollections();
return !database.collections().some((collection) => collection.id() === collectionId); return !database.collections().some((collection) => collection.id() === collectionId);
}, },

View File

@@ -10,7 +10,7 @@ describe("parseResourceTokenConnectionString", () => {
accountEndpoint: "fakeEndpoint", accountEndpoint: "fakeEndpoint",
collectionId: "fakeCollectionId", collectionId: "fakeCollectionId",
databaseId: "fakeDatabaseId", databaseId: "fakeDatabaseId",
partitionKey: undefined, partitionKey: "",
resourceToken: "type=resource&ver=1&sig=2dIP+CdIfT1ScwHWdv5GGw==;fakeToken;", resourceToken: "type=resource&ver=1&sig=2dIP+CdIfT1ScwHWdv5GGw==;fakeToken;",
}); });
}); });

View File

@@ -7,11 +7,11 @@ export interface ParsedResourceTokenConnectionString {
} }
export function parseResourceTokenConnectionString(connectionString: string): ParsedResourceTokenConnectionString { export function parseResourceTokenConnectionString(connectionString: string): ParsedResourceTokenConnectionString {
let accountEndpoint: string; let accountEndpoint = "";
let collectionId: string; let collectionId = "";
let databaseId: string; let databaseId = "";
let partitionKey: string; let partitionKey = "";
let resourceToken: string; let resourceToken = "";
const connectionStringParts = connectionString.split(";"); const connectionStringParts = connectionString.split(";");
connectionStringParts.forEach((part: string) => { connectionStringParts.forEach((part: string) => {
if (part.startsWith("type=resource")) { if (part.startsWith("type=resource")) {
@@ -39,5 +39,5 @@ export function parseResourceTokenConnectionString(connectionString: string): Pa
} }
export function isResourceTokenConnectionString(connectionString: string): boolean { export function isResourceTokenConnectionString(connectionString: string): boolean {
return connectionString && connectionString.includes("type=resource"); return connectionString.includes("type=resource");
} }

View File

@@ -40,7 +40,7 @@ interface UserContext {
// This is coming in a future Cosmos ARM API version as a prperty on databaseAccount // This is coming in a future Cosmos ARM API version as a prperty on databaseAccount
apiType: ApiType; apiType: ApiType;
readonly isTryCosmosDBSubscription?: boolean; readonly isTryCosmosDBSubscription?: boolean;
readonly portalEnv?: PortalEnv; readonly portalEnv: PortalEnv;
readonly features: Features; readonly features: Features;
readonly addCollectionFlight: string; readonly addCollectionFlight: string;
readonly hasWriteAccess: boolean; readonly hasWriteAccess: boolean;

View File

@@ -40,6 +40,7 @@
"./src/Explorer/Controls/Dialog.tsx", "./src/Explorer/Controls/Dialog.tsx",
"./src/Explorer/Controls/GitHub/GitHubStyleConstants.ts", "./src/Explorer/Controls/GitHub/GitHubStyleConstants.ts",
"./src/Explorer/Controls/SmartUi/InputUtils.ts", "./src/Explorer/Controls/SmartUi/InputUtils.ts",
"./src/Explorer/Controls/ThroughputInput/CostEstimateText/CostEstimateText.tsx",
"./src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.test.ts", "./src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.test.ts",
"./src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.ts", "./src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.ts",
"./src/Explorer/Graph/GraphExplorerComponent/EdgeInfoCache.ts", "./src/Explorer/Graph/GraphExplorerComponent/EdgeInfoCache.ts",
@@ -84,9 +85,15 @@
"./src/GitHub/GitHubConnector.ts", "./src/GitHub/GitHubConnector.ts",
"./src/HostedExplorerChildFrame.ts", "./src/HostedExplorerChildFrame.ts",
"./src/Platform/Hosted/Authorization.ts", "./src/Platform/Hosted/Authorization.ts",
"./src/Platform/Hosted/Components/ConnectExplorer.test.tsx",
"./src/Platform/Hosted/Components/ConnectExplorer.tsx",
"./src/Platform/Hosted/Components/MeControl.test.tsx", "./src/Platform/Hosted/Components/MeControl.test.tsx",
"./src/Platform/Hosted/Components/MeControl.tsx", "./src/Platform/Hosted/Components/MeControl.tsx",
"./src/Platform/Hosted/Components/SignInButton.tsx", "./src/Platform/Hosted/Components/SignInButton.tsx",
"./src/Platform/Hosted/Components/SwitchAccount.tsx",
"./src/Platform/Hosted/Components/SwitchSubscription.tsx",
"./src/Platform/Hosted/Helpers/ResourceTokenUtils.test.ts",
"./src/Platform/Hosted/Helpers/ResourceTokenUtils.ts",
"./src/Platform/Hosted/HostedUtils.test.ts", "./src/Platform/Hosted/HostedUtils.test.ts",
"./src/Platform/Hosted/HostedUtils.ts", "./src/Platform/Hosted/HostedUtils.ts",
"./src/Platform/Hosted/extractFeatures.test.ts", "./src/Platform/Hosted/extractFeatures.test.ts",
@@ -130,17 +137,15 @@
"./src/hooks/useFullScreenURLs.tsx", "./src/hooks/useFullScreenURLs.tsx",
"./src/hooks/useGraphPhoto.tsx", "./src/hooks/useGraphPhoto.tsx",
"./src/hooks/useNotebookSnapshotStore.ts", "./src/hooks/useNotebookSnapshotStore.ts",
"./src/hooks/usePortalAccessToken.tsx",
"./src/hooks/useNotificationConsole.ts", "./src/hooks/useNotificationConsole.ts",
"./src/hooks/useObservable.ts", "./src/hooks/useObservable.ts",
"./src/hooks/usePortalAccessToken.tsx",
"./src/hooks/useSidePanel.ts", "./src/hooks/useSidePanel.ts",
"./src/i18n.ts", "./src/i18n.ts",
"./src/quickstart.ts", "./src/quickstart.ts",
"./src/setupTests.ts", "./src/setupTests.ts",
"./src/userContext.test.ts", "./src/userContext.test.ts",
"src/Common/EntityValue.tsx", "src/Common/EntityValue.tsx"
"./src/Platform/Hosted/Components/SwitchAccount.tsx",
"./src/Platform/Hosted/Components/SwitchSubscription.tsx"
], ],
"include": [ "include": [
"src/CellOutputViewer/transforms/**/*", "src/CellOutputViewer/transforms/**/*",
@@ -155,6 +160,7 @@
"src/Explorer/Graph/GraphExplorerComponent/__mocks__/**/*", "src/Explorer/Graph/GraphExplorerComponent/__mocks__/**/*",
"src/Explorer/Menus/NavBar/**/*", "src/Explorer/Menus/NavBar/**/*",
"src/Explorer/Notebook/NotebookComponent/__mocks__/**/*", "src/Explorer/Notebook/NotebookComponent/__mocks__/**/*",
"src/Explorer/Notebook/NotebookRenderer/decorators/draggable/**/*",
"src/Explorer/Notebook/NotebookRenderer/decorators/hijack-scroll/**/*", "src/Explorer/Notebook/NotebookRenderer/decorators/hijack-scroll/**/*",
"src/Explorer/Notebook/NotebookRenderer/decorators/kbd-shortcuts/**/*", "src/Explorer/Notebook/NotebookRenderer/decorators/kbd-shortcuts/**/*",
"src/Explorer/Panes/RightPaneForm/**/*", "src/Explorer/Panes/RightPaneForm/**/*",
@@ -166,4 +172,4 @@
"src/Terminal/**/*", "src/Terminal/**/*",
"src/Utils/arm/**/*" "src/Utils/arm/**/*"
] ]
} }