feat: Change desktop UM experience (#5312)

* refactor: Hide prompt for desktop

* feat: add email field to personalization modal

* fix: update survey interfaces

* chore: enable personalization survey email key display condition

* feat: add users page upsell for desktop client

* feat: disable UM on desktop where possible

* refactor: Have a single function to decide whether UM is enabled

* feat: update community nodes upsell link

---------

Co-authored-by: Alex Grozav <alex@grozav.com>
Co-authored-by: krynble <omar@n8n.io>
Co-authored-by: freyamade <freya@n8n.io>
This commit is contained in:
Omar Ajoue
2023-02-08 10:42:22 +01:00
committed by GitHub
parent d8865aa917
commit 5e3e70b83b
19 changed files with 177 additions and 64 deletions

View File

@@ -571,6 +571,7 @@ export interface IN8nUISettings {
}
export interface IPersonalizationSurveyAnswers {
email: string | null;
codingSkill: string | null;
companyIndustry: string[];
companySize: string | null;

View File

@@ -303,7 +303,8 @@ class Server extends AbstractServer {
showSetupOnFirstLoad:
config.getEnv('userManagement.disabled') === false &&
config.getEnv('userManagement.isInstanceOwnerSetUp') === false &&
config.getEnv('userManagement.skipInstanceOwnerSetup') === false,
config.getEnv('userManagement.skipInstanceOwnerSetup') === false &&
config.getEnv('deployment.type').startsWith('desktop_') === false,
});
// refresh enterprise status

View File

@@ -37,10 +37,20 @@ export function isEmailSetUp(): boolean {
}
export function isUserManagementEnabled(): boolean {
return (
!config.getEnv('userManagement.disabled') ||
config.getEnv('userManagement.isInstanceOwnerSetUp')
);
// This can be simplified but readability is more important here
if (config.getEnv('userManagement.isInstanceOwnerSetUp')) {
// Short circuit - if owner is set up, UM cannot be disabled.
// Users must reset their instance in order to do so.
return true;
}
// UM is disabled for desktop by default
if (config.getEnv('deployment.type').startsWith('desktop_')) {
return false;
}
return config.getEnv('userManagement.disabled') ? false : true;
}
export function isSharingEnabled(): boolean {
@@ -51,13 +61,6 @@ export function isSharingEnabled(): boolean {
);
}
export function isUserManagementDisabled(): boolean {
return (
config.getEnv('userManagement.disabled') &&
!config.getEnv('userManagement.isInstanceOwnerSetUp')
);
}
export async function getRoleId(scope: Role['scope'], name: Role['name']): Promise<Role['id']> {
return Db.collections.Role.findOneOrFail({
select: ['id'],

View File

@@ -13,7 +13,7 @@ import {
getInstanceBaseUrl,
hashPassword,
isEmailSetUp,
isUserManagementDisabled,
isUserManagementEnabled,
sanitizeUser,
validatePassword,
} from '@/UserManagement/UserManagementHelper';
@@ -94,7 +94,7 @@ export class UsersController {
@Post('/')
async sendEmailInvites(req: UserRequest.Invite) {
// TODO: this should be checked in the middleware rather than here
if (isUserManagementDisabled()) {
if (!isUserManagementEnabled()) {
this.logger.debug(
'Request to send email invite(s) to user(s) failed because user management is disabled',
);

View File

@@ -13,7 +13,7 @@ import {
isAuthenticatedRequest,
isAuthExcluded,
isPostUsersId,
isUserManagementDisabled,
isUserManagementEnabled,
} from '@/UserManagement/UserManagementHelper';
import type { Repository } from 'typeorm';
import type { User } from '@db/entities/User';
@@ -101,7 +101,7 @@ export const setupAuthMiddlewares = (
}
// skip authentication if user management is disabled
if (isUserManagementDisabled()) {
if (!isUserManagementEnabled()) {
req.user = await userRepository.findOneOrFail({
relations: ['globalRole'],
where: {},