Compare commits

...

7 Commits

Author SHA1 Message Date
Jordi Bunster
9ba434a1ac So. MUCH. override 2021-05-06 00:49:03 -07:00
Steve Faulkner
db227084be Remove IE11 from Coding Guidelines 2021-05-07 10:04:47 -05:00
victor-meng
d62baf327b Change create wildcard index default value to false for mongo 3.2 (#759)
* Change create wildcard index default value to false for mongo 3.2

* Update snapshots
2021-05-06 21:27:47 -05:00
Jordi Bunster
78eafe1aec Remove NotebookViewerTab (#749)
[Preview this branch](https://cosmos-explorer-preview.azurewebsites.net/pull/749)
2021-05-07 00:20:25 +00:00
Sunil Kumar Yadav
a91ea6c1e4 Remove old Add/Edit Table Entity code (#755) 2021-05-06 18:51:45 -05:00
victor-meng
5606ef3266 Fix table edit entity bug and add collection panel bug for connection string users (#757)
* Fix table edit entity bug and add collection panel bug for connection string users

* Remove parseInt for int64
2021-05-06 18:51:22 -05:00
Steve Faulkner
503f044a70 Update strict mode files (#753) 2021-05-06 12:35:24 -05:00
126 changed files with 3168 additions and 2489 deletions

View File

@@ -119,14 +119,10 @@ src/Explorer/Panes/ContextualPaneBase.ts
src/Explorer/Panes/DeleteDatabaseConfirmationPane.test.ts
src/Explorer/Panes/DeleteDatabaseConfirmationPane.ts
src/Explorer/Panes/GraphStylingPane.ts
# src/Explorer/Panes/NewVertexPane.ts
src/Explorer/Panes/PaneComponents.ts
src/Explorer/Panes/RenewAdHocAccessPane.ts
src/Explorer/Panes/SetupNotebooksPane.ts
src/Explorer/Panes/SwitchDirectoryPane.ts
src/Explorer/Panes/Tables/EditTableEntityPane.ts
src/Explorer/Panes/Tables/EntityPropertyViewModel.ts
src/Explorer/Panes/Tables/TableEntityPane.ts
src/Explorer/Panes/Tables/Validators/EntityPropertyNameValidator.ts
src/Explorer/Panes/Tables/Validators/EntityPropertyValidationCommon.ts
src/Explorer/Panes/Tables/Validators/EntityPropertyValueValidator.ts

View File

@@ -188,7 +188,3 @@ Cosmos Explorer has been under constant development for over 5 years. As a resul
✅ DO
- Support all [browsers supported by the Azure Portal](https://docs.microsoft.com/en-us/azure/azure-portal/azure-portal-supported-browsers-devices)
- Support IE11
- In practice, this should not need to be considered as part of a normal development workflow
- Polyfills and transpilation are already provided by our engineering systems.
- This requirement will be removed on March 30th, 2021 when Azure drops IE11 support.

3938
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -101,10 +101,10 @@
"utility-types": "3.10.0"
},
"devDependencies": {
"@babel/core": "7.9.0",
"@babel/preset-env": "7.9.0",
"@babel/preset-react": "7.9.4",
"@babel/preset-typescript": "7.9.0",
"@babel/core": "7.14.0",
"@babel/preset-env": "7.14.1",
"@babel/preset-react": "7.13.13",
"@babel/preset-typescript": "7.13.0",
"@testing-library/react": "11.2.3",
"@types/applicationinsights-js": "1.0.7",
"@types/codemirror": "0.0.56",
@@ -127,10 +127,10 @@
"@types/sinon": "2.3.3",
"@types/styled-components": "5.1.1",
"@types/underscore": "1.7.36",
"@typescript-eslint/eslint-plugin": "4.22.0",
"@typescript-eslint/parser": "4.22.0",
"babel-jest": "24.9.0",
"babel-loader": "8.1.0",
"@typescript-eslint/eslint-plugin": "4.22.1",
"@typescript-eslint/parser": "4.22.1",
"babel-jest": "26.6.3",
"babel-loader": "8.2.2",
"buffer": "5.1.0",
"case-sensitive-paths-webpack-plugin": "2.3.0",
"create-file-webpack": "1.0.2",
@@ -138,7 +138,7 @@
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.5",
"enzyme-to-json": "3.6.1",
"eslint": "7.8.1",
"eslint": "7.25.0",
"eslint-cli": "1.1.1",
"eslint-plugin-no-null": "1.0.2",
"eslint-plugin-prefer-arrow": "1.2.2",
@@ -152,7 +152,7 @@
"html-loader": "0.5.5",
"html-loader-jest": "0.2.1",
"html-webpack-plugin": "4.5.2",
"jest": "25.5.4",
"jest": "26.6.3",
"jest-canvas-mock": "2.1.0",
"jest-playwright-preset": "1.5.1",
"jest-trx-results-processor": "0.0.7",
@@ -169,10 +169,10 @@
"rimraf": "3.0.0",
"sinon": "3.2.1",
"style-loader": "0.23.0",
"ts-loader": "6.2.2",
"tslint": "5.11.0",
"tslint-microsoft-contrib": "6.0.0",
"typescript": "4.2.4",
"ts-loader": "9.1.2",
"tslint": "6.1.3",
"tslint-microsoft-contrib": "6.2.0",
"typescript": "4.3.0-beta",
"url-loader": "1.1.1",
"wait-on": "4.0.2",
"webpack": "4.46.0",

View File

@@ -3,11 +3,11 @@ export class ObjectCache<T> extends Map<string, T> {
super();
}
public get(key: string): T | undefined {
public override get(key: string): T | undefined {
return this.touch(key);
}
public set(key: string, value: T): this {
public override set(key: string, value: T): this {
if (this.size === this.limit) {
this.delete(this.keys().next().value);
}

View File

@@ -22,6 +22,4 @@ ko.components.register("throughput-input-autopilot-v3", ThroughputInputComponent
ko.components.register("add-database-pane", new PaneComponents.AddDatabasePaneComponent());
ko.components.register("add-collection-pane", new PaneComponents.AddCollectionPaneComponent());
ko.components.register("graph-styling-pane", new PaneComponents.GraphStylingPaneComponent());
ko.components.register("table-add-entity-pane", new PaneComponents.TableAddEntityPaneComponent());
ko.components.register("table-edit-entity-pane", new PaneComponents.TableEditEntityPaneComponent());
ko.components.register("cassandra-add-collection-pane", new PaneComponents.CassandraAddCollectionPaneComponent());

View File

@@ -20,7 +20,7 @@ export class AccessibleElement extends React.Component<AccessibleElementProps> {
}
};
public render(): JSX.Element {
public override render(): JSX.Element {
const elementProps = { ...this.props };
delete elementProps.as;
delete elementProps.onActivated;

View File

@@ -12,7 +12,7 @@ import TriangleRightIcon from "../../../../images/Triangle-right.svg";
export interface AccordionComponentProps {}
export class AccordionComponent extends React.Component<AccordionComponentProps> {
public render(): JSX.Element {
public override render(): JSX.Element {
return <div className="accordion">{this.props.children}</div>;
}
}
@@ -42,7 +42,7 @@ export class AccordionItemComponent extends React.Component<AccordionItemCompone
};
}
componentDidUpdate() {
public override componentDidUpdate() {
if (this.props.isExpanded !== this.isExpanded) {
this.isExpanded = this.props.isExpanded;
this.setState({
@@ -51,7 +51,7 @@ export class AccordionItemComponent extends React.Component<AccordionItemCompone
}
}
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<div className="accordionItemContainer">
<div className="accordionItemHeader" onClick={this.onHeaderClick} onKeyPress={this.onHeaderKeyPress}>

View File

@@ -62,7 +62,7 @@ export class ArcadiaMenuPicker extends React.Component<ArcadiaMenuPickerProps, A
this.props.onCreateNewSparkPoolClicked(item.key);
};
public render() {
public override render() {
const { workspaces } = this.props;
let workspaceMenuItems: IContextualMenuItem[] = workspaces.map((workspace) => {
let sparkPoolsMenuProps: IContextualMenuProps = {

View File

@@ -19,7 +19,7 @@ export interface CollapsiblePanelProps {
}
export class CollapsiblePanel extends React.Component<CollapsiblePanelProps> {
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<div className={`collapsiblePanel ${this.props.isCollapsed ? "paneCollapsed" : ""}`}>
{!this.props.isCollapsed ? this.getExpandedFragment() : this.getCollapsedFragment()}

View File

@@ -24,13 +24,13 @@ export class CollapsibleSectionComponent extends React.Component<CollapsibleSect
this.setState({ isExpanded: !this.state.isExpanded });
};
public componentDidUpdate(): void {
public override componentDidUpdate(): void {
if (this.state.isExpanded && this.props.onExpand) {
this.props.onExpand();
}
}
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<>
<Stack

View File

@@ -129,7 +129,7 @@ export class CommandButtonComponent extends React.Component<CommandButtonCompone
private dropdownElt: HTMLElement;
private expandButtonElt: HTMLElement;
public componentDidUpdate(): void {
public override componentDidUpdate(): void {
if (!this.dropdownElt || !this.expandButtonElt) {
return;
}
@@ -243,7 +243,7 @@ export class CommandButtonComponent extends React.Component<CommandButtonCompone
);
}
public render(): JSX.Element {
public override render(): JSX.Element {
let mainClassName = "commandButtonComponent";
if (this.props.disabled) {
mainClassName += " commandDisabled";

View File

@@ -16,7 +16,7 @@ export interface DefaultDirectoryDropdownProps {
export class DefaultDirectoryDropdownComponent extends React.Component<DefaultDirectoryDropdownProps> {
public static readonly lastVisitedKey: string = "lastVisited";
public render(): JSX.Element {
public override render(): JSX.Element {
const lastVisitedOption: IDropdownOption = {
key: DefaultDirectoryDropdownComponent.lastVisitedKey,
text: "Sign in to your last visited directory",

View File

@@ -36,7 +36,7 @@ export class DirectoryListComponent extends React.Component<DirectoryListProps,
};
}
public render(): JSX.Element {
public override render(): JSX.Element {
const { directories: originalItems, selectedDirectoryId } = this.props;
const { filterText } = this.state;
const filteredItems =

View File

@@ -56,7 +56,7 @@ export class DynamicListViewModel extends WaitsForTemplateViewModel {
public ariaLabel: string;
public buttonText: string;
public newItem: ko.Observable<string>;
public isTemplateReady: ko.Observable<boolean>;
public override isTemplateReady: ko.Observable<boolean>;
public listItems: ko.ObservableArray<DynamicListItem>;
public constructor(options: DynamicListParams) {

View File

@@ -26,7 +26,7 @@ export interface EditorParams extends JsonEditorParams {
*/
// TODO: Ideally, JsonEditorViewModel should extend EditorViewModel and not the other way around
class EditorViewModel extends JsonEditorViewModel {
public params: EditorParams;
public override params: EditorParams;
private static providerRegistered: string[] = [];
public constructor(params: EditorParams) {
@@ -44,11 +44,11 @@ class EditorViewModel extends JsonEditorViewModel {
});
}
protected getEditorLanguage(): string {
protected override getEditorLanguage(): string {
return this.params.contentType;
}
protected async registerCompletionItemProvider() {
protected override async registerCompletionItemProvider() {
if (EditorViewModel.providerRegistered.indexOf("sql") < 0) {
const { SqlCompletionItemProvider } = await import("@azure/cosmos-language-service");
const monaco = await loadMonaco();
@@ -57,7 +57,7 @@ class EditorViewModel extends JsonEditorViewModel {
}
}
protected async getErrorMarkers(input: string): Promise<monaco.editor.IMarkerData[]> {
protected override async getErrorMarkers(input: string): Promise<monaco.editor.IMarkerData[]> {
const { ErrorMarkProvider } = await import("@azure/cosmos-language-service");
return ErrorMarkProvider.getErrorMark(input);
}

View File

@@ -21,20 +21,20 @@ export class EditorReact extends React.Component<EditorReactProps> {
super(props);
}
public componentDidMount(): void {
public override componentDidMount(): void {
this.createEditor(this.configureEditor.bind(this));
}
public shouldComponentUpdate(): boolean {
public override shouldComponentUpdate(): boolean {
// Prevents component re-rendering
return false;
}
public componentWillUnmount(): void {
public override componentWillUnmount(): void {
this.selectionListener && this.selectionListener.dispose();
}
public render(): JSX.Element {
public override render(): JSX.Element {
return <div className="jsonEditor" ref={(elt: HTMLElement) => this.setRef(elt)} />;
}

View File

@@ -38,7 +38,7 @@ export class AddRepoComponent extends React.Component<AddRepoComponentProps, Add
};
}
public render(): JSX.Element {
public override render(): JSX.Element {
const textFieldProps: ITextFieldProps = {
placeholder: AddRepoComponent.TextFieldPlaceholder,
autoFocus: true,

View File

@@ -49,7 +49,7 @@ export class AuthorizeAccessComponent extends React.Component<
};
}
public render(): JSX.Element {
public override render(): JSX.Element {
const choiceGroupProps: IChoiceGroupProps = {
options: [
{

View File

@@ -29,7 +29,7 @@ export class GitHubReposComponent extends React.Component<GitHubReposComponentPr
private static readonly OKButtonText = "OK";
private static readonly CancelButtonText = "Cancel";
public render(): JSX.Element {
public override render(): JSX.Element {
const content: JSX.Element = this.props.showAuthorizeAccess ? (
<AuthorizeAccessComponent {...this.props.authorizeAccessProps} />
) : (

View File

@@ -67,7 +67,7 @@ export class ReposListComponent extends React.Component<ReposListComponentProps>
private static readonly DefaultBranchName = "master";
private static readonly FooterIndex = -1;
public render(): JSX.Element {
public override render(): JSX.Element {
const pinnedReposListProps: IDetailsListProps = {
styles: {
contentWrapper: {

View File

@@ -30,7 +30,7 @@ export class GalleryHeaderComponent extends React.Component {
);
};
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<Stack
tokens={{ childrenGap: 10 }}

View File

@@ -113,7 +113,7 @@ export class InputTypeaheadComponent extends React.Component<
* @param prevState
* @param snapshot
*/
public componentDidUpdate(
public override componentDidUpdate(
prevProps: InputTypeaheadComponentProps,
prevState: InputTypeaheadComponentState,
snapshot: any
@@ -127,11 +127,11 @@ export class InputTypeaheadComponent extends React.Component<
/**
* Executed once react is done building the DOM for this component
*/
public componentDidMount(): void {
public override componentDidMount(): void {
this.initializeTypeahead();
}
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<span className="input-typeahead-container">
<div

View File

@@ -19,7 +19,7 @@ export class NotebookTerminalComponent extends React.Component<NotebookTerminalC
super(props);
}
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<div className="notebookTerminalContainer">
<iframe

View File

@@ -42,7 +42,7 @@ export class GalleryAndNotebookViewerComponent extends React.Component<
};
}
public render(): JSX.Element {
public override render(): JSX.Element {
if (this.state.notebookUrl) {
const props: NotebookViewerComponentProps = {
container: this.props.container,

View File

@@ -149,7 +149,7 @@ export class GalleryViewerComponent extends React.Component<GalleryViewerCompone
this.loadFavoriteNotebooks(this.state.searchText, this.state.sortBy, false); // Need this to show correct favorite button state
}
public render(): JSX.Element {
public override render(): JSX.Element {
this.traceViewGallery();
const tabs: GalleryTabInfo[] = [

View File

@@ -38,7 +38,7 @@ export class InfoComponent extends React.Component<InfoComponentProps> {
);
};
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<HoverCard plainCardProps={{ onRenderPlainCard: this.onHover }} instantOpenOnClick type={HoverCardType.plain}>
<div className="infoPanelMain">

View File

@@ -41,7 +41,7 @@ export class NotebookMetadataComponent extends React.Component<NotebookMetadataC
);
};
public render(): JSX.Element {
public override render(): JSX.Element {
const options: Intl.DateTimeFormatOptions = {
year: "numeric",
month: "short",

View File

@@ -132,7 +132,7 @@ export class NotebookViewerComponent
}
}
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<div className="notebookViewerContainer">
{this.props.backNavigationText !== undefined ? (

View File

@@ -62,7 +62,7 @@ export class QueriesGridComponent extends React.Component<QueriesGridComponentPr
this.selection.setItems(this.state.filteredResults);
}
public componentDidUpdate(prevProps: QueriesGridComponentProps, prevState: QueriesGridComponentState): void {
public override componentDidUpdate(prevProps: QueriesGridComponentProps, prevState: QueriesGridComponentState): void {
this.selection.setItems(
this.state.filteredResults,
!_.isEqual(prevState.filteredResults, this.state.filteredResults)
@@ -79,11 +79,11 @@ export class QueriesGridComponent extends React.Component<QueriesGridComponentPr
}
// fetched saved queries when panel open
public componentDidMount() {
public override componentDidMount() {
this.fetchSavedQueries();
}
public render(): JSX.Element {
public override render(): JSX.Element {
if (this.state.queries.length === 0) {
return this.renderBannerComponent();
}

View File

@@ -20,7 +20,7 @@ export interface RadioSwitchComponentProps {
}
export class RadioSwitchComponent extends React.Component<RadioSwitchComponentProps> {
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<div className="radioSwitchComponent">
{this.props.choices.map((choice: Choice) => (

View File

@@ -17,7 +17,7 @@ export abstract class ResizeSensorComponent<P, S> extends React.Component<P, S>
protected abstract onDimensionsChanged(width: number, height: number): void;
protected abstract getSensorTarget(): HTMLElement;
public componentDidUpdate(): void {
public override componentDidUpdate(): void {
if (this.isSensing) {
return;
}
@@ -37,7 +37,7 @@ export abstract class ResizeSensorComponent<P, S> extends React.Component<P, S>
}
}
public componentWillUnmount(): void {
public override componentWillUnmount(): void {
if (!!this.resizeSensor) {
this.resizeSensor.detach();
}

View File

@@ -213,7 +213,7 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
};
}
componentDidMount(): void {
public override componentDidMount(): void {
if (this.isCollectionSettingsTab) {
this.refreshIndexTransformationProgress();
this.loadMongoIndexes();
@@ -226,7 +226,7 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
}
}
componentDidUpdate(): void {
public override componentDidUpdate(): void {
if (this.props.settingsTab.isActive()) {
this.props.settingsTab.getContainer().onUpdateTabsButtons(this.getTabsButtons());
}
@@ -879,7 +879,7 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
return mongoIndexingPolicyAADError;
};
public render(): JSX.Element {
public override render(): JSX.Element {
const scaleComponentProps: ScaleComponentProps = {
collection: this.collection,
database: this.database,

View File

@@ -26,7 +26,7 @@ import {
} from "./SettingsRenderUtils";
class SettingsRenderUtilsTestComponent extends React.Component {
public render(): JSX.Element {
public override render(): JSX.Element {
const estimatedSpendingColumns: IColumn[] = [
{ key: "costType", name: "", fieldName: "costType", minWidth: 100, maxWidth: 200, isResizable: true },
{ key: "hourly", name: "Hourly", fieldName: "hourly", minWidth: 100, maxWidth: 200, isResizable: true },

View File

@@ -40,11 +40,11 @@ export class ConflictResolutionComponent extends React.Component<ConflictResolut
{ key: DataModels.ConflictResolutionMode.Custom, text: "Merge Procedure (custom)" },
];
componentDidMount(): void {
public override componentDidMount(): void {
this.onComponentUpdate();
}
componentDidUpdate(): void {
public override componentDidUpdate(): void {
this.onComponentUpdate();
}
@@ -135,7 +135,7 @@ export class ConflictResolutionComponent extends React.Component<ConflictResolut
/>
);
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<Stack {...subComponentStackProps}>
{this.getConflictResolutionModeComponent()}

View File

@@ -38,7 +38,7 @@ export class IndexingPolicyComponent extends React.Component<
};
}
componentDidUpdate(): void {
public override componentDidUpdate(): void {
if (this.props.shouldDiscardIndexingPolicy) {
this.resetIndexingPolicyEditor();
this.props.resetShouldDiscardIndexingPolicy();
@@ -46,7 +46,7 @@ export class IndexingPolicyComponent extends React.Component<
this.onComponentUpdate();
}
componentDidMount(): void {
public override componentDidMount(): void {
this.resetIndexingPolicyEditor();
this.onComponentUpdate();
}
@@ -112,7 +112,7 @@ export class IndexingPolicyComponent extends React.Component<
}
};
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<Stack {...titleAndInputStackProps}>
<IndexingPolicyRefreshComponent

View File

@@ -52,7 +52,7 @@ export class IndexingPolicyRefreshComponent extends React.Component<
}
};
public render(): JSX.Element {
public override render(): JSX.Element {
return this.renderIndexTransformationWarning() ? (
<MessageBar messageBarType={MessageBarType.warning}>{this.renderIndexTransformationWarning()}</MessageBar>
) : (

View File

@@ -61,7 +61,7 @@ export class AddMongoIndexComponent extends React.Component<AddMongoIndexCompone
this.descriptionTextField.focus();
};
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<Stack {...mongoWarningStackProps}>
<Stack horizontal tokens={addMongoIndexSubElementsTokens}>

View File

@@ -89,14 +89,14 @@ export class MongoIndexingPolicyComponent extends React.Component<MongoIndexingP
},
];
componentDidUpdate(prevProps: MongoIndexingPolicyComponentProps): void {
public override componentDidUpdate(prevProps: MongoIndexingPolicyComponentProps): void {
if (this.props.indexesToAdd.length > prevProps.indexesToAdd.length) {
this.addMongoIndexComponentRefs[prevProps.indexesToAdd.length]?.current?.focus();
}
this.onComponentUpdate();
}
componentDidMount(): void {
public override componentDidMount(): void {
this.onComponentUpdate();
}
@@ -311,7 +311,7 @@ export class MongoIndexingPolicyComponent extends React.Component<MongoIndexingP
);
};
public render(): JSX.Element {
public override render(): JSX.Element {
if (this.props.mongoIndexes) {
if (this.hasCompoundIndex()) {
return mongoCompoundIndexNotSupportedMessage;

View File

@@ -216,7 +216,7 @@ export class ScaleComponent extends React.Component<ScaleComponentProps> {
);
}
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<Stack {...subComponentStackProps}>
{this.isFreeTierAccount() && (

View File

@@ -72,11 +72,11 @@ export class SubSettingsComponent extends React.Component<SubSettingsComponentPr
this.partitionKeyName = userContext.apiType === "Mongo" ? "Shard key" : "Partition key";
}
componentDidMount(): void {
public override componentDidMount(): void {
this.onComponentUpdate();
}
componentDidUpdate(): void {
public override componentDidUpdate(): void {
this.onComponentUpdate();
}
@@ -323,7 +323,7 @@ export class SubSettingsComponent extends React.Component<SubSettingsComponentPr
public isLargePartitionKeyEnabled = (): boolean => this.props.collection.partitionKey?.version >= 2;
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<Stack {...subComponentStackProps}>
{userContext.apiType !== "Cassandra" && this.getTtlComponent()}

View File

@@ -96,11 +96,11 @@ export class ThroughputInputAutoPilotV3Component extends React.Component<
{ key: "false", text: "Manual" },
];
componentDidMount(): void {
public override componentDidMount(): void {
this.onComponentUpdate();
}
componentDidUpdate(): void {
public override componentDidUpdate(): void {
this.onComponentUpdate();
}
@@ -627,7 +627,7 @@ export class ThroughputInputAutoPilotV3Component extends React.Component<
);
};
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<Stack {...checkBoxAndInputStackProps}>
{this.renderWarningMessage()}

View File

@@ -10,7 +10,7 @@ export interface ToolTipLabelComponentProps {
const iconButtonStyles: Partial<IIconStyles> = { root: { marginBottom: -3 } };
export class ToolTipLabelComponent extends React.Component<ToolTipLabelComponentProps> {
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<>
<Stack horizontal verticalAlign="center" tokens={toolTipLabelStackTokens}>

View File

@@ -103,6 +103,7 @@ exports[`SettingsComponent renders 1`] = `
"id": "addcollectionpane",
"isAnalyticalStorageOn": [Function],
"isAutoPilotSelected": [Function],
"isEnableMongoCapabilityEnabled": [Function],
"isExecuting": [Function],
"isFixedStorageSelected": [Function],
"isFreeTierAccount": [Function],
@@ -253,6 +254,7 @@ exports[`SettingsComponent renders 1`] = `
"id": "addcollectionpane",
"isAnalyticalStorageOn": [Function],
"isAutoPilotSelected": [Function],
"isEnableMongoCapabilityEnabled": [Function],
"isExecuting": [Function],
"isFixedStorageSelected": [Function],
"isFreeTierAccount": [Function],
@@ -1379,6 +1381,7 @@ exports[`SettingsComponent renders 1`] = `
"id": "addcollectionpane",
"isAnalyticalStorageOn": [Function],
"isAutoPilotSelected": [Function],
"isEnableMongoCapabilityEnabled": [Function],
"isExecuting": [Function],
"isFixedStorageSelected": [Function],
"isFreeTierAccount": [Function],
@@ -1529,6 +1532,7 @@ exports[`SettingsComponent renders 1`] = `
"id": "addcollectionpane",
"isAnalyticalStorageOn": [Function],
"isAutoPilotSelected": [Function],
"isEnableMongoCapabilityEnabled": [Function],
"isExecuting": [Function],
"isFixedStorageSelected": [Function],
"isFreeTierAccount": [Function],
@@ -2668,6 +2672,7 @@ exports[`SettingsComponent renders 1`] = `
"id": "addcollectionpane",
"isAnalyticalStorageOn": [Function],
"isAutoPilotSelected": [Function],
"isEnableMongoCapabilityEnabled": [Function],
"isExecuting": [Function],
"isFixedStorageSelected": [Function],
"isFreeTierAccount": [Function],
@@ -2818,6 +2823,7 @@ exports[`SettingsComponent renders 1`] = `
"id": "addcollectionpane",
"isAnalyticalStorageOn": [Function],
"isAutoPilotSelected": [Function],
"isEnableMongoCapabilityEnabled": [Function],
"isExecuting": [Function],
"isFixedStorageSelected": [Function],
"isFreeTierAccount": [Function],
@@ -3944,6 +3950,7 @@ exports[`SettingsComponent renders 1`] = `
"id": "addcollectionpane",
"isAnalyticalStorageOn": [Function],
"isAutoPilotSelected": [Function],
"isEnableMongoCapabilityEnabled": [Function],
"isExecuting": [Function],
"isFixedStorageSelected": [Function],
"isFreeTierAccount": [Function],
@@ -4094,6 +4101,7 @@ exports[`SettingsComponent renders 1`] = `
"id": "addcollectionpane",
"isAnalyticalStorageOn": [Function],
"isAutoPilotSelected": [Function],
"isEnableMongoCapabilityEnabled": [Function],
"isExecuting": [Function],
"isFixedStorageSelected": [Function],
"isFreeTierAccount": [Function],

View File

@@ -115,7 +115,7 @@ export class SmartUiComponent extends React.Component<SmartUiComponentProps, Sma
fontSize: 12,
};
componentDidUpdate(): void {
public override componentDidUpdate(): void {
if (!this.shouldCheckErrors) {
this.shouldCheckErrors = true;
return;
@@ -407,7 +407,7 @@ export class SmartUiComponent extends React.Component<SmartUiComponentProps, Sma
);
}
render(): JSX.Element {
public override render(): JSX.Element {
return this.renderNode(this.props.descriptor.root);
}
}

View File

@@ -68,7 +68,7 @@ export class TabComponent extends React.Component<TabComponentProps> {
});
}
public render(): JSX.Element {
public override render(): JSX.Element {
const currentTabContent = this.props.tabs[this.props.currentTabIndex].content;
let className = "tabComponentContent";
if (currentTabContent.className) {

View File

@@ -38,7 +38,7 @@ export class ThroughputInput extends React.Component<ThroughputInputProps, Throu
this.props.setIsAutoscale(true);
}
render(): JSX.Element {
public override render(): JSX.Element {
return (
<div className="throughputInputContainer throughputInputSpacing">
<Stack horizontal>

View File

@@ -56,7 +56,7 @@ export interface TreeComponentProps {
}
export class TreeComponent extends React.Component<TreeComponentProps> {
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<div style={this.props.style} className={`treeComponent ${this.props.className}`}>
<TreeNodeComponent paddingLeft={0} node={this.props.rootNode} generation={0} />
@@ -93,7 +93,7 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
};
}
componentDidUpdate(prevProps: TreeNodeComponentProps, prevState: TreeNodeComponentState) {
public override componentDidUpdate(prevProps: TreeNodeComponentProps, prevState: TreeNodeComponentState) {
// Only call when expand has actually changed
if (this.state.isExpanded !== prevState.isExpanded) {
if (this.state.isExpanded) {
@@ -110,7 +110,7 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
}
}
public render(): JSX.Element {
public override render(): JSX.Element {
return this.renderNode(this.props.node, this.props.generation);
}

View File

@@ -1,6 +1,5 @@
import * as ko from "knockout";
import { IChoiceGroupProps } from "@fluentui/react";
import * as path from "path";
import * as ko from "knockout";
import Q from "q";
import React from "react";
import _ from "underscore";
@@ -1843,39 +1842,6 @@ export default class Explorer {
}
}
public async openNotebookViewer(notebookUrl: string) {
const title = path.basename(notebookUrl);
const hashLocation = notebookUrl;
const NotebookViewerTab = await (
await import(/* webpackChunkName: "NotebookViewerTab" */ "./Tabs/NotebookViewerTab")
).default;
const notebookViewerTab = this.tabsManager.getTabs(ViewModels.CollectionTabKind.NotebookV2).find((tab) => {
return tab.hashLocation() == hashLocation && tab instanceof NotebookViewerTab && tab.notebookUrl === notebookUrl;
});
if (notebookViewerTab) {
this.tabsManager.activateNewTab(notebookViewerTab);
} else {
const notebookViewerTab = new NotebookViewerTab({
account: userContext.databaseAccount,
tabKind: ViewModels.CollectionTabKind.NotebookViewer,
node: null,
title: title,
tabPath: title,
collection: null,
hashLocation: hashLocation,
isTabsContentExpanded: ko.observable(true),
onLoadStartKey: null,
onUpdateTabsButtons: this.onUpdateTabsButtons,
container: this,
notebookUrl,
});
this.tabsManager.activateNewTab(notebookViewerTab);
}
}
public onNewCollectionClicked(databaseId?: string): void {
if (userContext.apiType === "Cassandra") {
this.cassandraAddCollectionPane.open();

View File

@@ -34,7 +34,7 @@ export class EditorNeighborsComponent extends React.Component<EditorNeighborsCom
this.addNewEdgeToNeighbor = this.props.isSource ? this.addNewEdgeToSource : this.addNewEdgeToTarget;
}
public componentDidMount(): void {
public override componentDidMount(): void {
// Show empty text boxes by default if no neighbor for convenience
if (this.props.editedNeighbors.currentNeighbors.length === 0) {
if (this.props.isSource) {
@@ -45,7 +45,7 @@ export class EditorNeighborsComponent extends React.Component<EditorNeighborsCom
}
}
public render(): JSX.Element {
public override render(): JSX.Element {
const neighborTitle = this.props.isSource
? EditorNeighborsComponent.SOURCE_TITLE
: EditorNeighborsComponent.TARGET_TITLE;

View File

@@ -20,7 +20,7 @@ export class EditorNodePropertiesComponent extends React.Component<EditorNodePro
public static readonly VERTEX_PROPERTY_TYPES = ["string", "number", "boolean" /* 'null' */]; // TODO Enable null when fully supported by backend
private static readonly DEFAULT_PROPERTY_TYPE = "string";
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<table className="propertyTable">
<tbody>

View File

@@ -965,7 +965,7 @@ export class GraphExplorer extends React.Component<GraphExplorerProps, GraphExpl
}
/* ************* React life-cycle methods *********** */
public render(): JSX.Element {
public override render(): JSX.Element {
const currentTabIndex = ((resultDisplay: ResultDisplay): number => {
switch (resultDisplay) {
case ResultDisplay.Graph:
@@ -1022,10 +1022,10 @@ export class GraphExplorer extends React.Component<GraphExplorerProps, GraphExpl
);
}
public componentWillUnmount(): void {
public override componentWillUnmount(): void {
this.gremlinClient.destroy();
}
public componentDidMount(): void {
public override componentDidMount(): void {
if (this.props.onLoadStartKey != null && this.props.onLoadStartKey != undefined) {
TelemetryProcessor.traceSuccess(
Action.Tab,
@@ -1069,7 +1069,7 @@ export class GraphExplorer extends React.Component<GraphExplorerProps, GraphExpl
}
}
public componentDidUpdate(): void {
public override componentDidUpdate(): void {
this.onIsPropertyPaneEditing(this.isPropertyPaneEditing());
this.onIsNewVertexDisabledChange(this.isNewVertexDisabled());
}

View File

@@ -18,20 +18,20 @@ export class GraphVizComponent extends React.Component<GraphVizComponentProps> {
this.forceGraph = new D3ForceGraph(this.props.forceGraphParams);
}
public componentDidMount(): void {
public override componentDidMount(): void {
this.forceGraph.init(this.rootNode);
}
public shouldComponentUpdate(): boolean {
public override shouldComponentUpdate(): boolean {
// Prevents component re-rendering
return false;
}
public componentWillUnmount(): void {
public override componentWillUnmount(): void {
this.forceGraph.destroy();
}
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<svg id="maingraph" ref={(elt: Element) => this.setRef(elt)}>
<title>Main Graph</title>

View File

@@ -18,7 +18,7 @@ interface LeftPaneComponentProps {
}
export class LeftPaneComponent extends React.Component<LeftPaneComponentProps> {
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<div className="leftPane">
<div className="paneTitle leftPaneResults">Results</div>

View File

@@ -12,7 +12,7 @@ interface MiddlePaneComponentProps {
}
export class MiddlePaneComponent extends React.Component<MiddlePaneComponentProps> {
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<div className="middlePane">
<div className="graphTitle">

View File

@@ -104,7 +104,7 @@ export class NodePropertiesComponent extends React.Component<
return null;
}
public render(): JSX.Element {
public override render(): JSX.Element {
if (!this.props.node) {
return <span />;
} else {

View File

@@ -25,7 +25,7 @@ export class QueryContainerComponent extends React.Component<
};
}
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<div className="queryContainer">
<InputTypeaheadComponent.InputTypeaheadComponent

View File

@@ -20,7 +20,7 @@ export class ReadOnlyNeighborsComponent extends React.Component<ReadOnlyNeighbor
private static readonly NO_TARGETS_LABEL = "No targets found";
private static readonly TARGET_TITLE = "Target";
public render(): JSX.Element {
public override render(): JSX.Element {
const neighbors = this.props.isSource ? this.props.node.sources : this.props.node.targets;
const noNeighborsLabel = this.props.isSource
? ReadOnlyNeighborsComponent.NO_SOURCES_LABEL

View File

@@ -12,7 +12,7 @@ export interface ReadOnlyNodePropertiesComponentProps {
}
export class ReadOnlyNodePropertiesComponent extends React.Component<ReadOnlyNodePropertiesComponentProps> {
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<table className="roPropertyTable propertyTable">
<tbody>

View File

@@ -10,17 +10,17 @@ interface MemoryTrackerProps {
export class MemoryTrackerComponent extends React.Component<MemoryTrackerProps> {
private memoryUsageInfoSubscription: Subscription;
public componentDidMount(): void {
public override componentDidMount(): void {
this.memoryUsageInfoSubscription = this.props.memoryUsageInfo.subscribe(() => {
this.forceUpdate();
});
}
public componentWillUnmount(): void {
public override componentWillUnmount(): void {
this.memoryUsageInfoSubscription && this.memoryUsageInfoSubscription.dispose();
}
public render(): JSX.Element {
public override render(): JSX.Element {
const memoryUsageInfo: MemoryUsageInfo = this.props.memoryUsageInfo();
if (!memoryUsageInfo) {
return (

View File

@@ -23,7 +23,7 @@ export class ControlBarComponent extends React.Component<ControlBarComponentProp
);
}
public render(): JSX.Element {
public override render(): JSX.Element {
if (!this.props.buttons || this.props.buttons.length < 1) {
return <React.Fragment />;
}

View File

@@ -74,7 +74,7 @@ export class NotificationConsoleComponent extends React.Component<
this.prevHeaderStatus = undefined;
}
public componentDidUpdate(
public override componentDidUpdate(
prevProps: NotificationConsoleComponentProps,
prevState: NotificationConsoleComponentState
): void {
@@ -102,7 +102,7 @@ export class NotificationConsoleComponent extends React.Component<
this.consoleHeaderElement = element;
};
public render(): JSX.Element {
public override render(): JSX.Element {
const numInProgress = this.state.allConsoleData.filter(
(data: ConsoleData) => data.type === ConsoleDataType.InProgress
).length;

View File

@@ -6,11 +6,11 @@ import { default as Contents } from "./contents";
export class NotebookComponent extends React.Component<{ contentRef: ContentRef }> {
notificationSystem!: ReactNotificationSystem;
shouldComponentUpdate(nextProps: { contentRef: ContentRef }): boolean {
public override shouldComponentUpdate(nextProps: { contentRef: ContentRef }): boolean {
return nextProps.contentRef !== this.props.contentRef;
}
public render(): JSX.Element {
public override render(): JSX.Element {
return (
<div className="notebookComponentContainer">
<Contents contentRef={this.props.contentRef} />

View File

@@ -53,7 +53,7 @@ export class NotebookComponentAdapter extends NotebookComponentBootstrapper impl
};
}
protected renderExtraComponent = (): JSX.Element => {
protected override renderExtraComponent = (): JSX.Element => {
return <VirtualCommandBarComponent contentRef={this.contentRef} onRender={this.onUpdateKernelInfo} />;
};
}

View File

@@ -16,7 +16,7 @@ class VirtualCommandBarComponent extends React.Component<VirtualCommandBarCompon
this.state = {};
}
shouldComponentUpdate(nextProps: VirtualCommandBarComponentProps): boolean {
public override shouldComponentUpdate(nextProps: VirtualCommandBarComponentProps): boolean {
return (
this.props.kernelStatus !== nextProps.kernelStatus ||
this.props.kernelSpecName !== nextProps.kernelSpecName ||
@@ -24,7 +24,7 @@ class VirtualCommandBarComponent extends React.Component<VirtualCommandBarCompon
);
}
public render(): JSX.Element {
public override render(): JSX.Element {
this.props.onRender && this.props.onRender();
return <></>;
}

View File

@@ -55,7 +55,7 @@ export class File extends React.PureComponent<FileProps> {
return choice;
};
render(): JSX.Element {
public override render(): JSX.Element {
const choice = this.getChoice();
// Right now we only handle one kind of editor

View File

@@ -35,7 +35,7 @@ interface TextFileState {
}
class EditorPlaceholder extends React.PureComponent<MonacoEditorProps> {
render(): JSX.Element {
public override render(): JSX.Element {
// TODO: Show a little blocky placeholder
return null;
}
@@ -53,13 +53,13 @@ export class TextFile extends React.PureComponent<TextFileProps, TextFileState>
this.props.handleChange(source);
};
componentDidMount(): void {
public override componentDidMount(): void {
import(/* webpackChunkName: "monaco-editor" */ "@nteract/monaco-editor").then((module) => {
this.setState({ Editor: module.default });
});
}
render(): JSX.Element {
public override render(): JSX.Element {
const Editor = this.state.Editor;
return (

View File

@@ -54,7 +54,7 @@ class Contents extends React.PureComponent<ContentsProps> {
SAVE: ["ctrl+s", "ctrl+shift+s", "meta+s", "meta+shift+s"],
};
render(): JSX.Element {
public override render(): JSX.Element {
const { contentRef, handlers } = this.props;
if (!contentRef) {

View File

@@ -25,7 +25,7 @@ export interface NotebookRendererProps {
* This is the class that uses nteract to render a read-only notebook.
*/
class NotebookReadOnlyRenderer extends React.Component<NotebookRendererProps> {
componentDidMount() {
public override componentDidMount() {
if (!userContext.features.sandboxNotebookOutputs) {
loadTransform(this.props as any);
}
@@ -54,7 +54,7 @@ class NotebookReadOnlyRenderer extends React.Component<NotebookRendererProps> {
);
}
render(): JSX.Element {
public override render(): JSX.Element {
return (
<div className="NotebookReadOnlyRender">
<Cells contentRef={this.props.contentRef}>

View File

@@ -68,22 +68,22 @@ class BaseNotebookRenderer extends React.Component<NotebookRendererProps> {
};
}
componentDidMount() {
public override componentDidMount() {
if (!userContext.features.sandboxNotebookOutputs) {
loadTransform(this.props as any);
}
this.props.updateNotebookParentDomElt(this.props.contentRef, this.notebookRendererRef.current);
}
componentDidUpdate() {
public override componentDidUpdate() {
this.props.updateNotebookParentDomElt(this.props.contentRef, this.notebookRendererRef.current);
}
componentWillUnmount() {
public override componentWillUnmount() {
this.props.updateNotebookParentDomElt(this.props.contentRef, undefined);
}
render(): JSX.Element {
public override render(): JSX.Element {
return (
<>
<div className="NotebookRendererContainer">

View File

@@ -36,7 +36,7 @@ interface DispatchProps {
type Props = StateProps & DispatchProps & ComponentProps;
export class PromptPure extends React.Component<Props> {
render() {
public override render() {
return (
<div className="nteract-cell-prompt">
{this.props.children({

View File

@@ -45,14 +45,14 @@ const BarContainer = styled.div`
`;
export class StatusBar extends React.Component<Props> {
shouldComponentUpdate(nextProps: Props): boolean {
public override shouldComponentUpdate(nextProps: Props): boolean {
if (this.props.lastSaved !== nextProps.lastSaved || this.props.kernelStatus !== nextProps.kernelStatus) {
return true;
}
return false;
}
render() {
public override render() {
const name = this.props.kernelSpecDisplayName || "Loading...";
return (

View File

@@ -37,7 +37,7 @@ interface StateProps {
class BaseToolbar extends React.PureComponent<ComponentProps & DispatchProps & StateProps> {
static contextType = CellToolbarContext;
render(): JSX.Element {
public override render(): JSX.Element {
let items: IContextualMenuItem[] = [];
if (this.props.cellType === "code") {

View File

@@ -132,7 +132,7 @@ export class PureCellCreator extends React.PureComponent<CellCreatorProps> {
this.props.createCell("code", this.props.above);
};
render() {
public override render() {
return (
<CreatorHoverMask>
<CreatorHoverRegion>
@@ -171,7 +171,7 @@ class CellCreator extends React.PureComponent<ComponentProps & DispatchProps & S
: createCellBelow({ cellType: type, id, source: "", contentRef });
};
render() {
public override render() {
return (
<React.Fragment>
{this.props.isFirstCell && (

View File

@@ -19,7 +19,7 @@ interface StateProps {
* Displays "Cell <index>"
*/
class CellLabeler extends React.Component<ComponentProps & StateProps> {
render() {
public override render() {
return (
<div className="CellLabeler">
<div className="CellLabel">Cell {this.props.cellIndex + 1}</div>

View File

@@ -20,7 +20,7 @@ interface DispatchProps {
* HoverableCell sets the hovered cell
*/
class HoverableCell extends React.Component<ComponentProps & DispatchProps> {
render() {
public override render() {
return (
<div className="HoverableCell" onMouseEnter={this.props.hover} onMouseLeave={this.props.unHover}>
{this.props.children}

View File

@@ -173,11 +173,11 @@ function collectTarget(
export class DraggableCellView extends React.Component<Props & DnDSourceProps & DnDTargetProps, State> {
el?: HTMLDivElement | null;
state = {
public override state = {
hoverUpperHalf: true,
};
componentDidMount(): void {
public override componentDidMount(): void {
const connectDragPreview = this.props.connectDragPreview;
const img = new (window as any).Image();
@@ -193,7 +193,7 @@ export class DraggableCellView extends React.Component<Props & DnDSourceProps &
focusCell({ id, contentRef });
};
render() {
public override render() {
return this.props.connectDropTarget(
// Sadly connectDropTarget _has_ to take a React element for a DOM element (no styled-divs)
<div>

View File

@@ -47,15 +47,15 @@ export class HijackScroll extends React.Component<Props> {
}
}
componentDidUpdate(prevProps: Props) {
public override componentDidUpdate(prevProps: Props) {
this.scrollIntoViewIfNeeded(prevProps.focused);
}
componentDidMount(): void {
public override componentDidMount(): void {
this.scrollIntoViewIfNeeded();
}
render() {
public override render() {
return (
<div
onClick={this.props.selectCell}

View File

@@ -31,18 +31,18 @@ export class KeyboardShortcuts extends React.Component<Props> {
this.keyDown = this.keyDown.bind(this);
}
shouldComponentUpdate(nextProps: Props) {
public override shouldComponentUpdate(nextProps: Props) {
const newContentRef = this.props.contentRef !== nextProps.contentRef;
const newFocusedCell = this.props.focusedCell !== nextProps.focusedCell;
const newCellOrder = this.props.cellOrder && this.props.cellOrder.size !== nextProps.cellOrder.size;
return newContentRef || newFocusedCell || newCellOrder;
}
componentDidMount(): void {
public override componentDidMount(): void {
document.addEventListener("keydown", this.keyDown);
}
componentWillUnmount(): void {
public override componentWillUnmount(): void {
document.removeEventListener("keydown", this.keyDown);
}
@@ -102,7 +102,7 @@ export class KeyboardShortcuts extends React.Component<Props> {
}
}
render() {
public override render() {
return <React.Fragment>{this.props.children}</React.Fragment>;
}
}

View File

@@ -54,7 +54,7 @@ export const Source = styled(BareSource)`
width: -moz-available;
`;
export class PureMarkdownCell extends React.Component<ComponentProps & DispatchProps & StateProps> {
render() {
public override render() {
const { contentRef, id, cell, children } = this.props;
const { isEditorFocused, isCellFocused, markdownOptions } = this.props;

View File

@@ -33,7 +33,7 @@ interface DispatchProps {
export class SandboxOutputs extends React.PureComponent<ComponentProps & StateProps & DispatchProps> {
private childWindow: Window;
render(): JSX.Element {
public override render(): JSX.Element {
// Using min-width to set the width of the iFrame, works around an issue in iOS that can prevent the iFrame from sizing correctly.
return (
<IframeResizer
@@ -72,11 +72,11 @@ export class SandboxOutputs extends React.PureComponent<ComponentProps & StatePr
postRobot.send(this.childWindow, "props", props);
}
componentDidMount(): void {
public override componentDidMount(): void {
this.sendPropsToFrame();
}
componentDidUpdate(): void {
public override componentDidUpdate(): void {
this.sendPropsToFrame();
}
}

View File

@@ -46,7 +46,7 @@ export class SchemaAnalyzerComponent extends React.Component<
};
}
componentDidMount(): void {
public override componentDidMount(): void {
loadTransform(this.props);
}
@@ -78,7 +78,7 @@ export class SchemaAnalyzerComponent extends React.Component<
this.props.runCell(this.props.contentRef, this.props.firstCellId);
};
render(): JSX.Element {
public override render(): JSX.Element {
const { firstCellId: id, contentRef, kernelStatus, outputs } = this.props;
if (!id) {
return <></>;

View File

@@ -71,7 +71,7 @@ export class SchemaAnalyzerComponentAdapter extends NotebookComponentBootstrappe
}
}
public renderComponent(): JSX.Element {
public override renderComponent(): JSX.Element {
const props = {
contentRef: this.contentRef,
kernelRef: this.kernelRef,

View File

@@ -438,7 +438,7 @@
<!-- Provision collection throughput - end -->
<!-- Custom indexes for mongo checkbox - start -->
<div class="pkPadding" data-bind="visible: container.isEnableMongoCapabilityPresent()">
<div class="pkPadding" data-bind="visible: isEnableMongoCapabilityEnabled()">
<p>
<span class="addCollectionLabel">Indexing</span>
</p>

View File

@@ -14,6 +14,7 @@ import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstan
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import { userContext } from "../../UserContext";
import * as AutoPilotUtils from "../../Utils/AutoPilotUtils";
import { isCapabilityEnabled } from "../../Utils/CapabilityUtils";
import * as PricingUtils from "../../Utils/PricingUtils";
import { DynamicListItem } from "../Controls/DynamicList/DynamicListComponent";
import { ContextualPaneBase } from "./ContextualPaneBase";
@@ -35,7 +36,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
public collectionWithThroughputInShared: ko.Observable<boolean>;
public databaseCreateNewShared: ko.Observable<boolean>;
public databaseHasSharedOffer: ko.Observable<boolean>;
public formErrorsDetails: ko.Observable<string>;
public override formErrorsDetails: ko.Observable<string>;
public formWarnings: ko.Observable<string>;
public partitionKey: ko.Observable<string>;
public partitionKeyName: ko.Computed<string>;
@@ -95,6 +96,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
public shouldCreateMongoWildcardIndex: ko.Observable<boolean>;
private _isSynapseLinkEnabled: ko.Computed<boolean>;
private isEnableMongoCapabilityEnabled: ko.Observable<boolean>;
constructor(options: AddCollectionPaneOptions) {
super(options);
@@ -634,6 +636,8 @@ export default class AddCollectionPane extends ContextualPaneBase {
});
});
this.isEnableMongoCapabilityEnabled = ko.observable(isCapabilityEnabled("EnableMongo"));
this.shouldCreateMongoWildcardIndex = ko.observable(this.container.isMongoIndexingEnabled());
}
@@ -654,7 +658,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
return true;
};
public async open(databaseId?: string) {
public override async open(databaseId?: string) {
super.open();
// TODO: Figure out if a database level partition split is about to happen once shared throughput read is available
this.formWarnings("");
@@ -748,7 +752,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
return this._getThroughput();
}
public submit() {
public override submit() {
if (!this.isValid()) {
return;
}
@@ -908,7 +912,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
);
}
public resetData() {
public override resetData() {
this.collectionId("");
this.databaseId("");
this.partitionKey("");

View File

@@ -25,6 +25,7 @@ import { Action } from "../../Shared/Telemetry/TelemetryConstants";
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import { userContext } from "../../UserContext";
import { getCollectionName } from "../../Utils/APITypeUtils";
import { isCapabilityEnabled } from "../../Utils/CapabilityUtils";
import { getUpsellMessage } from "../../Utils/PricingUtils";
import { CollapsibleSectionComponent } from "../Controls/CollapsiblePanel/CollapsibleSectionComponent";
import { ThroughputInput } from "../Controls/ThroughputInput/ThroughputInput";
@@ -80,7 +81,7 @@ export class AddCollectionPanel extends React.Component<AddCollectionPanelProps,
isSharded: userContext.apiType !== "Tables",
partitionKey: "",
enableDedicatedThroughput: false,
createMongoWildCardIndex: true,
createMongoWildCardIndex: isCapabilityEnabled("EnableMongo"),
useHashV2: false,
enableAnalyticalStore: false,
uniqueKeys: [],
@@ -90,7 +91,7 @@ export class AddCollectionPanel extends React.Component<AddCollectionPanelProps,
};
}
render(): JSX.Element {
public override render(): JSX.Element {
return (
<form className="panelFormWrapper" onSubmit={this.submit.bind(this)}>
{this.state.errorMessage && (
@@ -525,7 +526,7 @@ export class AddCollectionPanel extends React.Component<AddCollectionPanelProps,
}}
>
<Stack className="panelGroupSpacing" id="collapsibleSectionContent">
{userContext.databaseAccount.properties.capabilities.find((c) => c.name === "EnableMongo") && (
{isCapabilityEnabled("EnableMongo") && (
<Stack className="panelGroupSpacing">
<Stack horizontal>
<span className="mandatoryStar">*&nbsp;</span>
@@ -851,7 +852,7 @@ export class AddCollectionPanel extends React.Component<AddCollectionPanelProps,
return true;
}
return properties.capabilities.some(
return properties.capabilities?.some(
(capability) => capability.name === Constants.CapabilityNames.EnableStorageAnalytics
);
}

View File

@@ -23,7 +23,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
public databaseIdTooltipText: ko.Computed<string>;
public databaseLevelThroughputTooltipText: ko.Computed<string>;
public databaseCreateNewShared: ko.Observable<boolean>;
public formErrorsDetails: ko.Observable<string>;
public override formErrorsDetails: ko.Observable<string>;
public throughput: ViewModels.Editable<number>;
public maxThroughputRU: ko.Observable<number>;
public minThroughputRU: ko.Observable<number>;
@@ -255,7 +255,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
return true;
};
public open() {
public override open() {
super.open();
this.resetData();
const addDatabasePaneOpenMessage = {
@@ -272,7 +272,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
TelemetryProcessor.trace(Action.CreateDatabase, ActionModifiers.Open, addDatabasePaneOpenMessage);
}
public submit() {
public override submit() {
if (!this._isValid()) {
return;
}
@@ -317,7 +317,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
);
}
public resetData() {
public override resetData() {
this.databaseId("");
this.databaseCreateNewShared(this.getSharedThroughputDefault());
this.isAutoPilotSelected(this.container.isAutoscaleDefaultEnabled());

View File

@@ -279,7 +279,7 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase {
}
}
public open() {
public override open() {
super.open();
if (!this.container.isServerlessEnabled()) {
this.isAutoPilotSelected(this.container.isAutoscaleDefaultEnabled());
@@ -306,7 +306,7 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase {
TelemetryProcessor.trace(Action.CreateCollection, ActionModifiers.Open, addCollectionPaneOpenMessage);
}
public submit() {
public override submit() {
if (!this._isValid()) {
return;
}
@@ -436,7 +436,7 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase {
);
}
public resetData() {
public override resetData() {
super.resetData();
const throughputDefaults = this.container.collectionCreationDefaults.throughput;
this.isAutoPilotSelected(this.container.isAutoscaleDefaultEnabled());

View File

@@ -98,7 +98,7 @@ export class GitHubReposPanel extends React.Component<IGitHubReposPanelProps, IG
this.junoClient = this.props.junoClientProp;
}
componentDidMount(): void {
public override componentDidMount(): void {
this.open();
}
@@ -431,7 +431,7 @@ export class GitHubReposPanel extends React.Component<IGitHubReposPanelProps, IG
this.props.explorer.notebookManager?.gitHubOAuthService.startOAuth(scope);
}
render(): JSX.Element {
public override render(): JSX.Element {
return (
<form className="panelFormWrapper">
{this.state.errorMessage && (

View File

@@ -92,6 +92,7 @@ exports[`GitHub Repos Panel should render Default properly 1`] = `
"id": "addcollectionpane",
"isAnalyticalStorageOn": [Function],
"isAutoPilotSelected": [Function],
"isEnableMongoCapabilityEnabled": [Function],
"isExecuting": [Function],
"isFixedStorageSelected": [Function],
"isFreeTierAccount": [Function],
@@ -242,6 +243,7 @@ exports[`GitHub Repos Panel should render Default properly 1`] = `
"id": "addcollectionpane",
"isAnalyticalStorageOn": [Function],
"isAutoPilotSelected": [Function],
"isEnableMongoCapabilityEnabled": [Function],
"isExecuting": [Function],
"isFixedStorageSelected": [Function],
"isFreeTierAccount": [Function],

View File

@@ -61,7 +61,7 @@ export default class GraphStylingPane extends ContextualPaneBase {
this.remoteConfig = config;
}
public close() {
public override close() {
this.remoteConfig = null;
super.close();
}

View File

@@ -2,8 +2,6 @@ import AddCollectionPaneTemplate from "./AddCollectionPane.html";
import AddDatabasePaneTemplate from "./AddDatabasePane.html";
import CassandraAddCollectionPaneTemplate from "./CassandraAddCollectionPane.html";
import GraphStylingPaneTemplate from "./GraphStylingPane.html";
import TableAddEntityPaneTemplate from "./Tables/TableAddEntityPane.html";
import TableEditEntityPaneTemplate from "./Tables/TableEditEntityPane.html";
export class PaneComponent {
constructor(data: any) {
@@ -38,23 +36,6 @@ export class GraphStylingPaneComponent {
}
}
export class TableAddEntityPaneComponent {
constructor() {
return {
viewModel: PaneComponent,
template: TableAddEntityPaneTemplate,
};
}
}
export class TableEditEntityPaneComponent {
constructor() {
return {
viewModel: PaneComponent,
template: TableEditEntityPaneTemplate,
};
}
}
export class CassandraAddCollectionPaneComponent {
constructor() {
return {

View File

@@ -27,15 +27,15 @@ export class PanelContainerComponent extends React.Component<PanelContainerProps
};
}
componentDidMount(): void {
public override componentDidMount(): void {
window.addEventListener("resize", () => this.setState({ height: this.getPanelHeight() }));
}
componentWillUnmount(): void {
public override componentWillUnmount(): void {
window.removeEventListener("resize", () => this.setState({ height: this.getPanelHeight() }));
}
render(): JSX.Element {
public override render(): JSX.Element {
if (!this.props.panelContent) {
return <></>;
}

View File

@@ -82,6 +82,7 @@ exports[`StringInput Pane should render Create new directory properly 1`] = `
"id": "addcollectionpane",
"isAnalyticalStorageOn": [Function],
"isAutoPilotSelected": [Function],
"isEnableMongoCapabilityEnabled": [Function],
"isExecuting": [Function],
"isFixedStorageSelected": [Function],
"isFreeTierAccount": [Function],
@@ -232,6 +233,7 @@ exports[`StringInput Pane should render Create new directory properly 1`] = `
"id": "addcollectionpane",
"isAnalyticalStorageOn": [Function],
"isAutoPilotSelected": [Function],
"isEnableMongoCapabilityEnabled": [Function],
"isExecuting": [Function],
"isFixedStorageSelected": [Function],
"isFreeTierAccount": [Function],

View File

@@ -1,225 +0,0 @@
import * as ko from "knockout";
import _ from "underscore";
import * as ViewModels from "../../../Contracts/ViewModels";
import { userContext } from "../../../UserContext";
import Explorer from "../../Explorer";
import * as TableConstants from "../../Tables/Constants";
import * as Entities from "../../Tables/Entities";
import { CassandraAPIDataClient, CassandraTableKey } from "../../Tables/TableDataClient";
import * as TableEntityProcessor from "../../Tables/TableEntityProcessor";
import * as Utilities from "../../Tables/Utilities";
import EntityPropertyViewModel from "./EntityPropertyViewModel";
import TableEntityPane from "./TableEntityPane";
export default class EditTableEntityPane extends TableEntityPane {
container: Explorer;
visible: ko.Observable<boolean>;
public originEntity: Entities.ITableEntity;
public originalNumberOfProperties: number;
private originalDocument: any;
constructor(options: ViewModels.PaneOptions) {
super(options);
this.submitButtonText("Update Entity");
if (userContext.apiType === "Cassandra") {
this.submitButtonText("Update Row");
}
this.scrollId = ko.observable<string>("editEntityScroll");
}
public submit() {
if (!this.canApply()) {
return;
}
let entity: Entities.ITableEntity = this.updateEntity(this.displayedAttributes());
this.container.tableDataClient
.updateDocument(this.tableViewModel.queryTablesTab.collection, this.originalDocument, entity)
.then((newEntity: Entities.ITableEntity) => {
var numberOfProperties = 0;
for (var property in newEntity) {
if (
property !== TableEntityProcessor.keyProperties.attachments &&
property !== TableEntityProcessor.keyProperties.etag &&
property !== TableEntityProcessor.keyProperties.resourceId &&
property !== TableEntityProcessor.keyProperties.self &&
(userContext.apiType !== "Cassandra" || property !== TableConstants.EntityKeyNames.RowKey)
) {
numberOfProperties++;
}
}
var propertiesDelta = numberOfProperties - this.originalNumberOfProperties;
return this.tableViewModel
.updateCachedEntity(newEntity)
.then(() => {
if (!this.tryInsertNewHeaders(this.tableViewModel, newEntity)) {
this.tableViewModel.redrawTableThrottled();
}
})
.then(() => {
// Selecting updated entity
this.tableViewModel.selected.removeAll();
this.tableViewModel.selected.push(newEntity);
});
});
this.close();
}
public open() {
this.displayedAttributes(this.constructDisplayedAttributes(this.originEntity));
if (userContext.apiType === "Tables") {
this.originalDocument = TableEntityProcessor.convertEntitiesToDocuments(
[<Entities.ITableEntityForTablesAPI>this.originEntity],
this.tableViewModel.queryTablesTab.collection
)[0]; // TODO change for Cassandra
this.originalDocument.id = ko.observable<string>(this.originalDocument.id);
} else {
this.originalDocument = this.originEntity;
}
this.updateIsActionEnabled();
super.open();
}
private constructDisplayedAttributes(entity: Entities.ITableEntity): EntityPropertyViewModel[] {
var displayedAttributes: EntityPropertyViewModel[] = [];
const keys = Object.keys(entity);
keys &&
keys.forEach((key: string) => {
if (
key !== TableEntityProcessor.keyProperties.attachments &&
key !== TableEntityProcessor.keyProperties.etag &&
key !== TableEntityProcessor.keyProperties.resourceId &&
key !== TableEntityProcessor.keyProperties.self &&
(userContext.apiType !== "Cassandra" || key !== TableConstants.EntityKeyNames.RowKey)
) {
if (userContext.apiType === "Cassandra") {
const cassandraKeys = this.tableViewModel.queryTablesTab.collection.cassandraKeys.partitionKeys
.concat(this.tableViewModel.queryTablesTab.collection.cassandraKeys.clusteringKeys)
.map((key) => key.property);
var entityAttribute: Entities.ITableEntityAttribute = entity[key];
var entityAttributeType: string = entityAttribute.$;
var displayValue: any = this.getPropertyDisplayValue(entity, key, entityAttributeType);
var removable: boolean = false;
// TODO figure out validation story for blob and Inet so we can allow adding/editing them
const nonEditableType: boolean =
entityAttributeType === TableConstants.CassandraType.Blob ||
entityAttributeType === TableConstants.CassandraType.Inet;
displayedAttributes.push(
new EntityPropertyViewModel(
this,
key,
entityAttributeType,
displayValue,
/* namePlaceholder */ undefined,
/* valuePlaceholder */ undefined,
false,
/* default valid name */ true,
/* default valid value */ true,
/* isRequired */ false,
removable,
/*value editable*/ !_.contains<string>(cassandraKeys, key) && !nonEditableType
)
);
} else {
var entityAttribute: Entities.ITableEntityAttribute = entity[key];
var entityAttributeType: string = entityAttribute.$;
var displayValue: any = this.getPropertyDisplayValue(entity, key, entityAttributeType);
var editable: boolean = this.isAttributeEditable(key, entityAttributeType);
// As per VSO:189935, Binary properties are read-only, we still want to be able to remove them.
var removable: boolean = editable || entityAttributeType === TableConstants.TableType.Binary;
displayedAttributes.push(
new EntityPropertyViewModel(
this,
key,
entityAttributeType,
displayValue,
/* namePlaceholder */ undefined,
/* valuePlaceholder */ undefined,
editable,
/* default valid name */ true,
/* default valid value */ true,
/* isRequired */ false,
removable
)
);
}
}
});
if (userContext.apiType === "Cassandra") {
(<CassandraAPIDataClient>this.container.tableDataClient)
.getTableSchema(this.tableViewModel.queryTablesTab.collection)
.then((properties: CassandraTableKey[]) => {
properties &&
properties.forEach((property) => {
if (!_.contains(keys, property.property)) {
this.insertAttribute(property.property, property.type);
}
});
});
}
return displayedAttributes;
}
private updateEntity(displayedAttributes: EntityPropertyViewModel[]): Entities.ITableEntity {
var updatedEntity: any = {};
displayedAttributes &&
displayedAttributes.forEach((attribute: EntityPropertyViewModel) => {
if (attribute.name() && (userContext.apiType !== "Cassandra" || attribute.value() !== "")) {
var value = attribute.getPropertyValue();
var type = attribute.type();
if (type === TableConstants.TableType.Int64) {
value = Utilities.padLongWithZeros(value);
}
updatedEntity[attribute.name()] = {
_: value,
$: type,
};
}
});
return updatedEntity;
}
private isAttributeEditable(attributeName: string, entityAttributeType: string) {
return !(
attributeName === TableConstants.EntityKeyNames.PartitionKey ||
attributeName === TableConstants.EntityKeyNames.RowKey ||
attributeName === TableConstants.EntityKeyNames.Timestamp ||
// As per VSO:189935, Making Binary properties read-only in Edit Entity dialog until we have a full story for it.
entityAttributeType === TableConstants.TableType.Binary
);
}
private getPropertyDisplayValue(entity: Entities.ITableEntity, name: string, type: string): any {
var attribute: Entities.ITableEntityAttribute = entity[name];
var displayValue: any = attribute._;
var isBinary: boolean = type === TableConstants.TableType.Binary;
// Showing the value in base64 for binary properties since that is what the Azure Storage Client Library expects.
// This means that, even if the Azure Storage API returns a byte[] of binary content, it needs that same array
// *base64 - encoded * as the value for the updated property or the whole update operation will fail.
if (isBinary && displayValue && $.isArray(displayValue.data)) {
var bytes: number[] = displayValue.data;
displayValue = this.getBase64DisplayValue(bytes);
}
return displayValue;
}
private getBase64DisplayValue(bytes: number[]): string {
var displayValue: string = null;
try {
var chars: string[] = bytes.map((byte: number) => String.fromCharCode(byte));
var toEncode: string = chars.join("");
displayValue = window.btoa(toEncode);
} catch (error) {
// Error
}
return displayValue;
}
}

View File

@@ -1,164 +0,0 @@
import * as ko from "knockout";
import * as DateTimeUtilities from "../../Tables/QueryBuilder/DateTimeUtilities";
import * as EntityPropertyNameValidator from "./Validators/EntityPropertyNameValidator";
import EntityPropertyValueValidator from "./Validators/EntityPropertyValueValidator";
import * as Constants from "../../Tables/Constants";
import * as Utilities from "../../Tables/Utilities";
import TableEntityPane from "./TableEntityPane";
export interface IValidationResult {
isInvalid: boolean;
help: string;
}
export interface IActionEnabledDialog {
updateIsActionEnabled: () => void;
}
/**
* View model for an entity proprety
*/
export default class EntityPropertyViewModel {
/* Constants */
public static noTooltip = "";
// Maximum number of custom properties, see Azure Service Data Model
// At https://msdn.microsoft.com/library/azure/dd179338.aspx
public static maximumNumberOfProperties = 252;
// Labels
public closeButtonLabel: string = "Close"; // localize
/* Observables */
public name: ko.Observable<string>;
public type: ko.Observable<string>;
public value: ko.Observable<any>;
public inputType: ko.Computed<string>;
public nameTooltip: ko.Observable<string>;
public isInvalidName: ko.Observable<boolean>;
public valueTooltip: ko.Observable<string>;
public isInvalidValue: ko.Observable<boolean>;
public namePlaceholder: ko.Observable<string>;
public valuePlaceholder: ko.Observable<string>;
public hasFocus: ko.Observable<boolean>;
public valueHasFocus: ko.Observable<boolean>;
public isDateType: ko.Computed<boolean>;
public editable: boolean; // If a property's name or type is editable, these two are always the same regarding editability.
public valueEditable: boolean; // If a property's value is editable, could be different from name or type.
public removable: boolean; // If a property is removable, usually, PartitionKey, RowKey and TimeStamp (if applicable) are not removable.
public isRequired: boolean; // If a property's value is required, used to differentiate the place holder label.
public ignoreEmptyValue: boolean;
/* Members */
private tableEntityPane: TableEntityPane;
private _validator: EntityPropertyValueValidator;
constructor(
tableEntityPane: TableEntityPane,
name: string,
type: string,
value: any,
namePlaceholder: string = "",
valuePlaceholder: string = "",
editable: boolean = false,
defaultValidName: boolean = true,
defaultValidValue: boolean = false,
isRequired: boolean = false,
removable: boolean = editable,
valueEditable: boolean = editable,
ignoreEmptyValue: boolean = false
) {
this.name = ko.observable<string>(name);
this.type = ko.observable<string>(type);
this.isDateType = ko.pureComputed<boolean>(() => this.type() === Constants.TableType.DateTime);
if (this.isDateType()) {
value = value ? DateTimeUtilities.getLocalDateTime(value) : value;
}
this.value = ko.observable(value);
this.inputType = ko.pureComputed<string>(() => {
if (!this.valueHasFocus() && !this.value() && this.isDateType()) {
return Constants.InputType.Text;
}
return Utilities.getInputTypeFromDisplayedName(this.type());
});
this.namePlaceholder = ko.observable<string>(namePlaceholder);
this.valuePlaceholder = ko.observable<string>(valuePlaceholder);
this.editable = editable;
this.isRequired = isRequired;
this.removable = removable;
this.valueEditable = valueEditable;
this._validator = new EntityPropertyValueValidator(isRequired);
this.tableEntityPane = tableEntityPane;
this.nameTooltip = ko.observable<string>(EntityPropertyViewModel.noTooltip);
this.isInvalidName = ko.observable<boolean>(!defaultValidName);
this.name.subscribe((name: string) => this.validateName(name));
if (!defaultValidName) {
this.validateName(name);
}
this.valueTooltip = ko.observable<string>(EntityPropertyViewModel.noTooltip);
this.isInvalidValue = ko.observable<boolean>(!defaultValidValue);
this.value.subscribe((value: string) => this.validateValue(value, this.type()));
if (!defaultValidValue) {
this.validateValue(value, type);
}
this.type.subscribe((type: string) => this.validateValue(this.value(), type));
this.hasFocus = ko.observable<boolean>(false);
this.valueHasFocus = ko.observable<boolean>(false);
}
/**
* Gets the Javascript value of the entity property based on its EDM type.
*/
public getPropertyValue(): any {
var value: string = this.value();
if (this.type() === Constants.TableType.DateTime) {
value = DateTimeUtilities.getUTCDateTime(value);
}
return this._validator.parseValue(value, this.type());
}
private validateName(name: string): void {
var result: IValidationResult = this.isInvalidNameInput(name);
this.isInvalidName(result.isInvalid);
this.nameTooltip(result.help);
this.namePlaceholder(result.help);
this.tableEntityPane.updateIsActionEnabled();
}
private validateValue(value: string, type: string): void {
var result: IValidationResult = this.isInvalidValueInput(value, type);
if (!result) {
return;
}
this.isInvalidValue(result.isInvalid);
this.valueTooltip(result.help);
this.valuePlaceholder(result.help);
this.tableEntityPane.updateIsActionEnabled();
}
private isInvalidNameInput(name: string): IValidationResult {
return EntityPropertyNameValidator.validate(name);
}
private isInvalidValueInput(value: string, type: string): IValidationResult {
if (this.ignoreEmptyValue && this.value() === "") {
return { isInvalid: false, help: "" };
}
return this._validator.validate(value, type);
}
}

View File

@@ -1,190 +0,0 @@
<div data-bind="visible: visible">
<div
class="contextual-pane-out"
data-bind="
click: cancel,
clickBubble: false"
></div>
<div class="contextual-pane" style="width: 700px" id="addtableentitypane">
<!-- Add table entity form - Start -->
<div
class="contextual-pane-in"
data-bind="
visible: !isEditing()"
>
<form
class="paneContentContainer"
data-bind="
submit: submit"
>
<!-- Add table entity header - Start -->
<div class="firstdivbg headerline">
<span role="heading" aria-level="2" data-bind="text: title"></span>
<div
id="closeAddEntityPane"
class="closeImg"
role="button"
aria-label="Close pane"
tabindex="0"
data-bind="
click: cancel, event: { keydown: onCloseKeyPress }"
>
<img src="../../../../images/close-black.svg" title="Close" alt="Close" />
</div>
</div>
<!-- Add table entity header - End -->
<div class="tableParamContent paneContentContainer">
<div class="entity-table">
<div class="entity-table-row">
<div class="entity-table-cell entity-table-property-header" data-bind="text: attributeNameLabel"></div>
<div class="entity-table-cell entity-table-type-header" data-bind="text: dataTypeLabel"></div>
<div class="entity-table-cell entity-table-value-header" data-bind="text: attributeValueLabel"></div>
</div>
</div>
<div class="entity-table-scroll-box" id="addEntityScroll">
<div class="entity-table" data-bind="foreach: displayedAttributes">
<div class="entity-table-row">
<div class="entity-table-cell entity-table-property-column">
<input
type="text"
class="entity-table-field entity-table-property-column"
required
data-bind="
textInput: name,
attr: { title: nameTooltip, placeholder: namePlaceholder, 'aria-label': 'property name' },
css: { 'invalid-field': isInvalidName },
readOnly: !editable,
hasFocus: hasFocus"
/>
</div>
<div class="entity-table-cell entity-table-type-column">
<select
class="entity-table-field"
data-bind="
options: $parent.edmTypes,
optionsAfterRender: $parent.setOptionDisable,
value: type,
attr: { 'aria-label': 'type' },
enable: editable,
readOnly: !editable"
></select>
</div>
<!-- ko ifnot: isDateType -->
<div class="entity-table-cell entity-table-value-column">
<input
class="entity-table-field"
id="addTableEntityValue"
step="1"
data-bind="
textInput: value,
attr: { title: valueTooltip, placeholder: valuePlaceholder, type: inputType, 'aria-label': 'value' },
css: { 'invalid-field': isInvalidValue },
readOnly: !valueEditable"
/>
</div>
<!-- /ko -->
<!-- ko if: isDateType -->
<div class="entity-table-cell entity-table-value-column">
<input
class="entity-table-field"
step="1"
data-bind="
value: value,
attr: { title: valueTooltip, placeholder: valuePlaceholder, type: inputType },
css: { 'invalid-field': isInvalidValue },
readOnly: !valueEditable,
hasFocus: valueHasFocus"
autocomplete="off"
/>
</div>
<!-- /ko -->
<div class="entity-table-cell entity-table-action-column" data-bind="if: removable || valueEditable">
<span
class="entity-Edit-Cancel"
title="Edit property"
role="button"
aria-label="Edit property"
tabindex="0"
data-bind="click: $parent.editAttribute.bind($data, $index()), visible: valueEditable, event: { keydown: $parent.onEditPropertyKeyDown.bind($data, $index()) }"
>
<img class="entity-Editor-Cancel-Img" src="/Edit_entity.svg" alt="Edit" />
</span>
<span
class="entity-Edit-Cancel"
title="Delete property"
role="button"
aria-label="Delete property"
tabindex="0"
data-bind="click: $parent.removeAttribute.bind($data, $index()), visible: removable, event: { keydown: $parent.onDeletePropertyKeyDown.bind($data, $index()) }"
>
<img class="entity-Editor-Cancel-Img" src="/delete.svg" alt="Cancel" />
</span>
</div>
</div>
</div>
<div class="entity-table addProperty">
<div class="entity-table-row">
<div class="entity-table-cell">
<span
class="commandButton"
id="addProperty"
role="button"
aria-label="Add property"
tabindex="0"
data-bind="visible: canAdd, click: insertAttribute, event: { keydown: onAddPropertyKeyDown }"
autofocus
>
<img class="addPropertyImg" src="/Add-property.svg" alt="Insert attribute" />
<span data-bind="text: addButtonLabel"> </span>
</span>
</div>
</div>
</div>
</div>
</div>
<div class="paneFooter">
<div class="leftpanel-okbut">
<input
type="submit"
class="btncreatecoll1"
data-bind="value: submitButtonText, event: { keydown: onSubmitKeyPress }"
/>
</div>
</div>
</form>
</div>
<!-- Add table entity form - End -->
<!-- Add table entity editor - Start -->
<div id="editor-panel-addEntity" data-bind="visible: isEditing()" style="display: none">
<div data-bind="with: editingProperty()">
<!-- Add table entity editor header - Start -->
<div class="firstdivbg headerline">
<span
class="backBtn"
aria-label="Back"
role="button"
tabindex="0"
data-bind="
click: $parent.finishEditingAttribute, event: { keydown: $parent.onBackButtonKeyDown }"
>
<img src="/RevertBack.svg" alt="BackIcon" />
</span>
<span class="edit-value-text" data-bind="text: name"></span>
</div>
<!-- Add table entity editor header - End -->
<div class="seconddivbg paddingspan2">
<textarea
class="entity-editor-expanded"
id="textAreaEditProperty"
tabindex="0"
rows="21"
data-bind="value: value, attr: { 'aria-label': name }"
style="width: 95%"
autofocus
></textarea>
</div>
</div>
</div>
<!-- Add table entity editor - End -->
</div>
</div>

View File

@@ -1,187 +0,0 @@
<div data-bind="visible: visible">
<div
class="contextual-pane-out"
data-bind="
click: cancel,
clickBubble: false"
></div>
<div class="contextual-pane" style="width: 700px" id="edittableentitypane">
<!-- Edit table entity form - Start -->
<div
class="contextual-pane-in"
data-bind="
visible: !isEditing()"
>
<form
class="paneContentContainer"
data-bind="
submit: submit"
>
<!-- Edit table entity header - Start -->
<div class="firstdivbg headerline">
<span role="heading" aria-level="2" data-bind="text: title"></span>
<div
class="closeImg"
role="button"
aria-label="Close pane"
tabindex="0"
data-bind="
click: cancel, event: { keydown: onCloseKeyPress }"
>
<img src="../../../../images/close-black.svg" title="Close" alt="Close" />
</div>
</div>
<!-- Edit table entity header - End -->
<div class="tableParamContent paneContentContainer">
<div class="entity-table">
<div class="entity-table-row">
<div class="entity-table-cell entity-table-property-header" data-bind="text: attributeNameLabel"></div>
<div class="entity-table-cell entity-table-type-header" data-bind="text: dataTypeLabel"></div>
<div class="entity-table-cell entity-table-value-header" data-bind="text: attributeValueLabel"></div>
</div>
</div>
<div class="entity-table-scroll-box" id="editEntityScroll">
<div class="entity-table" data-bind="foreach: displayedAttributes">
<div class="entity-table-row">
<div class="entity-table-cell entity-table-property-column">
<input
type="text"
class="entity-table-field entity-table-property-column"
required
data-bind="
textInput: name,
attr: { title: nameTooltip, placeholder: namePlaceholder, 'aria-label': 'property name' },
css: { 'invalid-field': isInvalidName },
readOnly: !editable,
hasFocus: hasFocus"
/>
</div>
<div class="entity-table-cell entity-table-type-column">
<select
class="entity-table-field"
data-bind="
options: $parent.edmTypes,
optionsAfterRender: $parent.setOptionDisable,
value: type,
attr: { 'aria-label': 'type' },
enable: editable,
readOnly: !editable"
></select>
</div>
<!-- ko ifnot: isDateType -->
<div class="entity-table-cell entity-table-value-column">
<input
class="entity-table-field"
step="1"
data-bind="
textInput: value,
attr: { title: valueTooltip, placeholder: valuePlaceholder, type: inputType, 'aria-label': 'value' },
css: { 'invalid-field': isInvalidValue },
readOnly: !valueEditable"
/>
</div>
<!-- /ko -->
<!-- ko if: isDateType -->
<div class="entity-table-cell entity-table-value-column">
<input
class="entity-table-field"
step="1"
data-bind="
value: value,
attr: { title: valueTooltip, placeholder: valuePlaceholder, type: inputType, 'aria-label': 'value' },
css: { 'invalid-field': isInvalidValue },
readOnly: !valueEditable,
hasFocus: valueHasFocus"
autocomplete="off"
/>
</div>
<!-- /ko -->
<div class="entity-table-cell entity-table-action-column" data-bind="if: removable || valueEditable">
<span
class="entity-Edit-Cancel"
role="button"
aria-label="Edit property"
tabindex="0"
data-bind="click: $parent.editAttribute.bind($data, $index()), visible: valueEditable, event: { keydown: $parent.onEditPropertyKeyDown.bind($data, $index()) }"
title="Edit property"
>
<img class="entity-Editor-Cancel-Img" src="/Edit_entity.svg" alt="Edit attribute" />
</span>
<span
class="entity-Edit-Cancel"
role="button"
aria-label="Delete property"
tabindex="0"
data-bind="click: $parent.removeAttribute.bind($data, $index()), visible: removable, event: { keydown: $parent.onDeletePropertyKeyDown.bind($data, $index()) }"
title="Delete property"
>
<img class="entity-Editor-Cancel-Img" src="/delete.svg" alt="Remove attribute" />
</span>
</div>
</div>
</div>
<div class="entity-table addProperty">
<div class="entity-table-row">
<div class="entity-table-cell">
<span
class="commandButton"
role="button"
aria-label="Add property"
tabindex="0"
data-bind="visible: canAdd, click: insertAttribute, event: { keydown: onAddPropertyKeyDown }"
autofocus
>
<img class="addPropertyImg" src="/Add-property.svg" alt="Add attribute" />
<span data-bind="text: addButtonLabel"> </span>
</span>
</div>
</div>
</div>
</div>
</div>
<div class="paneFooter">
<div class="leftpanel-okbut">
<input
type="submit"
value="Update Entity"
class="btncreatecoll1"
data-bind="value: submitButtonText, event: { keydown: onSubmitKeyPress }"
/>
</div>
</div>
</form>
</div>
<!-- Edit table entity form - End -->
<!-- Edit table entity editor - Start -->
<div id="editor-panel-editEntity" data-bind="visible: isEditing()" style="display: none">
<div data-bind="with: editingProperty()">
<!-- Edit table entity editor header - Start -->
<div class="firstdivbg headerline">
<span
class="backBtn"
aria-label="Back"
role="button"
tabindex="0"
data-bind="
click: $parent.finishEditingAttribute, event: { keydown: $parent.onBackButtonKeyDown }"
>
<img src="/RevertBack.svg" alt="BackIcon" />
</span>
<span class="edit-value-text" data-bind="text: name"></span>
</div>
<!-- Edit table entity editor header - End -->
<div class="seconddivbg paddingspan2">
<textarea
class="entity-editor-expanded"
id="editor-area"
tabindex="0"
rows="21"
data-bind="value: value, attr: { 'aria-label': name }"
autofocus
></textarea>
</div>
</div>
</div>
<!-- Edit table entity editor - End -->
</div>
</div>

View File

@@ -1,279 +0,0 @@
import * as ko from "knockout";
import _ from "underscore";
import { KeyCodes } from "../../../Common/Constants";
import * as ViewModels from "../../../Contracts/ViewModels";
import { userContext } from "../../../UserContext";
import * as TableConstants from "../../Tables/Constants";
import * as DataTableUtilities from "../../Tables/DataTable/DataTableUtilities";
import TableEntityListViewModel from "../../Tables/DataTable/TableEntityListViewModel";
import * as Entities from "../../Tables/Entities";
import * as TableEntityProcessor from "../../Tables/TableEntityProcessor";
import * as Utilities from "../../Tables/Utilities";
import { ContextualPaneBase } from "../ContextualPaneBase";
import EntityPropertyViewModel from "./EntityPropertyViewModel";
// Class with variables and functions that are common to both adding and editing entities
export default abstract class TableEntityPane extends ContextualPaneBase {
protected static requiredFieldsForTablesAPI: string[] = [
TableConstants.EntityKeyNames.PartitionKey,
TableConstants.EntityKeyNames.RowKey,
];
/* Labels */
public attributeNameLabel = "Property Name"; // localize
public dataTypeLabel = "Type"; // localize
public attributeValueLabel = "Value"; // localize
/* Controls */
public removeButtonLabel = "Remove"; // localize
public editButtonLabel = "Edit"; // localize
public addButtonLabel = "Add Property"; // localize
public edmTypes: ko.ObservableArray<string> = ko.observableArray([
TableConstants.TableType.String,
TableConstants.TableType.Boolean,
TableConstants.TableType.Binary,
TableConstants.TableType.DateTime,
TableConstants.TableType.Double,
TableConstants.TableType.Guid,
TableConstants.TableType.Int32,
TableConstants.TableType.Int64,
]);
public canAdd: ko.Computed<boolean>;
public canApply: ko.Observable<boolean>;
public displayedAttributes = ko.observableArray<EntityPropertyViewModel>();
public editingProperty = ko.observable<EntityPropertyViewModel>();
public isEditing = ko.observable<boolean>(false);
public submitButtonText = ko.observable<string>();
public tableViewModel: TableEntityListViewModel;
protected scrollId: ko.Observable<string>;
constructor(options: ViewModels.PaneOptions) {
super(options);
if (userContext.apiType === "Cassandra") {
this.edmTypes([
TableConstants.CassandraType.Text,
TableConstants.CassandraType.Ascii,
TableConstants.CassandraType.Bigint,
TableConstants.CassandraType.Blob,
TableConstants.CassandraType.Boolean,
TableConstants.CassandraType.Decimal,
TableConstants.CassandraType.Double,
TableConstants.CassandraType.Float,
TableConstants.CassandraType.Int,
TableConstants.CassandraType.Uuid,
TableConstants.CassandraType.Varchar,
TableConstants.CassandraType.Varint,
TableConstants.CassandraType.Inet,
TableConstants.CassandraType.Smallint,
TableConstants.CassandraType.Tinyint,
]);
}
this.canAdd = ko.computed<boolean>(() => {
// Cassandra can't add since the schema can't be changed once created
if (userContext.apiType === "Cassandra") {
return false;
}
// Adding '2' to the maximum to take into account PartitionKey and RowKey
return this.displayedAttributes().length < EntityPropertyViewModel.maximumNumberOfProperties + 2;
});
this.canApply = ko.observable<boolean>(true);
this.editingProperty(this.displayedAttributes()[0]);
}
public removeAttribute = (index: number, data: any): void => {
this.displayedAttributes.splice(index, 1);
this.updateIsActionEnabled();
document.getElementById("addProperty").focus();
};
public editAttribute = (index: number, data: EntityPropertyViewModel): void => {
this.editingProperty(data);
this.isEditing(true);
document.getElementById("textAreaEditProperty").focus();
};
public finishEditingAttribute = (): void => {
this.isEditing(false);
this.editingProperty(null);
};
public onKeyUp = (data: any, event: KeyboardEvent): boolean => {
var handled: boolean = Utilities.onEsc(event, ($sourceElement: JQuery) => {
this.finishEditingAttribute();
});
return !handled;
};
public onAddPropertyKeyDown = (source: any, event: KeyboardEvent): boolean => {
if (event.keyCode === KeyCodes.Enter || event.keyCode === KeyCodes.Space) {
this.insertAttribute();
event.stopPropagation();
return false;
}
return true;
};
public onEditPropertyKeyDown = (
index: number,
data: EntityPropertyViewModel,
event: KeyboardEvent,
source: any
): boolean => {
if (event.keyCode === KeyCodes.Enter || event.keyCode === KeyCodes.Space) {
this.editAttribute(index, data);
event.stopPropagation();
return false;
}
return true;
};
public onDeletePropertyKeyDown = (
index: number,
data: EntityPropertyViewModel,
event: KeyboardEvent,
source: any
): boolean => {
if (event.keyCode === KeyCodes.Enter || event.keyCode === KeyCodes.Space) {
this.removeAttribute(index, data);
event.stopPropagation();
return false;
}
return true;
};
public onBackButtonKeyDown = (source: any, event: KeyboardEvent): boolean => {
if (event.keyCode === KeyCodes.Enter || event.keyCode === KeyCodes.Space) {
this.finishEditingAttribute();
event.stopPropagation();
return false;
}
return true;
};
public insertAttribute = (name?: string, type?: string): void => {
let entityProperty: EntityPropertyViewModel;
if (!!name && !!type && userContext.apiType === "Cassandra") {
// TODO figure out validation story for blob and Inet so we can allow adding/editing them
const nonEditableType: boolean =
type === TableConstants.CassandraType.Blob || type === TableConstants.CassandraType.Inet;
entityProperty = new EntityPropertyViewModel(
this,
name,
type,
"", // default to empty string
/* namePlaceholder */ undefined,
/* valuePlaceholder */ undefined,
/* editable */ false,
/* default valid name */ false,
/* default valid value */ true,
/* isRequired */ false,
/* removable */ false,
/*value editable*/ !nonEditableType
);
} else {
entityProperty = new EntityPropertyViewModel(
this,
"",
this.edmTypes()[0], // default to the first Edm type: 'string'
"", // default to empty string
/* namePlaceholder */ undefined,
/* valuePlaceholder */ undefined,
/* editable */ true,
/* default valid name */ false,
/* default valid value */ true
);
}
this.displayedAttributes.push(entityProperty);
this.updateIsActionEnabled();
this.scrollToBottom();
entityProperty.hasFocus(true);
};
public updateIsActionEnabled(needRequiredFields: boolean = true): void {
var properties: EntityPropertyViewModel[] = this.displayedAttributes() || [];
var disable: boolean = _.some(properties, (property: EntityPropertyViewModel) => {
return property.isInvalidName() || property.isInvalidValue();
});
this.canApply(!disable);
}
protected entityFromAttributes(displayedAttributes: EntityPropertyViewModel[]): Entities.ITableEntity {
var entity: any = {};
displayedAttributes &&
displayedAttributes.forEach((attribute: EntityPropertyViewModel) => {
if (attribute.name() && (attribute.value() !== "" || attribute.isRequired)) {
var value = attribute.getPropertyValue();
var type = attribute.type();
if (type === TableConstants.TableType.Int64) {
value = Utilities.padLongWithZeros(value);
}
entity[attribute.name()] = {
_: value,
$: type,
};
}
});
return entity;
}
// Removing Binary from Add Entity dialog until we have a full story for it.
protected setOptionDisable(option: Node, value: string): void {
ko.applyBindingsToNode(option, { disable: value === TableConstants.TableType.Binary }, value);
}
/**
* Parse the updated entity to see if there are any new attributes that old headers don't have.
* In this case, add these attributes names as new headers.
* Remarks: adding new headers will automatically trigger table redraw.
*/
protected tryInsertNewHeaders(viewModel: TableEntityListViewModel, newEntity: Entities.ITableEntity): boolean {
var newHeaders: string[] = [];
const keys = Object.keys(newEntity);
keys &&
keys.forEach((key: string) => {
if (
!_.contains(viewModel.headers, key) &&
key !== TableEntityProcessor.keyProperties.attachments &&
key !== TableEntityProcessor.keyProperties.etag &&
key !== TableEntityProcessor.keyProperties.resourceId &&
key !== TableEntityProcessor.keyProperties.self &&
(userContext.apiType !== "Cassandra" || key !== TableConstants.EntityKeyNames.RowKey)
) {
newHeaders.push(key);
}
});
var newHeadersInserted: boolean = false;
if (newHeaders.length) {
if (!DataTableUtilities.checkForDefaultHeader(viewModel.headers)) {
newHeaders = viewModel.headers.concat(newHeaders);
}
viewModel.updateHeaders(newHeaders, /* notifyColumnChanges */ true, /* enablePrompt */ false);
newHeadersInserted = true;
}
return newHeadersInserted;
}
protected scrollToBottom(): void {
var scrollBox = document.getElementById(this.scrollId());
var isScrolledToBottom = scrollBox.scrollHeight - scrollBox.clientHeight <= scrollBox.scrollHeight + 1;
if (isScrolledToBottom) {
scrollBox.scrollTop = scrollBox.scrollHeight - scrollBox.clientHeight;
}
}
}

View File

@@ -51,7 +51,7 @@ class KeyValidator implements ValueValidator {
class BooleanValueValidator extends ValueValidator {
private detailedHelp = "Enter true or false."; // localize
public validate(value: string): IValidationResult {
public override validate(value: string): IValidationResult {
var success: boolean = false;
var help: string = noHelp;
@@ -66,7 +66,7 @@ class BooleanValueValidator extends ValueValidator {
return { isInvalid: !success, help: help };
}
public parseValue(value: string): boolean {
public override parseValue(value: string): boolean {
// OData seems to require lowercase boolean values, see http://www.odata.org/documentation/odata-version-2-0/overview/
return value.toString().toLowerCase() === "true";
}
@@ -75,7 +75,7 @@ class BooleanValueValidator extends ValueValidator {
class DateTimeValueValidator extends ValueValidator {
private detailedHelp = "Enter a date and time."; // localize
public validate(value: string): IValidationResult {
public override validate(value: string): IValidationResult {
var success: boolean = false;
var help: string = noHelp;
@@ -93,7 +93,7 @@ class DateTimeValueValidator extends ValueValidator {
return { isInvalid: !success, help: help };
}
public parseValue(value: string): Date {
public override parseValue(value: string): Date {
var millisecondTime = Date.parse(value);
var parsed: Date = new Date(millisecondTime);
@@ -104,7 +104,7 @@ class DateTimeValueValidator extends ValueValidator {
class DoubleValueValidator extends ValueValidator {
private detailedHelp = "Enter a 64-bit floating point value."; // localize
public validate(value: string): IValidationResult {
public override validate(value: string): IValidationResult {
var success: boolean = false;
var help: string = noHelp;
@@ -119,7 +119,7 @@ class DoubleValueValidator extends ValueValidator {
return { isInvalid: !success, help: help };
}
public parseValue(value: string): number {
public override parseValue(value: string): number {
return parseFloat(value);
}
}
@@ -127,7 +127,7 @@ class DoubleValueValidator extends ValueValidator {
class GuidValueValidator extends ValueValidator {
private detailedHelp = "Enter a 16-byte (128-bit) GUID value."; // localize
public validate(value: string): IValidationResult {
public override validate(value: string): IValidationResult {
var success: boolean = false;
var help: string = noHelp;
@@ -155,7 +155,7 @@ class IntegerValueValidator extends ValueValidator {
this.isInt64 = isInt64;
}
public validate(value: string): IValidationResult {
public override validate(value: string): IValidationResult {
var success: boolean = false;
var help: string = noHelp;
@@ -180,7 +180,7 @@ class IntegerValueValidator extends ValueValidator {
return { isInvalid: !success, help: help };
}
public parseValue(value: string): number {
public override parseValue(value: string): number {
return parseInt(value, 10);
}
}
@@ -198,7 +198,7 @@ class StringValidator extends ValueValidator {
this.isRequired = isRequired;
}
public validate(value: string): IValidationResult {
public override validate(value: string): IValidationResult {
var help: string = this.isRequired ? this.isRequiredHelp : this.detailedHelp;
if (value === null) {
return { isInvalid: false, help: help };
@@ -219,7 +219,7 @@ class StringValidator extends ValueValidator {
return { isInvalid: !success, help: help };
}
public parseValue(value: string): string {
public override parseValue(value: string): string {
return String(value); // Ensure value is converted to string.
}
}
@@ -233,12 +233,12 @@ class NotSupportedValidator extends ValueValidator {
this.type = type;
}
public validate(ignoredValue: string): IValidationResult {
public override validate(ignoredValue: string): IValidationResult {
//throw new Errors.NotSupportedError(this.getMessage());
return null;
}
public parseValue(ignoredValue: string): any {
public override parseValue(ignoredValue: string): any {
//throw new Errors.NotSupportedError(this.getMessage());
return null;
}

Some files were not shown because too many files have changed in this diff Show More