feat: Add demo experiment to help users activate (#5141)
* feat: enable posthog for dev process * feat: inject sticky in demo * feat: update url * feat: update pos * feat: add demo button * feat: add callout * feat: hide behind exp * fix: fix zoom to fit * fix: fix zoom reset when moving to new view * fix: use constant for test * feat: add tracking * feat: fix tracking * feat: fix tracking * fix canvas centering * feat: update time * feat: update bg color * feat: update copy * feat: update btm padding * feat: replace thumbnail * feat: increase height of sticky * chore: clean up props * fix: revert canvas change * chore: address feedback * chore: remove extra space * test: fix unit tests
This commit is contained in:
@@ -167,7 +167,6 @@ import type {
|
||||
jsPlumbInstance,
|
||||
} from 'jsplumb';
|
||||
import type { MessageBoxInputData } from 'element-ui/types/message-box';
|
||||
import once from 'lodash/once';
|
||||
|
||||
import {
|
||||
FIRST_ONBOARDING_PROMPT_TIMEOUT,
|
||||
@@ -186,6 +185,7 @@ import {
|
||||
WEBHOOK_NODE_TYPE,
|
||||
TRIGGER_NODE_FILTER,
|
||||
EnterpriseEditionFeature,
|
||||
POSTHOG_ASSUMPTION_TEST,
|
||||
} from '@/constants';
|
||||
import { copyPaste } from '@/mixins/copyPaste';
|
||||
import { externalHooks } from '@/mixins/externalHooks';
|
||||
@@ -373,7 +373,6 @@ export default mixins(
|
||||
// Re-center CanvasAddButton if there's no triggers
|
||||
if (containsTrigger === false)
|
||||
this.canvasStore.setRecenteredCanvasAddButtonPosition(this.getNodeViewOffsetPosition);
|
||||
else this.tryToAddWelcomeSticky();
|
||||
},
|
||||
nodeViewScale(newScale) {
|
||||
const element = this.$refs.nodeView as HTMLDivElement;
|
||||
@@ -2436,27 +2435,22 @@ export default mixins(
|
||||
this.workflowsStore.activeWorkflowExecution = null;
|
||||
|
||||
this.uiStore.stateIsDirty = false;
|
||||
this.canvasStore.setZoomLevel(1, 0);
|
||||
this.canvasStore.zoomToFit();
|
||||
this.canvasStore.setZoomLevel(1, [0, 0]);
|
||||
this.tryToAddWelcomeSticky();
|
||||
this.uiStore.nodeViewInitialized = true;
|
||||
this.historyStore.reset();
|
||||
this.workflowsStore.activeWorkflowExecution = null;
|
||||
this.stopLoading();
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
tryToAddWelcomeSticky: once(async function (this: any) {
|
||||
async tryToAddWelcomeSticky(): Promise<void> {
|
||||
const newWorkflow = this.workflowData;
|
||||
if (window.posthog?.getFeatureFlag?.('welcome-note') === 'test') {
|
||||
if (window.posthog?.getFeatureFlag?.(POSTHOG_ASSUMPTION_TEST) === 'assumption-video') {
|
||||
// For novice users (onboardingFlowEnabled == true)
|
||||
// Inject welcome sticky note and zoom to fit
|
||||
|
||||
if (newWorkflow?.onboardingFlowEnabled && !this.isReadOnly) {
|
||||
const collisionPadding = NodeViewUtils.GRID_SIZE + NodeViewUtils.NODE_SIZE;
|
||||
// Position the welcome sticky left to the added trigger node
|
||||
let position: XYPosition = [...(this.triggerNodes[0].position as XYPosition)];
|
||||
|
||||
position[0] -=
|
||||
NodeViewUtils.WELCOME_STICKY_NODE.parameters.width + NodeViewUtils.GRID_SIZE * 4;
|
||||
position = NodeViewUtils.getNewNodePosition(this.nodes, position, [
|
||||
collisionPadding,
|
||||
collisionPadding,
|
||||
]);
|
||||
const position: XYPosition = [50, 250];
|
||||
|
||||
await this.addNodes([
|
||||
{
|
||||
@@ -2470,14 +2464,16 @@ export default mixins(
|
||||
position,
|
||||
},
|
||||
]);
|
||||
this.$telemetry.track('welcome note inserted');
|
||||
setTimeout(() => {
|
||||
this.canvasStore.zoomToFit();
|
||||
this.canvasStore.canvasAddButtonPosition = [500, 350];
|
||||
this.$telemetry.track('welcome note inserted');
|
||||
}, 0);
|
||||
}
|
||||
} else {
|
||||
this.canvasStore.zoomToFit();
|
||||
}
|
||||
this.uiStore.nodeViewInitialized = true;
|
||||
this.historyStore.reset();
|
||||
this.workflowsStore.activeWorkflowExecution = null;
|
||||
this.stopLoading();
|
||||
}),
|
||||
},
|
||||
async initView(): Promise<void> {
|
||||
if (this.$route.params.action === 'workflowSave') {
|
||||
// In case the workflow got saved we do not have to run init
|
||||
|
||||
@@ -11,6 +11,17 @@
|
||||
@click:add="addWorkflow"
|
||||
@update:filters="filters = $event"
|
||||
>
|
||||
<template #callout v-if="!hasActiveWorkflows && isDemoTest">
|
||||
<n8n-callout theme="secondary" icon="graduation-cap" class="mb-xs">
|
||||
{{ $locale.baseText('workflows.viewDemoNotice') }}
|
||||
|
||||
<template #trailingContent>
|
||||
<n8n-link size="small" theme="secondary" bold underline @click="goToTemplates">
|
||||
{{ $locale.baseText('workflows.viewDemo') }}
|
||||
</n8n-link>
|
||||
</template>
|
||||
</n8n-callout>
|
||||
</template>
|
||||
<template #default="{ data }">
|
||||
<workflow-card :data="data" @click:tag="onClickTag" />
|
||||
</template>
|
||||
@@ -30,7 +41,7 @@
|
||||
{{ $locale.baseText('workflows.empty.description') }}
|
||||
</n8n-text>
|
||||
</div>
|
||||
<div class="text-center mt-2xl">
|
||||
<div :class="['text-center', 'mt-2xl', $style.actionsContainer]">
|
||||
<n8n-card
|
||||
:class="[$style.emptyStateCard, 'mr-s']"
|
||||
hoverable
|
||||
@@ -48,9 +59,16 @@
|
||||
@click="goToTemplates"
|
||||
data-test-id="new-workflow-template-card"
|
||||
>
|
||||
<n8n-icon :class="$style.emptyStateCardIcon" icon="box-open" />
|
||||
<n8n-icon
|
||||
:class="$style.emptyStateCardIcon"
|
||||
:icon="isDemoTest ? 'graduation-cap' : 'box-open'"
|
||||
/>
|
||||
<n8n-text size="large" class="mt-xs" color="text-base">
|
||||
{{ $locale.baseText('workflows.empty.browseTemplates') }}
|
||||
{{
|
||||
$locale.baseText(
|
||||
isDemoTest ? 'workflows.empty.viewDemo' : 'workflows.empty.browseTemplates',
|
||||
)
|
||||
}}
|
||||
</n8n-text>
|
||||
</n8n-card>
|
||||
</div>
|
||||
@@ -103,7 +121,7 @@ import PageViewLayout from '@/components/layouts/PageViewLayout.vue';
|
||||
import PageViewLayoutList from '@/components/layouts/PageViewLayoutList.vue';
|
||||
import WorkflowCard from '@/components/WorkflowCard.vue';
|
||||
import TemplateCard from '@/components/TemplateCard.vue';
|
||||
import { EnterpriseEditionFeature, VIEWS } from '@/constants';
|
||||
import { EnterpriseEditionFeature, POSTHOG_ASSUMPTION_TEST, VIEWS } from '@/constants';
|
||||
import { debounceHelper } from '@/mixins/debounce';
|
||||
import Vue from 'vue';
|
||||
import { ITag, IUser, IWorkflowDb } from '@/Interface';
|
||||
@@ -155,6 +173,12 @@ export default mixins(showMessage, debounceHelper).extend({
|
||||
isShareable(): boolean {
|
||||
return this.settingsStore.isEnterpriseFeatureEnabled(EnterpriseEditionFeature.Sharing);
|
||||
},
|
||||
hasActiveWorkflows(): boolean {
|
||||
return !!this.workflowsStore.activeWorkflows.length;
|
||||
},
|
||||
isDemoTest(): boolean {
|
||||
return window.posthog?.getFeatureFlag?.(POSTHOG_ASSUMPTION_TEST) === 'assumption-demo';
|
||||
},
|
||||
statusFilterOptions(): Array<{ label: string; value: string | boolean }> {
|
||||
return [
|
||||
{
|
||||
@@ -182,7 +206,14 @@ export default mixins(showMessage, debounceHelper).extend({
|
||||
});
|
||||
},
|
||||
goToTemplates() {
|
||||
this.$router.push({ name: VIEWS.TEMPLATES });
|
||||
if (this.isDemoTest) {
|
||||
this.$router.push({ name: VIEWS.COLLECTION, params: { id: '7' } });
|
||||
this.$telemetry.track('User clicked on inspect demo workflow', {
|
||||
location: this.allWorkflows.length ? 'workflows' : 'start_page',
|
||||
});
|
||||
} else {
|
||||
this.$router.push({ name: VIEWS.TEMPLATES });
|
||||
}
|
||||
},
|
||||
async initialize() {
|
||||
this.usersStore.fetchUsers(); // Can be loaded in the background, used for filtering
|
||||
@@ -236,6 +267,11 @@ export default mixins(showMessage, debounceHelper).extend({
|
||||
</script>
|
||||
|
||||
<style lang="scss" module>
|
||||
.actionsContainer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.emptyStateCard {
|
||||
width: 192px;
|
||||
text-align: center;
|
||||
|
||||
Reference in New Issue
Block a user