Cleanup Synapse+Spark Logic (#813)

This commit is contained in:
Steve Faulkner
2021-05-25 14:46:52 -05:00
committed by GitHub
parent 522fdc69ab
commit e7e15c54b3
22 changed files with 46 additions and 6746 deletions

View File

@@ -1,7 +1,6 @@
import { stringifyNotebook, toJS } from "@nteract/commutable";
import * as ko from "knockout";
import * as Q from "q";
import * as _ from "underscore";
import ClearAllOutputsIcon from "../../../images/notebook/Notebook-clear-all-outputs.svg";
import CopyIcon from "../../../images/notebook/Notebook-copy.svg";
import CutIcon from "../../../images/notebook/Notebook-cut.svg";
@@ -12,14 +11,9 @@ import RunAllIcon from "../../../images/notebook/Notebook-run-all.svg";
import RunIcon from "../../../images/notebook/Notebook-run.svg";
import { default as InterruptKernelIcon, default as KillKernelIcon } from "../../../images/notebook/Notebook-stop.svg";
import SaveIcon from "../../../images/save-cosmos.svg";
import { ArmApiVersions } from "../../Common/Constants";
import { configContext } from "../../ConfigContext";
import * as DataModels from "../../Contracts/DataModels";
import { useNotebookSnapshotStore } from "../../hooks/useNotebookSnapshotStore";
import { trackEvent } from "../../Shared/appInsights";
import { Action, ActionModifiers, Source } from "../../Shared/Telemetry/TelemetryConstants";
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import { userContext } from "../../UserContext";
import * as NotebookConfigurationUtils from "../../Utils/NotebookConfigurationUtils";
import { logConsoleInfo } from "../../Utils/NotificationConsoleUtils";
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
@@ -38,7 +32,6 @@ export interface NotebookTabOptions extends NotebookTabBaseOptions {
export default class NotebookTabV2 extends NotebookTabBase {
public readonly html = '<div data-bind="react:notebookComponentAdapter" style="height: 100%"></div>';
public notebookPath: ko.Observable<string>;
private selectedSparkPool: ko.Observable<string>;
private notebookComponentAdapter: NotebookComponentAdapter;
constructor(options: NotebookTabOptions) {
@@ -53,16 +46,6 @@ export default class NotebookTabV2 extends NotebookTabBase {
notebookClient: NotebookTabBase.clientManager,
onUpdateKernelInfo: this.onKernelUpdate,
});
this.selectedSparkPool = ko.observable<string>(null);
this.container &&
this.container.arcadiaToken.subscribe(async () => {
const currentKernel = this.notebookComponentAdapter.getCurrentKernelName();
if (!currentKernel) {
return;
}
await this.configureServiceEndpoints(currentKernel);
});
}
public onCloseTabButtonClick(): Q.Promise<any> {
@@ -361,32 +344,6 @@ export default class NotebookTabV2 extends NotebookTabBase {
},
// TODO: Uncomment when undo/redo is reimplemented in nteract
];
if (this.container.hasStorageAnalyticsAfecFeature()) {
const arcadiaWorkspaceDropdown: CommandButtonComponentProps = {
iconSrc: null,
iconAlt: workspaceLabel,
ariaLabel: workspaceLabel,
onCommandClick: () => {},
commandButtonLabel: null,
hasPopup: false,
disabled: this.container.arcadiaWorkspaces.length < 1,
isDropdown: false,
isArcadiaPicker: true,
arcadiaProps: {
selectedSparkPool: this.selectedSparkPool(),
workspaces: this.container.arcadiaWorkspaces(),
onSparkPoolSelect: this.onSparkPoolSelect,
onCreateNewWorkspaceClicked: () => {
this.container.createWorkspace();
},
onCreateNewSparkPoolClicked: (workspaceResourceId: string) => {
this.container.createSparkPool(workspaceResourceId);
},
},
};
buttons.splice(1, 0, arcadiaWorkspaceDropdown);
}
return buttons;
}
@@ -394,50 +351,6 @@ export default class NotebookTabV2 extends NotebookTabBase {
this.updateNavbarWithTabsButtons();
}
private onSparkPoolSelect = (evt: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>, item: any) => {
if (!item || !item.text) {
this.selectedSparkPool(null);
return;
}
trackEvent(
{ name: "SparkPoolSelected" },
{
subscriptionId: userContext.subscriptionId,
accountName: userContext.databaseAccount?.name,
accountId: userContext.databaseAccount?.id,
}
);
this.container &&
this.container.arcadiaWorkspaces &&
this.container.arcadiaWorkspaces() &&
this.container.arcadiaWorkspaces().forEach(async (workspace) => {
if (workspace && workspace.name && workspace.sparkPools) {
const selectedPoolIndex = _.findIndex(workspace.sparkPools, (pool) => pool && pool.name === item.text);
if (selectedPoolIndex >= 0) {
const selectedPool = workspace.sparkPools[selectedPoolIndex];
if (selectedPool && selectedPool.name) {
this.container.sparkClusterConnectionInfo({
userName: undefined,
password: undefined,
endpoints: [
{
endpoint: `https://${workspace.name}.${configContext.ARCADIA_LIVY_ENDPOINT_DNS_ZONE}/livyApi/versions/${ArmApiVersions.arcadiaLivy}/sparkPools/${selectedPool.name}/`,
kind: DataModels.SparkClusterEndpointKind.Livy,
},
],
});
this.selectedSparkPool(item.text);
await this.reconfigureServiceEndpoints();
this.container.sparkClusterConnectionInfo.valueHasMutated();
return;
}
}
}
});
};
private onKernelUpdate = async () => {
await this.configureServiceEndpoints(this.notebookComponentAdapter.getCurrentKernelName()).catch((reason) => {
/* Erroring is ok here */