Remove Explorer.isRefreshing (#539)

This commit is contained in:
Steve Faulkner 2021-03-19 12:13:52 -05:00 committed by GitHub
parent e97a1643fb
commit ee8d2070bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 22 additions and 71 deletions

View File

@ -327,7 +327,6 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
? this.saveCollectionSettings(startKey) ? this.saveCollectionSettings(startKey)
: this.saveDatabaseSettings(startKey)); : this.saveDatabaseSettings(startKey));
} catch (error) { } catch (error) {
this.container.isRefreshingExplorer(false);
this.props.settingsTab.isExecutionError(true); this.props.settingsTab.isExecutionError(true);
console.error(error); console.error(error);
traceFailure( traceFailure(
@ -701,7 +700,6 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
} }
} }
this.container.isRefreshingExplorer(false);
this.setBaseline(); this.setBaseline();
this.setState({ wasAutopilotOriginallySet: this.state.isAutoPilotSelected }); this.setState({ wasAutopilotOriginallySet: this.state.isAutoPilotSelected });
traceSuccess( traceSuccess(
@ -864,7 +862,6 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
}); });
} }
} }
this.container.isRefreshingExplorer(false);
this.setBaseline(); this.setBaseline();
this.setState({ wasAutopilotOriginallySet: this.state.isAutoPilotSelected }); this.setState({ wasAutopilotOriginallySet: this.state.isAutoPilotSelected });
traceSuccess( traceSuccess(

View File

@ -936,7 +936,6 @@ exports[`SettingsComponent renders 1`] = `
"isPreferredApiMongoDB": [Function], "isPreferredApiMongoDB": [Function],
"isPreferredApiTable": [Function], "isPreferredApiTable": [Function],
"isPublishNotebookPaneEnabled": [Function], "isPublishNotebookPaneEnabled": [Function],
"isRefreshingExplorer": [Function],
"isResourceTokenCollectionNodeSelected": [Function], "isResourceTokenCollectionNodeSelected": [Function],
"isRightPanelV2Enabled": [Function], "isRightPanelV2Enabled": [Function],
"isSchemaEnabled": [Function], "isSchemaEnabled": [Function],
@ -2134,7 +2133,6 @@ exports[`SettingsComponent renders 1`] = `
"isPreferredApiMongoDB": [Function], "isPreferredApiMongoDB": [Function],
"isPreferredApiTable": [Function], "isPreferredApiTable": [Function],
"isPublishNotebookPaneEnabled": [Function], "isPublishNotebookPaneEnabled": [Function],
"isRefreshingExplorer": [Function],
"isResourceTokenCollectionNodeSelected": [Function], "isResourceTokenCollectionNodeSelected": [Function],
"isRightPanelV2Enabled": [Function], "isRightPanelV2Enabled": [Function],
"isSchemaEnabled": [Function], "isSchemaEnabled": [Function],
@ -3345,7 +3343,6 @@ exports[`SettingsComponent renders 1`] = `
"isPreferredApiMongoDB": [Function], "isPreferredApiMongoDB": [Function],
"isPreferredApiTable": [Function], "isPreferredApiTable": [Function],
"isPublishNotebookPaneEnabled": [Function], "isPublishNotebookPaneEnabled": [Function],
"isRefreshingExplorer": [Function],
"isResourceTokenCollectionNodeSelected": [Function], "isResourceTokenCollectionNodeSelected": [Function],
"isRightPanelV2Enabled": [Function], "isRightPanelV2Enabled": [Function],
"isSchemaEnabled": [Function], "isSchemaEnabled": [Function],
@ -4543,7 +4540,6 @@ exports[`SettingsComponent renders 1`] = `
"isPreferredApiMongoDB": [Function], "isPreferredApiMongoDB": [Function],
"isPreferredApiTable": [Function], "isPreferredApiTable": [Function],
"isPublishNotebookPaneEnabled": [Function], "isPublishNotebookPaneEnabled": [Function],
"isRefreshingExplorer": [Function],
"isResourceTokenCollectionNodeSelected": [Function], "isResourceTokenCollectionNodeSelected": [Function],
"isRightPanelV2Enabled": [Function], "isRightPanelV2Enabled": [Function],
"isSchemaEnabled": [Function], "isSchemaEnabled": [Function],

View File

@ -185,11 +185,6 @@ export default class Explorer {
public selectedCollectionId: ko.Computed<string>; public selectedCollectionId: ko.Computed<string>;
public isLeftPaneExpanded: ko.Observable<boolean>; public isLeftPaneExpanded: ko.Observable<boolean>;
public selectedNode: ko.Observable<ViewModels.TreeNode>; public selectedNode: ko.Observable<ViewModels.TreeNode>;
/**
* @deprecated
* Use a local loading state and spinner instead. Using a global isRefreshing state causes problems.
* */
public isRefreshingExplorer: ko.Observable<boolean>;
private resourceTree: ResourceTreeAdapter; private resourceTree: ResourceTreeAdapter;
// Resource Token // Resource Token
@ -299,22 +294,6 @@ export default class Explorer {
this.databaseAccount = ko.observable<DataModels.DatabaseAccount>(); this.databaseAccount = ko.observable<DataModels.DatabaseAccount>();
this.subscriptionType = ko.observable<SubscriptionType>(SharedConstants.CollectionCreation.DefaultSubscriptionType); this.subscriptionType = ko.observable<SubscriptionType>(SharedConstants.CollectionCreation.DefaultSubscriptionType);
let firstInitialization = true;
this.isRefreshingExplorer = ko.observable<boolean>(true);
this.isRefreshingExplorer.subscribe((isRefreshing: boolean) => {
if (!isRefreshing && firstInitialization) {
// set focus on first element
firstInitialization = false;
try {
document.getElementById("createNewContainerCommandButton").parentElement.parentElement.focus();
} catch (e) {
Logger.logWarning(
"getElementById('createNewContainerCommandButton') failed to find element",
"Explorer/this.isRefreshingExplorer.subscribe"
);
}
}
});
this.isAccountReady = ko.observable<boolean>(false); this.isAccountReady = ko.observable<boolean>(false);
this._isInitializingNotebooks = false; this._isInitializingNotebooks = false;
this.arcadiaToken = ko.observable<string>(); this.arcadiaToken = ko.observable<string>();
@ -1083,7 +1062,6 @@ export default class Explorer {
} }
public refreshAllDatabases(isInitialLoad?: boolean): Q.Promise<any> { public refreshAllDatabases(isInitialLoad?: boolean): Q.Promise<any> {
this.isRefreshingExplorer(true);
const startKey: number = TelemetryProcessor.traceStart(Action.LoadDatabases, { const startKey: number = TelemetryProcessor.traceStart(Action.LoadDatabases, {
dataExplorerArea: Constants.Areas.ResourceTree, dataExplorerArea: Constants.Areas.ResourceTree,
}); });
@ -1113,8 +1091,7 @@ export default class Explorer {
this.deleteDatabasesFromList(deltaDatabases.toDelete); this.deleteDatabasesFromList(deltaDatabases.toDelete);
this.selectedNode(currentlySelectedNode); this.selectedNode(currentlySelectedNode);
this._setLoadingStatusText("Fetching containers..."); this._setLoadingStatusText("Fetching containers...");
this.refreshAndExpandNewDatabases(deltaDatabases.toAdd) this.refreshAndExpandNewDatabases(deltaDatabases.toAdd).then(
.then(
() => { () => {
this._setLoadingStatusText("Successfully fetched containers."); this._setLoadingStatusText("Successfully fetched containers.");
deferred.resolve(); deferred.resolve();
@ -1123,12 +1100,10 @@ export default class Explorer {
this._setLoadingStatusText("Failed to fetch containers."); this._setLoadingStatusText("Failed to fetch containers.");
deferred.reject(reason); deferred.reject(reason);
} }
) );
.finally(() => this.isRefreshingExplorer(false));
}, },
(error) => { (error) => {
this._setLoadingStatusText("Failed to fetch databases."); this._setLoadingStatusText("Failed to fetch databases.");
this.isRefreshingExplorer(false);
deferred.reject(error); deferred.reject(error);
const errorMessage = getErrorMessage(error); const errorMessage = getErrorMessage(error);
TelemetryProcessor.traceFailure( TelemetryProcessor.traceFailure(
@ -1188,7 +1163,6 @@ export default class Explorer {
description: "Refresh button clicked", description: "Refresh button clicked",
dataExplorerArea: Constants.Areas.ResourceTree, dataExplorerArea: Constants.Areas.ResourceTree,
}); });
this.isRefreshingExplorer(true);
userContext.authType === AuthType.ResourceToken userContext.authType === AuthType.ResourceToken
? this.refreshDatabaseForResourceToken() ? this.refreshDatabaseForResourceToken()
: this.refreshAllDatabases(); : this.refreshAllDatabases();

View File

@ -401,7 +401,6 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
this._setBaseline(); this._setBaseline();
this._wasAutopilotOriginallySet(this.isAutoPilotSelected()); this._wasAutopilotOriginallySet(this.isAutoPilotSelected());
} catch (error) { } catch (error) {
this.container.isRefreshingExplorer(false);
this.isExecutionError(true); this.isExecutionError(true);
console.error(error); console.error(error);
const errorMessage = getErrorMessage(error); const errorMessage = getErrorMessage(error);

View File

@ -4,18 +4,24 @@ import * as _ from "underscore";
import UploadWorker from "worker-loader!../../workers/upload"; import UploadWorker from "worker-loader!../../workers/upload";
import { AuthType } from "../../AuthType"; import { AuthType } from "../../AuthType";
import * as Constants from "../../Common/Constants"; import * as Constants from "../../Common/Constants";
import { createDocument } from "../../Common/dataAccess/createDocument";
import { getCollectionUsageSizeInKB } from "../../Common/dataAccess/getCollectionDataUsageSize";
import { readCollectionOffer } from "../../Common/dataAccess/readCollectionOffer";
import { readStoredProcedures } from "../../Common/dataAccess/readStoredProcedures"; import { readStoredProcedures } from "../../Common/dataAccess/readStoredProcedures";
import { readTriggers } from "../../Common/dataAccess/readTriggers"; import { readTriggers } from "../../Common/dataAccess/readTriggers";
import { readUserDefinedFunctions } from "../../Common/dataAccess/readUserDefinedFunctions"; import { readUserDefinedFunctions } from "../../Common/dataAccess/readUserDefinedFunctions";
import { readCollectionOffer } from "../../Common/dataAccess/readCollectionOffer"; import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils";
import { getCollectionUsageSizeInKB } from "../../Common/dataAccess/getCollectionDataUsageSize";
import * as Logger from "../../Common/Logger"; import * as Logger from "../../Common/Logger";
import { fetchPortalNotifications } from "../../Common/PortalNotifications";
import { configContext, Platform } from "../../ConfigContext";
import * as DataModels from "../../Contracts/DataModels"; import * as DataModels from "../../Contracts/DataModels";
import * as ViewModels from "../../Contracts/ViewModels"; import * as ViewModels from "../../Contracts/ViewModels";
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants"; import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import { userContext } from "../../UserContext";
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
import { StartUploadMessageParams, UploadDetails, UploadDetailsRecord } from "../../workers/upload/definitions"; import { StartUploadMessageParams, UploadDetails, UploadDetailsRecord } from "../../workers/upload/definitions";
import Explorer from "../Explorer";
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
import { CassandraAPIDataClient, CassandraTableKey, CassandraTableKeys } from "../Tables/TableDataClient"; import { CassandraAPIDataClient, CassandraTableKey, CassandraTableKeys } from "../Tables/TableDataClient";
import ConflictsTab from "../Tabs/ConflictsTab"; import ConflictsTab from "../Tabs/ConflictsTab";
@ -32,12 +38,6 @@ import DocumentId from "./DocumentId";
import StoredProcedure from "./StoredProcedure"; import StoredProcedure from "./StoredProcedure";
import Trigger from "./Trigger"; import Trigger from "./Trigger";
import UserDefinedFunction from "./UserDefinedFunction"; import UserDefinedFunction from "./UserDefinedFunction";
import { configContext, Platform } from "../../ConfigContext";
import Explorer from "../Explorer";
import { userContext } from "../../UserContext";
import { fetchPortalNotifications } from "../../Common/PortalNotifications";
import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils";
import { createDocument } from "../../Common/dataAccess/createDocument";
export default class Collection implements ViewModels.Collection { export default class Collection implements ViewModels.Collection {
public nodeKind: string; public nodeKind: string;
@ -1200,7 +1200,6 @@ export default class Collection implements ViewModels.Collection {
public async loadOffer(): Promise<void> { public async loadOffer(): Promise<void> {
if (!this.container.isServerlessEnabled() && !this.offer()) { if (!this.container.isServerlessEnabled() && !this.offer()) {
this.container.isRefreshingExplorer(true);
const startKey: number = TelemetryProcessor.traceStart(Action.LoadOffers, { const startKey: number = TelemetryProcessor.traceStart(Action.LoadOffers, {
databaseName: this.databaseId, databaseName: this.databaseId,
collectionName: this.id(), collectionName: this.id(),
@ -1237,8 +1236,6 @@ export default class Collection implements ViewModels.Collection {
startKey startKey
); );
throw error; throw error;
} finally {
this.container.isRefreshingExplorer(false);
} }
} }
} }

View File

@ -211,10 +211,7 @@ const App: React.FunctionComponent = () => {
{/* Splitter - End */} {/* Splitter - End */}
</div> </div>
{/* Collections Tree - End */} {/* Collections Tree - End */}
<div <div className="connectExplorerContainer" data-bind="tabsManager.openedTabs().length === 0">
className="connectExplorerContainer"
data-bind="visible: !isRefreshingExplorer() && tabsManager.openedTabs().length === 0"
>
<form className="connectExplorerFormContainer"> <form className="connectExplorerFormContainer">
<SplashScreen explorer={explorer} /> <SplashScreen explorer={explorer} />
</form> </form>

View File

@ -1,9 +1,8 @@
import crossroads from "crossroads";
import hasher from "hasher";
import * as _ from "underscore"; import * as _ from "underscore";
import * as Constants from "../Common/Constants"; import * as Constants from "../Common/Constants";
import * as ViewModels from "../Contracts/ViewModels"; import * as ViewModels from "../Contracts/ViewModels";
import crossroads from "crossroads";
import hasher from "hasher";
import ScriptTabBase from "../Explorer/Tabs/ScriptTabBase"; import ScriptTabBase from "../Explorer/Tabs/ScriptTabBase";
import TabsBase from "../Explorer/Tabs/TabsBase"; import TabsBase from "../Explorer/Tabs/TabsBase";
@ -398,14 +397,7 @@ export class TabRouteHandler {
private _executeActionHelper(action: () => void): void { private _executeActionHelper(action: () => void): void {
const explorer = window.dataExplorer; const explorer = window.dataExplorer;
if (!!explorer && (explorer.isRefreshingExplorer() || !explorer.isAccountReady())) { if (explorer && explorer.isAccountReady()) {
const refreshSubscription = explorer.isRefreshingExplorer.subscribe((isRefreshing: boolean) => {
if (!isRefreshing) {
action();
refreshSubscription.dispose();
}
});
} else {
action(); action();
} }
} }

View File

@ -160,7 +160,6 @@ function configureHostedWithResourceToken(config: ResourceToken, explorerParams:
databaseAccount, databaseAccount,
features: extractFeatures(), features: extractFeatures(),
}); });
explorer.isRefreshingExplorer(false);
return explorer; return explorer;
} }