Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Fix frontend.settings external hook execution #7496

Merged
Merged
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
18 changes: 13 additions & 5 deletions packages/cli/src/services/frontend.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ import {
getWorkflowHistoryPruneTime,
} from '@/workflows/workflowHistory/workflowHistoryHelper.ee';
import { UserManagementMailer } from '@/UserManagement/email';
import type { CommunityPackagesService } from '@/services/communityPackages.service';

@Service()
export class FrontendService {
settings: IN8nUISettings;

private communityPackagesService?: CommunityPackagesService;

constructor(
private readonly loadNodesAndCredentials: LoadNodesAndCredentials,
private readonly credentialTypes: CredentialTypes,
Expand All @@ -44,6 +47,13 @@ export class FrontendService {
private readonly instanceSettings: InstanceSettings,
) {
this.initSettings();

if (config.getEnv('nodes.communityPackages.enabled')) {
// eslint-disable-next-line @typescript-eslint/naming-convention
void import('@/services/communityPackages.service').then(({ CommunityPackagesService }) => {
this.communityPackagesService = Container.get(CommunityPackagesService);
});
}
}

private initSettings() {
Expand Down Expand Up @@ -198,7 +208,7 @@ export class FrontendService {
this.writeStaticJSON('credentials', credentials);
}

async getSettings(): Promise<IN8nUISettings> {
getSettings(): IN8nUISettings {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we are at it, I think we should add some simple unit tests to cover this case.

Copy link
Contributor Author

@RicardoE105 RicardoE105 Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do after all the metings 💀

const restEndpoint = config.getEnv('endpoints.rest');

// Update all urls, in case `WEBHOOK_URL` was updated by `--tunnel`
Expand Down Expand Up @@ -275,10 +285,8 @@ export class FrontendService {
});
}

if (config.getEnv('nodes.communityPackages.enabled')) {
// eslint-disable-next-line @typescript-eslint/naming-convention
const { CommunityPackagesService } = await import('@/services/communityPackages.service');
netroy marked this conversation as resolved.
Show resolved Hide resolved
this.settings.missingPackages = Container.get(CommunityPackagesService).hasMissingPackages;
if (this.communityPackagesService) {
this.settings.missingPackages = this.communityPackagesService.hasMissingPackages;
}

this.settings.mfa.enabled = config.get('mfa.enabled');
Expand Down
Loading