fix(editor): Show nice error when environment is not set up (#7778)

Adds a nicer error message with a link for owners who press Push to Git
without having a repository connected yet.
This commit is contained in:
Michael Auerswald 2023-11-23 13:50:03 +01:00 committed by GitHub
parent 67a88914f2
commit 5835e055d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View file

@ -7,9 +7,16 @@ export const sourceControlLicensedAndEnabledMiddleware: RequestHandler = (req, r
const sourceControlPreferencesService = Container.get(SourceControlPreferencesService);
if (sourceControlPreferencesService.isSourceControlLicensedAndEnabled()) {
next();
} else {
if (!sourceControlPreferencesService.isSourceControlConnected()) {
res.status(412).json({
status: 'error',
message: 'source_control_not_connected',
});
} else {
res.status(401).json({ status: 'error', message: 'Unauthorized' });
}
}
};
export const sourceControlLicensedMiddleware: RequestHandler = (req, res, next) => {

View file

@ -593,7 +593,18 @@ export default defineComponent({
data: { eventBus: this.eventBus, status },
});
} catch (error) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
switch (error.message) {
case 'source_control_not_connected':
this.showError(
{ ...error, message: '' },
this.$locale.baseText('settings.sourceControl.error.not.connected.title'),
this.$locale.baseText('settings.sourceControl.error.not.connected.message'),
);
break;
default:
this.showError(error, this.$locale.baseText('error'));
}
} finally {
this.stopLoading();
}

View file

@ -1654,6 +1654,8 @@
"settings.sourceControl.docs.setup.ssh.url": "https://docs.n8n.io/source-control-environments/setup/#step-3-set-up-a-deploy-key",
"settings.sourceControl.docs.using.url": "https://docs.n8n.io/source-control-environments/using/",
"settings.sourceControl.docs.using.pushPull.url": "https://docs.n8n.io/source-control-environments/using/push-pull",
"settings.sourceControl.error.not.connected.title": "Environments have not been enabled",
"settings.sourceControl.error.not.connected.message": "Please head over to <a href='/settings/environments'>environment settings</a> to connect a git repository first to activate this functionality.",
"showMessage.cancel": "@:_reusableBaseText.cancel",
"settings.auditLogs.title": "Audit Logs",
"settings.auditLogs.actionBox.title": "Available on the Enterprise plan",