Skip to content

Commit

Permalink
fix(editor): Show nice error when environment is not set up (#7778)
Browse files Browse the repository at this point in the history
Adds a nicer error message with a link for owners who press Push to Git
without having a repository connected yet.
  • Loading branch information
flipswitchingmonkey authored Nov 23, 2023
1 parent 67a8891 commit 5835e05
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ export const sourceControlLicensedAndEnabledMiddleware: RequestHandler = (req, r
if (sourceControlPreferencesService.isSourceControlLicensedAndEnabled()) {
next();
} else {
res.status(401).json({ status: 'error', message: 'Unauthorized' });
if (!sourceControlPreferencesService.isSourceControlConnected()) {
res.status(412).json({
status: 'error',
message: 'source_control_not_connected',
});
} else {
res.status(401).json({ status: 'error', message: 'Unauthorized' });
}
}
};

Expand Down
13 changes: 12 additions & 1 deletion packages/editor-ui/src/components/MainHeader/WorkflowDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,18 @@ export default defineComponent({
data: { eventBus: this.eventBus, status },
});
} catch (error) {
this.showError(error, this.$locale.baseText('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();
}
Expand Down
2 changes: 2 additions & 0 deletions packages/editor-ui/src/plugins/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 5835e05

Please sign in to comment.