Skip to content

Commit

Permalink
Fixed multiple integration issues. (#608)
Browse files Browse the repository at this point in the history
* Fixed unsaved changes route guard. Fixed type definition rendering issue.
* Fixed issue with updating route hash.
* Fixed issue with autoselecting first subscription key when opening Test console.
* Fixed issues with search queries.
  • Loading branch information
azaslonov authored May 12, 2020
1 parent a1096f6 commit c8c067d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 60 deletions.
40 changes: 20 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@
"webpack-merge": "^4.2.2"
},
"dependencies": {
"@paperbits/azure": "0.1.277",
"@paperbits/common": "0.1.277",
"@paperbits/core": "0.1.277",
"@paperbits/prosemirror": "0.1.277",
"@paperbits/styles": "0.1.277",
"@paperbits/azure": "0.1.278",
"@paperbits/common": "0.1.278",
"@paperbits/core": "0.1.278",
"@paperbits/prosemirror": "0.1.278",
"@paperbits/styles": "0.1.278",
"@webcomponents/custom-elements": "1.3.2",
"@webcomponents/shadydom": "^1.7.2",
"adal-vanilla": "^1.0.18",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class OperationConsole {
await this.resetConsole();

this.requestHostname.subscribe(this.setHostname);
this.selectedSubscriptionKey.subscribe(this.applySubscriptionKey);
this.selectedSubscriptionKey.subscribe(this.applySubscriptionKey.bind(this));
this.api.subscribe(this.resetConsole);
this.operation.subscribe(this.resetConsole);
this.selectedLanguage.subscribe(this.updateRequestSummary);
Expand Down Expand Up @@ -241,6 +241,7 @@ export class OperationConsole {
if (availableProducts.length > 0) {
const subscriptionKey = availableProducts[0].subscriptionKeys[0].value;
this.selectedSubscriptionKey(subscriptionKey);
this.applySubscriptionKey(subscriptionKey);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export class OperationDetails {

constructor(
private readonly apiService: ApiService,
private readonly tenantService: TenantService,
private readonly router: Router,
private readonly routeHelper: RouteHelper
) {
Expand Down Expand Up @@ -184,8 +183,11 @@ export class OperationDetails {
}

private lookupReferences(definitions: TypeDefinition[], skipNames: string[]): string[] {
const objectDefinitions: TypeDefinitionProperty[] = definitions.map(r => r.properties).flat();
const result = [];
const objectDefinitions: TypeDefinitionProperty[] = definitions
.map(definition => definition.properties)
.filter(definition => !!definition)
.flat();

objectDefinitions.forEach(definition => {
if (definition.kind === "indexed") {
Expand Down Expand Up @@ -259,17 +261,6 @@ export class OperationDetails {
return this.routeHelper.getDefinitionAnchor(apiName, operationName, definition.name);
}

private async getProxyHostnames(): Promise<string[]> {
const apiName = this.routeHelper.getApiName();

if (!apiName) {
return [];
}

const apiDefinition: SwaggerObject = await this.apiService.exportApi(`apis/${apiName}`, "swagger");
return [apiDefinition.host];
}

@OnDestroyed()
public dispose(): void {
this.router.removeRouteChangeListener(this.onRouteChange);
Expand Down
6 changes: 4 additions & 2 deletions src/models/typeDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,10 @@ export class TypeDefinitionObjectProperty extends TypeDefinitionProperty {
if (propertySchemaObject.enum) {
props.push(new TypeDefinitionEnumerationProperty(propertyName, propertySchemaObject, isRequired));
}

props.push(new TypeDefinitionPrimitiveProperty(propertyName, propertySchemaObject, isRequired));
else {
props.push(new TypeDefinitionPrimitiveProperty(propertyName, propertySchemaObject, isRequired));
}

break;

case "object":
Expand Down
16 changes: 0 additions & 16 deletions src/routing/routeHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ export class RouteHelper {
path = detailsPageUrl;
}

if (currentPath.endsWith("/")) {
path = Utils.ensureTrailingSlash(path);
}

return `${path}#api=${apiName}`;
}

Expand All @@ -79,10 +75,6 @@ export class RouteHelper {
path = detailsPageUrl;
}

if (currentPath.endsWith("/")) {
path = Utils.ensureTrailingSlash(path);
}

return `${path}#api=${apiName}&operation=${operationName}`;
}

Expand Down Expand Up @@ -147,10 +139,6 @@ export class RouteHelper {
path = detailsPageUrl;
}

if (currentPath.endsWith("/")) {
path = Utils.ensureTrailingSlash(path);
}

return `${path}#product=${productName}`;
}

Expand All @@ -175,10 +163,6 @@ export class RouteHelper {
path = Constants.pageUrlSignUpOAuth;
}

if (currentPath.endsWith("/")) {
path = Utils.ensureTrailingSlash(path);
}

return `${path}#provider=${provider}&token=${idToken}`;
}

Expand Down
9 changes: 6 additions & 3 deletions src/routing/unsavedChangesRouteGuard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ export class UnsavedChangesRouteGuard implements RouteGuard {

public canActivate(route: Route): Promise<boolean> {
return new Promise<boolean>(async (resolve) => {
if (!this.offlineObjectStorage.hasUnsavedChanges()) {
const hasUnsavedChanges = await this.offlineObjectStorage.hasUnsavedChanges();

if (!hasUnsavedChanges) {
resolve(true);
}

const path = route.path;

const pathNotChanged = route.previous && route.previous.path === path;

if (pathNotChanged) {
Expand All @@ -28,7 +29,9 @@ export class UnsavedChangesRouteGuard implements RouteGuard {
resolve(true);
}

if (this.offlineObjectStorage.hasUnsavedChangesAt(page.contentKey)) {
const hasUnsavedChanges = await this.offlineObjectStorage.hasUnsavedChangesAt(page.contentKey);

if (hasUnsavedChanges) {
const toast = this.viewManager.addToast("Unsaved changes", `You have unsaved changes. Do you want to save or discard them?`, [
{
title: "Save",
Expand Down

0 comments on commit c8c067d

Please sign in to comment.