Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class UmbDashboardElement extends UmbElementMixin(LitElement) {
},
{
path: '',
pathMatch: 'full',
redirectTo: 'tab1',
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class UmbExampleModal extends UmbModalBaseElement {
},
{
path: '',
pathMatch: 'full',
redirectTo: 'modalOverview',
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ export class UmbBackofficeMainElement extends UmbLitElement {

if (newRoutes.length > 0) {
newRoutes.push({
path: '',
pathMatch: 'full',
awaitStability: true,
redirectTo: newRoutes[0].path,
path: ``,
});

newRoutes.push({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export class UmbBlockWorkspaceViewEditElement extends UmbLitElement implements U
if (!this._hasRootGroups) {
routes.push({
path: '',
pathMatch: 'full',
redirectTo: routes[0]?.path,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,14 @@
});
routes.push({
path: '',
pathMatch: 'full',
redirectTo: 'root',
guards: [() => this.#processingTabId === undefined],
});
} else {
routes.push({
path: '',
pathMatch: 'full',

Check warning on line 215 in src/Umbraco.Web.UI.Client/src/packages/content/content-type/workspace/views/design/content-type-design-editor.element.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (release/16.0)

❌ Getting worse: Complex Method

UmbContentTypeDesignEditorElement.createRoutes already has high cyclomatic complexity, and now it increases in Lines of Code from 76 to 78. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
redirectTo: routes[0]?.path,
guards: [() => this.#processingTabId === undefined],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export class UmbContentWorkspaceViewEditElement extends UmbLitElement implements
if (routes.length !== 0) {
routes.push({
path: '',
pathMatch: 'full',
redirectTo: routes[0].path,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ export interface IRedirectRoute<D = any> extends IRouteBase<D> {
// The paths the route should redirect to. Can either be relative or absolute.
redirectTo: string;

// First redirect when the routes appears stable. Delaying the redirect so other routes get the change to resolve first.
awaitStability?: boolean;

// Whether the query should be preserved when redirecting.
preserveQuery?: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,24 @@
}
}

Comment thread
iOvergaard marked this conversation as resolved.
private getRedirectDelay() {
if ('connection' in navigator) {
const connection =
navigator.connection || (navigator as any).mozConnection || (navigator as any).webkitConnection;

switch (connection.effectiveType) {
case 'slow-2g':
case '2g':
return 1200;
case '3g':
return 800;
case '4g':
return 200;
}
}
return 400;
Comment thread
iOvergaard marked this conversation as resolved.
}

/**
* Loads a new path based on the routes.
* Returns true if a navigation was made to a new page.
Expand Down Expand Up @@ -387,6 +405,14 @@
// Redirect if necessary
if (isRedirectRoute(route)) {
cleanup();
if (route.awaitStability === true) {
// await until browser is done loading, based on a guess:
const delay = this.getRedirectDelay();
await new Promise((resolve) => setTimeout(resolve, delay));
if (navigationInvalidated) {
return cancel();
}
}

Check warning on line 415 in src/Umbraco.Web.UI.Client/src/packages/core/router/router-slot/router-slot.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (release/16.0)

❌ Getting worse: Complex Method

RouterSlot.renderPath increases in cyclomatic complexity from 17 to 19, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

Check warning on line 415 in src/Umbraco.Web.UI.Client/src/packages/core/router/router-slot/router-slot.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (release/16.0)

❌ Getting worse: Bumpy Road Ahead

RouterSlot.renderPath increases from 4 to 5 logical blocks with deeply nested code, threshold is one single block per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.
handleRedirect(this, route);
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export class UmbDocumentBlueprintWorkspaceEditorElement extends UmbLitElement {
// Using first single view as the default route for now (hence the math below):
routes.push({
path: '',
pathMatch: 'full',
redirectTo: routes[variants.length * variants.length]?.path,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class UmbMediaDashboardElement extends UmbLitElement {
},
{
path: '',
pathMatch: 'full',
redirectTo: 'collection',
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export class UmbMediaWorkspaceEditorElement extends UmbLitElement {
// Using first single view as the default route for now (hence the math below):
routes.push({
path: '',
pathMatch: 'full',
redirectTo: routes[variants.length * variants.length]?.path,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class UmbMemberWorkspaceEditorElement extends UmbLitElement {
// Using first single view as the default route for now (hence the math below):
routes.push({
path: '',
pathMatch: 'full',
redirectTo: routes[options.length * options.length]?.path,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class UmbCreatedPackagesSectionViewElement extends UmbLitElement implemen

routes.push({
path: '',
pathMatch: 'full',
redirectTo: 'overview',
});
routes.push({
Expand Down
Loading