mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 03:12:15 +00:00
fix(editor): Open Community+ enrollment modal only for the instance owner (#11292)
This commit is contained in:
@@ -93,6 +93,7 @@ import { useExternalHooks } from '@/composables/useExternalHooks';
|
||||
import { useI18n } from '@/composables/useI18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { getResourcePermissions } from '@/permissions';
|
||||
|
||||
const SURVEY_VERSION = 'v4';
|
||||
|
||||
@@ -110,7 +111,9 @@ const uiStore = useUIStore();
|
||||
|
||||
const formValues = ref<Record<string, string>>({});
|
||||
const isSaving = ref(false);
|
||||
|
||||
const userPermissions = computed(() =>
|
||||
getResourcePermissions(usersStore.currentUser?.globalScopes),
|
||||
);
|
||||
const survey = computed<IFormInputs>(() => [
|
||||
{
|
||||
name: COMPANY_TYPE_KEY,
|
||||
@@ -548,23 +551,30 @@ const onSave = () => {
|
||||
formBus.emit('submit');
|
||||
};
|
||||
|
||||
const closeCallback = () => {
|
||||
const isPartOfOnboardingExperiment =
|
||||
posthogStore.getVariant(MORE_ONBOARDING_OPTIONS_EXPERIMENT.name) ===
|
||||
MORE_ONBOARDING_OPTIONS_EXPERIMENT.control;
|
||||
// In case the redirect to homepage for new users didn't happen
|
||||
// we try again after closing the modal
|
||||
if (route.name !== VIEWS.HOMEPAGE && !isPartOfOnboardingExperiment) {
|
||||
void router.replace({ name: VIEWS.HOMEPAGE });
|
||||
}
|
||||
};
|
||||
|
||||
const closeDialog = () => {
|
||||
modalBus.emit('close');
|
||||
uiStore.openModalWithData({
|
||||
name: COMMUNITY_PLUS_ENROLLMENT_MODAL,
|
||||
data: {
|
||||
closeCallback: () => {
|
||||
const isPartOfOnboardingExperiment =
|
||||
posthogStore.getVariant(MORE_ONBOARDING_OPTIONS_EXPERIMENT.name) ===
|
||||
MORE_ONBOARDING_OPTIONS_EXPERIMENT.control;
|
||||
// In case the redirect to homepage for new users didn't happen
|
||||
// we try again after closing the modal
|
||||
if (route.name !== VIEWS.HOMEPAGE && !isPartOfOnboardingExperiment) {
|
||||
void router.replace({ name: VIEWS.HOMEPAGE });
|
||||
}
|
||||
|
||||
if (userPermissions.value.community.register) {
|
||||
uiStore.openModalWithData({
|
||||
name: COMMUNITY_PLUS_ENROLLMENT_MODAL,
|
||||
data: {
|
||||
closeCallback,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
} else {
|
||||
closeCallback();
|
||||
}
|
||||
};
|
||||
|
||||
const onSubmit = async (values: IPersonalizationLatestVersion) => {
|
||||
|
||||
Reference in New Issue
Block a user