From 9d0bc86197aa0228b2b87078e4d5715d7703bdf9 Mon Sep 17 00:00:00 2001 From: Jordi Bunster Date: Thu, 29 Apr 2021 10:20:57 -0700 Subject: [PATCH 1/3] Remove 'explorer' from a few Panes (#650) While working on #549 I realized there were a few places where 'explorer' was only needed to expand the notifications console, so I stripped those out where it was easy. --- src/Explorer/Explorer.tsx | 9 +- .../CopyNotebookPane/CopyNotebookPane.tsx | 2 +- .../DeleteCollectionConfirmationPane.tsx | 2 +- ...teCollectionConfirmationPane.test.tsx.snap | 11 +- .../ExecuteSprocParamsPane.test.tsx | 4 +- .../ExecuteSprocParamsPane.tsx | 7 +- .../ExecuteSprocParamsPane.test.tsx.snap | 4 +- .../GenericRightPaneComponent.tsx | 11 +- .../Panes/LoadQueryPane/LoadQueryPane.tsx | 2 +- .../__snapshots__/LoadQueryPane.test.tsx.snap | 2 +- .../PublishNotebookPane.tsx | 2 +- .../Panes/SaveQueryPane/SaveQueryPane.tsx | 2 +- .../__snapshots__/SaveQueryPane.test.tsx.snap | 6 +- .../Panes/SettingsPane/SettingsPane.test.tsx | 3 +- .../Panes/SettingsPane/SettingsPane.tsx | 7 +- .../__snapshots__/SettingsPane.test.tsx.snap | 1041 +---------------- .../Panes/StringInputPane/StringInputPane.tsx | 2 +- .../StringInputPane.test.tsx.snap | 499 +------- .../__snapshots__/index.test.tsx.snap | 2 +- .../Tables/TableQuerySelectPanel/index.tsx | 2 +- .../Panes/UploadFilePane/UploadFilePane.tsx | 7 +- .../Panes/UploadItemsPane/UploadItemsPane.tsx | 2 +- .../UploadItemsPane.test.tsx.snap | 499 +------- 23 files changed, 79 insertions(+), 2049 deletions(-) diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index 3a090fd7e..3c9ce8659 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -2089,15 +2089,18 @@ export default class Explorer { } public openSettingPane(): void { - this.openSidePanel("Settings", ); + this.openSidePanel( + "Settings", + this.expandConsole()} closePanel={this.closeSidePanel} /> + ); } public openExecuteSprocParamsPanel(storedProcedure: StoredProcedure): void { this.openSidePanel( "Input parameters", this.expandConsole()} closePanel={() => this.closeSidePanel()} /> ); @@ -2132,7 +2135,7 @@ export default class Explorer { this.openSidePanel( "Upload File", this.expandConsole()} closePanel={this.closeSidePanel} uploadFile={(name: string, content: string) => this.uploadFile(name, content, parent)} /> diff --git a/src/Explorer/Panes/CopyNotebookPane/CopyNotebookPane.tsx b/src/Explorer/Panes/CopyNotebookPane/CopyNotebookPane.tsx index 3f4c281aa..30e6bdeb5 100644 --- a/src/Explorer/Panes/CopyNotebookPane/CopyNotebookPane.tsx +++ b/src/Explorer/Panes/CopyNotebookPane/CopyNotebookPane.tsx @@ -131,7 +131,6 @@ export const CopyNotebookPane: FunctionComponent = ({ }; const genericPaneProps: GenericRightPaneProps = { - container, formError, formErrorDetail, id: "copynotebookpane", @@ -140,6 +139,7 @@ export const CopyNotebookPane: FunctionComponent = ({ submitButtonText: "OK", onClose: closePanel, onSubmit: () => submit(), + expandConsole: () => container.expandConsole(), }; const copyNotebookPaneProps: CopyNotebookPaneProps = { diff --git a/src/Explorer/Panes/DeleteCollectionConfirmationPane/DeleteCollectionConfirmationPane.tsx b/src/Explorer/Panes/DeleteCollectionConfirmationPane/DeleteCollectionConfirmationPane.tsx index 171289999..b6864aadb 100644 --- a/src/Explorer/Panes/DeleteCollectionConfirmationPane/DeleteCollectionConfirmationPane.tsx +++ b/src/Explorer/Panes/DeleteCollectionConfirmationPane/DeleteCollectionConfirmationPane.tsx @@ -101,7 +101,6 @@ export const DeleteCollectionConfirmationPane: FunctionComponent explorer.expandConsole(), }; return ( diff --git a/src/Explorer/Panes/DeleteCollectionConfirmationPane/__snapshots__/DeleteCollectionConfirmationPane.test.tsx.snap b/src/Explorer/Panes/DeleteCollectionConfirmationPane/__snapshots__/DeleteCollectionConfirmationPane.test.tsx.snap index 8d5985440..a78871304 100644 --- a/src/Explorer/Panes/DeleteCollectionConfirmationPane/__snapshots__/DeleteCollectionConfirmationPane.test.tsx.snap +++ b/src/Explorer/Panes/DeleteCollectionConfirmationPane/__snapshots__/DeleteCollectionConfirmationPane.test.tsx.snap @@ -16,16 +16,7 @@ exports[`Delete Collection Confirmation Pane submit() should call delete collect } > { - const fakeExplorer = {} as Explorer; const fakeSproc = {} as StoredProcedure; const props = { - explorer: fakeExplorer, storedProcedure: fakeSproc, + expandConsole: (): void => undefined, closePanel: (): void => undefined, }; diff --git a/src/Explorer/Panes/ExecuteSprocParamsPane/ExecuteSprocParamsPane.tsx b/src/Explorer/Panes/ExecuteSprocParamsPane/ExecuteSprocParamsPane.tsx index ab63e4fcb..2677c6055 100644 --- a/src/Explorer/Panes/ExecuteSprocParamsPane/ExecuteSprocParamsPane.tsx +++ b/src/Explorer/Panes/ExecuteSprocParamsPane/ExecuteSprocParamsPane.tsx @@ -2,7 +2,6 @@ import { useBoolean } from "@uifabric/react-hooks"; import { IDropdownOption, IImageProps, Image, Stack, Text } from "office-ui-fabric-react"; import React, { FunctionComponent, useState } from "react"; import AddPropertyIcon from "../../../../images/Add-property.svg"; -import Explorer from "../../Explorer"; import StoredProcedure from "../../Tree/StoredProcedure"; import { GenericRightPaneComponent, @@ -11,7 +10,7 @@ import { import { InputParameter } from "./InputParameter"; interface ExecuteSprocParamsPaneProps { - explorer: Explorer; + expandConsole: () => void; storedProcedure: StoredProcedure; closePanel: () => void; } @@ -27,7 +26,7 @@ interface UnwrappedExecuteSprocParam { } export const ExecuteSprocParamsPane: FunctionComponent = ({ - explorer, + expandConsole, storedProcedure, closePanel, }: ExecuteSprocParamsPaneProps): JSX.Element => { @@ -43,7 +42,7 @@ export const ExecuteSprocParamsPane: FunctionComponent void; formError: string; formErrorDetail: string; id: string; @@ -24,7 +23,7 @@ export interface GenericRightPaneState { } export const GenericRightPaneComponent: FunctionComponent = ({ - container, + expandConsole, formError, formErrorDetail, id, @@ -72,7 +71,7 @@ export const GenericRightPaneComponent: FunctionComponent {formError} - @@ -114,10 +113,6 @@ export const GenericRightPaneComponent: FunctionComponent } }; - const showErrorDetail = (): void => { - container.expandConsole(); - }; - return (
diff --git a/src/Explorer/Panes/LoadQueryPane/LoadQueryPane.tsx b/src/Explorer/Panes/LoadQueryPane/LoadQueryPane.tsx index 6a8fed727..d2079c010 100644 --- a/src/Explorer/Panes/LoadQueryPane/LoadQueryPane.tsx +++ b/src/Explorer/Panes/LoadQueryPane/LoadQueryPane.tsx @@ -37,7 +37,7 @@ export const LoadQueryPane: FunctionComponent = ({ const title = "Load Query"; const genericPaneProps: GenericRightPaneProps = { - container: explorer, + expandConsole: () => explorer.expandConsole(), formError: formError, formErrorDetail: formErrorsDetails, id: "loadQueryPane", diff --git a/src/Explorer/Panes/LoadQueryPane/__snapshots__/LoadQueryPane.test.tsx.snap b/src/Explorer/Panes/LoadQueryPane/__snapshots__/LoadQueryPane.test.tsx.snap index ee672aa5c..badff47b7 100644 --- a/src/Explorer/Panes/LoadQueryPane/__snapshots__/LoadQueryPane.test.tsx.snap +++ b/src/Explorer/Panes/LoadQueryPane/__snapshots__/LoadQueryPane.test.tsx.snap @@ -2,7 +2,7 @@ exports[`Load Query Pane should render Default properly 1`] = ` = }; const props: GenericRightPaneProps = { - container: container, formError: formError, formErrorDetail: formErrorDetail, id: "publishnotebookpane", @@ -167,6 +166,7 @@ export const PublishNotebookPane: FunctionComponent = submitButtonText: "Publish", onSubmit: () => submit(), onClose: closePanel, + expandConsole: () => container.expandConsole(), isSubmitButtonHidden: !isCodeOfConductAccepted, }; diff --git a/src/Explorer/Panes/SaveQueryPane/SaveQueryPane.tsx b/src/Explorer/Panes/SaveQueryPane/SaveQueryPane.tsx index 949e9203f..652c58949 100644 --- a/src/Explorer/Panes/SaveQueryPane/SaveQueryPane.tsx +++ b/src/Explorer/Panes/SaveQueryPane/SaveQueryPane.tsx @@ -32,7 +32,7 @@ export const SaveQueryPane: FunctionComponent = ({ const title = "Save Query"; const { canSaveQueries } = explorer; const genericPaneProps: GenericRightPaneProps = { - container: explorer, + expandConsole: () => explorer.expandConsole(), formError: formError, formErrorDetail: formErrorsDetails, id: "saveQueryPane", diff --git a/src/Explorer/Panes/SaveQueryPane/__snapshots__/SaveQueryPane.test.tsx.snap b/src/Explorer/Panes/SaveQueryPane/__snapshots__/SaveQueryPane.test.tsx.snap index b5ed7ed77..aba5e17b8 100644 --- a/src/Explorer/Panes/SaveQueryPane/__snapshots__/SaveQueryPane.test.tsx.snap +++ b/src/Explorer/Panes/SaveQueryPane/__snapshots__/SaveQueryPane.test.tsx.snap @@ -2,11 +2,7 @@ exports[`Save Query Pane should render Default properly 1`] = ` undefined, closePanel: (): void => undefined, }; describe("Settings Pane", () => { diff --git a/src/Explorer/Panes/SettingsPane/SettingsPane.tsx b/src/Explorer/Panes/SettingsPane/SettingsPane.tsx index 02dfdd614..480f358c5 100644 --- a/src/Explorer/Panes/SettingsPane/SettingsPane.tsx +++ b/src/Explorer/Panes/SettingsPane/SettingsPane.tsx @@ -7,19 +7,18 @@ import { LocalStorageUtility, StorageKey } from "../../../Shared/StorageUtility" import * as StringUtility from "../../../Shared/StringUtility"; import { userContext } from "../../../UserContext"; import { logConsoleInfo } from "../../../Utils/NotificationConsoleUtils"; -import Explorer from "../../Explorer"; import { GenericRightPaneComponent, GenericRightPaneProps, } from "../GenericRightPaneComponent/GenericRightPaneComponent"; export interface SettingsPaneProps { - explorer: Explorer; + expandConsole: () => void; closePanel: () => void; } export const SettingsPane: FunctionComponent = ({ - explorer: container, + expandConsole, closePanel, }: SettingsPaneProps) => { const [formErrors, setFormErrors] = useState(""); @@ -107,7 +106,7 @@ export const SettingsPane: FunctionComponent = ({ }; const genericPaneProps: GenericRightPaneProps = { - container, + expandConsole, formError: formErrors, formErrorDetail: "", id: "settingspane", diff --git a/src/Explorer/Panes/SettingsPane/__snapshots__/SettingsPane.test.tsx.snap b/src/Explorer/Panes/SettingsPane/__snapshots__/SettingsPane.test.tsx.snap index 69f4ef1b7..c20b14595 100644 --- a/src/Explorer/Panes/SettingsPane/__snapshots__/SettingsPane.test.tsx.snap +++ b/src/Explorer/Panes/SettingsPane/__snapshots__/SettingsPane.test.tsx.snap @@ -2,504 +2,7 @@ exports[`Settings Pane should render Default properly 1`] = `
+ > +
+
+ Query results per page + + Enter the number of query results that should be shown per page. + +
+ +
+
= ({ } }; const genericPaneProps: GenericRightPaneProps = { - container: container, formError: formErrors, formErrorDetail: formErrorsDetails, id: "stringInputPane", @@ -101,6 +100,7 @@ export const StringInputPane: FunctionComponent = ({ submitButtonText: submitButtonLabel, onClose: closePanel, onSubmit: submit, + expandConsole: () => container.expandConsole(), }; return ( diff --git a/src/Explorer/Panes/StringInputPane/__snapshots__/StringInputPane.test.tsx.snap b/src/Explorer/Panes/StringInputPane/__snapshots__/StringInputPane.test.tsx.snap index fbdc9fc80..7fd573d15 100644 --- a/src/Explorer/Panes/StringInputPane/__snapshots__/StringInputPane.test.tsx.snap +++ b/src/Explorer/Panes/StringInputPane/__snapshots__/StringInputPane.test.tsx.snap @@ -519,504 +519,7 @@ exports[`StringInput Pane should render Create new directory properly 1`] = ` successMessage="Created directory " > (true); const genericPaneProps: GenericRightPaneProps = { - container: explorer, formError: "", formErrorDetail: "", id: "querySelectPane", @@ -41,6 +40,7 @@ export const TableQuerySelectPanel: FunctionComponent closePanel(), onSubmit: () => submit(), + expandConsole: () => explorer.expandConsole(), }; const submit = (): void => { diff --git a/src/Explorer/Panes/UploadFilePane/UploadFilePane.tsx b/src/Explorer/Panes/UploadFilePane/UploadFilePane.tsx index 70b66baea..d65301610 100644 --- a/src/Explorer/Panes/UploadFilePane/UploadFilePane.tsx +++ b/src/Explorer/Panes/UploadFilePane/UploadFilePane.tsx @@ -1,7 +1,6 @@ import React, { ChangeEvent, FunctionComponent, useState } from "react"; import { Upload } from "../../../Common/Upload/Upload"; import { logConsoleError, logConsoleInfo, logConsoleProgress } from "../../../Utils/NotificationConsoleUtils"; -import Explorer from "../../Explorer"; import { NotebookContentItem } from "../../Notebook/NotebookContentItem"; import { GenericRightPaneComponent, @@ -9,13 +8,13 @@ import { } from "../GenericRightPaneComponent/GenericRightPaneComponent"; export interface UploadFilePanelProps { - explorer: Explorer; + expandConsole: () => void; closePanel: () => void; uploadFile: (name: string, content: string) => Promise; } export const UploadFilePane: FunctionComponent = ({ - explorer: container, + expandConsole, closePanel, uploadFile, }: UploadFilePanelProps) => { @@ -93,7 +92,7 @@ export const UploadFilePane: FunctionComponent = ({ }; const genericPaneProps: GenericRightPaneProps = { - container: container, + expandConsole, formError: formErrors, formErrorDetail: formErrorsDetails, id: "uploadFilePane", diff --git a/src/Explorer/Panes/UploadItemsPane/UploadItemsPane.tsx b/src/Explorer/Panes/UploadItemsPane/UploadItemsPane.tsx index c2836ba3c..31448612f 100644 --- a/src/Explorer/Panes/UploadItemsPane/UploadItemsPane.tsx +++ b/src/Explorer/Panes/UploadItemsPane/UploadItemsPane.tsx @@ -71,7 +71,7 @@ export const UploadItemsPane: FunctionComponent = ({ }; const genericPaneProps: GenericRightPaneProps = { - container: explorer, + expandConsole: () => explorer.expandConsole(), formError, formErrorDetail, id: "uploaditemspane", diff --git a/src/Explorer/Panes/UploadItemsPane/__snapshots__/UploadItemsPane.test.tsx.snap b/src/Explorer/Panes/UploadItemsPane/__snapshots__/UploadItemsPane.test.tsx.snap index fc59040bf..c13f7f4ae 100644 --- a/src/Explorer/Panes/UploadItemsPane/__snapshots__/UploadItemsPane.test.tsx.snap +++ b/src/Explorer/Panes/UploadItemsPane/__snapshots__/UploadItemsPane.test.tsx.snap @@ -2,504 +2,7 @@ exports[`Upload Items Pane should render Default properly 1`] = ` Date: Thu, 29 Apr 2021 14:46:31 -0700 Subject: [PATCH 2/3] Remove GraphExplorerAdapter (#736) --- .../GraphExplorerAdapter.tsx | 63 ------------------- src/Explorer/Tabs/GraphTab.tsx | 29 ++++++--- 2 files changed, 20 insertions(+), 72 deletions(-) delete mode 100644 src/Explorer/Graph/GraphExplorerComponent/GraphExplorerAdapter.tsx diff --git a/src/Explorer/Graph/GraphExplorerComponent/GraphExplorerAdapter.tsx b/src/Explorer/Graph/GraphExplorerComponent/GraphExplorerAdapter.tsx deleted file mode 100644 index 77ab623fc..000000000 --- a/src/Explorer/Graph/GraphExplorerComponent/GraphExplorerAdapter.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import * as React from "react"; -import { ReactAdapter } from "../../../Bindings/ReactBindingHandler"; -import { GraphConfig } from "../../Tabs/GraphTab"; -import * as ViewModels from "../../../Contracts/ViewModels"; -import { GraphExplorer, GraphAccessor } from "./GraphExplorer"; - -interface Parameter { - onIsNewVertexDisabledChange: (isEnabled: boolean) => void; - onGraphAccessorCreated: (instance: GraphAccessor) => void; - onIsFilterQueryLoading: (isFilterQueryLoading: boolean) => void; - onIsValidQuery: (isValidQuery: boolean) => void; - onIsPropertyEditing: (isEditing: boolean) => void; - onIsGraphDisplayed: (isDisplayed: boolean) => void; - onResetDefaultGraphConfigValues: () => void; - - graphConfigUiData: ViewModels.GraphConfigUiData; - graphConfig?: GraphConfig; - - collectionPartitionKeyProperty: string; - graphBackendEndpoint: string; - databaseId: string; - collectionId: string; - masterKey: string; - - onLoadStartKey: number; - onLoadStartKeyChange: (newKey: number) => void; - resourceId: string; -} - -export class GraphExplorerAdapter implements ReactAdapter { - public params: Parameter; - public parameters = {}; - public isNewVertexDisabled: boolean; - - public constructor(params: Parameter) { - this.params = params; - } - - public renderComponent(): JSX.Element { - return ( - - ); - } -} diff --git a/src/Explorer/Tabs/GraphTab.tsx b/src/Explorer/Tabs/GraphTab.tsx index 8a6712b67..3402b7275 100644 --- a/src/Explorer/Tabs/GraphTab.tsx +++ b/src/Explorer/Tabs/GraphTab.tsx @@ -5,8 +5,12 @@ import StyleIcon from "../../../images/Style.svg"; import { DatabaseAccount } from "../../Contracts/DataModels"; import * as ViewModels from "../../Contracts/ViewModels"; import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent"; -import { GraphAccessor, GraphExplorerError } from "../Graph/GraphExplorerComponent/GraphExplorer"; -import { GraphExplorerAdapter } from "../Graph/GraphExplorerComponent/GraphExplorerAdapter"; +import { + GraphAccessor, + GraphExplorer, + GraphExplorerError, + GraphExplorerProps, +} from "../Graph/GraphExplorerComponent/GraphExplorer"; import { ContextualPaneBase } from "../Panes/ContextualPaneBase"; import GraphStylingPane from "../Panes/GraphStylingPane"; import { NewVertexPanel } from "../Panes/NewVertexPanel/NewVertexPanel"; @@ -36,15 +40,13 @@ interface GraphTabOptions extends ViewModels.TabOptions { } export default class GraphTab extends TabsBase { - public readonly html = - '
'; // Graph default configuration public static readonly DEFAULT_NODE_CAPTION = "id"; private static readonly LINK_COLOR = "#aaa"; private static readonly NODE_SIZE = 10; private static readonly NODE_COLOR = "orange"; private static readonly LINK_WIDTH = 1; - private graphExplorerAdapter: GraphExplorerAdapter; + private graphExplorerProps: GraphExplorerProps; private isNewVertexDisabled: ko.Observable; private isPropertyEditing: ko.Observable; private isGraphDisplayed: ko.Observable; @@ -70,7 +72,7 @@ export default class GraphTab extends TabsBase { this.graphConfig = GraphTab.createGraphConfig(); // TODO Merge this with this.graphConfig this.graphConfigUiData = GraphTab.createGraphConfigUiData(this.graphConfig); - this.graphExplorerAdapter = new GraphExplorerAdapter({ + this.graphExplorerProps = { onGraphAccessorCreated: (instance: GraphAccessor): void => { this.graphAccessor = instance; }, @@ -89,8 +91,9 @@ export default class GraphTab extends TabsBase { onResetDefaultGraphConfigValues: () => this.setDefaultGraphConfigValues(), graphConfig: this.graphConfig, graphConfigUiData: this.graphConfigUiData, - onIsFilterQueryLoading: (isFilterQueryLoading: boolean): void => this.isFilterQueryLoading(isFilterQueryLoading), - onIsValidQuery: (isValidQuery: boolean): void => this.isValidQuery(isValidQuery), + onIsFilterQueryLoadingChange: (isFilterQueryLoading: boolean): void => + this.isFilterQueryLoading(isFilterQueryLoading), + onIsValidQueryChange: (isValidQuery: boolean): void => this.isValidQuery(isValidQuery), collectionPartitionKeyProperty: options.collectionPartitionKeyProperty, graphBackendEndpoint: GraphTab.getGremlinEndpoint(options.account), databaseId: options.databaseId, @@ -103,7 +106,7 @@ export default class GraphTab extends TabsBase { } }, resourceId: options.account.id, - }); + }; this.isFilterQueryLoading = ko.observable(false); this.isValidQuery = ko.observable(true); @@ -115,6 +118,14 @@ export default class GraphTab extends TabsBase { : `${account.name}.graphs.azure.com:443/`; } + public render(): JSX.Element { + return ( +
+ +
+ ); + } + public onTabClick(): void { super.onTabClick(); this.collection.selectedSubnodeKind(ViewModels.CollectionTabKind.Graph); From 9878bf0d5e6adcedf1aa6039427508040af196d6 Mon Sep 17 00:00:00 2001 From: victor-meng <56978073+victor-meng@users.noreply.github.com> Date: Thu, 29 Apr 2021 17:23:21 -0700 Subject: [PATCH 3/3] Fix table entity boolean and number type property values (#737) --- .../Panes/Tables/EditTableEntityPanel.tsx | 2 +- src/Explorer/Tables/TableEntityProcessor.ts | 36 ++++++++++++------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/Explorer/Panes/Tables/EditTableEntityPanel.tsx b/src/Explorer/Panes/Tables/EditTableEntityPanel.tsx index f34ef865e..9aa50fac3 100644 --- a/src/Explorer/Panes/Tables/EditTableEntityPanel.tsx +++ b/src/Explorer/Panes/Tables/EditTableEntityPanel.tsx @@ -328,7 +328,7 @@ export const EditTableEntityPanel: FunctionComponent selectedKey={entity.type} entityPropertyPlaceHolder={detailedHelp} entityValuePlaceholder={entity.entityValuePlaceholder} - entityValue={entity.value} + entityValue={entity.value?.toString()} isEntityTypeDate={entity.isEntityTypeDate} entityTimeValue={entity.entityTimeValue} isEntityValueDisable={entity.isEntityValueDisable} diff --git a/src/Explorer/Tables/TableEntityProcessor.ts b/src/Explorer/Tables/TableEntityProcessor.ts index 4f6fd4f99..f26d2c38d 100644 --- a/src/Explorer/Tables/TableEntityProcessor.ts +++ b/src/Explorer/Tables/TableEntityProcessor.ts @@ -165,7 +165,7 @@ export function convertEntityToNewDocument(entity: Entities.ITableEntityForTable $id: entity.RowKey._, id: entity.RowKey._, }; - for (var property in entity) { + for (const property in entity) { if ( property !== Constants.EntityKeyNames.PartitionKey && property !== Constants.EntityKeyNames.RowKey && @@ -176,18 +176,30 @@ export function convertEntityToNewDocument(entity: Entities.ITableEntityForTable property !== keyProperties.attachments && property !== keyProperties.Id2 ) { - if (entity[property].$ === Constants.TableType.DateTime) { - // Convert javascript date back to ticks with 20 zeros padding - document[property] = { - $t: (DataTypes)[entity[property].$], - $v: DateTimeUtilities.convertJSDateToTicksWithPadding(entity[property]._), - }; - } else { - document[property] = { - $t: (DataTypes)[entity[property].$], - $v: entity[property]._, - }; + const propertyValue = entity[property]._; + let parsedValue; + switch (entity[property].$) { + case Constants.TableType.DateTime: + parsedValue = DateTimeUtilities.convertJSDateToTicksWithPadding(propertyValue); + break; + case Constants.TableType.Boolean: + parsedValue = propertyValue.toLowerCase() === "true"; + break; + case Constants.TableType.Int32: + case Constants.TableType.Int64: + parsedValue = parseInt(propertyValue, 10); + break; + case Constants.TableType.Double: + parsedValue = parseFloat(propertyValue); + break; + default: + parsedValue = propertyValue; } + + document[property] = { + $t: (DataTypes)[entity[property].$], + $v: parsedValue, + }; } } return document;