Skip to content

Commit

Permalink
Providing class name to routing if we don't want to use the first cla…
Browse files Browse the repository at this point in the history
…ss in file (#1297)
  • Loading branch information
dafo authored Aug 6, 2024
1 parent b16ea93 commit 2b90add
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/core/typescript/TypeScriptFileUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ export class TypeScriptFileUpdate {
lazyload = false,
routesPath = "",
root = false,
isDefault = false
isDefault = false,
className?: string
) {
this.addRouteModuleEntry(filePath, linkPath, linkText, routesVariable,
parentRoutePath, lazyload, routesPath, root, isDefault);
parentRoutePath, lazyload, routesPath, root, isDefault, className);
}

/**
Expand All @@ -113,8 +114,8 @@ export class TypeScriptFileUpdate {
linkPath: string,
linkText: string,
routesVariable = DEFAULT_ROUTES_VARIABLE,
lazyload = false, routesPath = "", root = false, isDefault = false) {
this.addRouteModuleEntry(filePath, linkPath, linkText, routesVariable, null, lazyload, routesPath, root, isDefault);
lazyload = false, routesPath = "", root = false, isDefault = false, className?: string,) {
this.addRouteModuleEntry(filePath, linkPath, linkText, routesVariable, null, lazyload, routesPath, root, isDefault, className);
}

/**
Expand Down Expand Up @@ -308,12 +309,13 @@ export class TypeScriptFileUpdate {
lazyload = false,
routesPath = "",
root = false,
isDefault = false
isDefault = false,
providedClassName?: string
) {
let className: string;
const fileSource = TsUtils.getFileSource(filePath);
const relativePath: string = Util.relativePath(this.targetPath, filePath, true, true);
className = TsUtils.getClassName(fileSource.getChildren());
// TODO: Remove once the logic is updated to use the actual class name from the generated .json file
const className = providedClassName || TsUtils.getClassName(fileSource.getChildren());

if (!lazyload) {
this.requestImport([className], relativePath);
Expand Down

0 comments on commit 2b90add

Please sign in to comment.