feat(editor): Add version controls settings (WIP) (#6036)

* feat(editor): Version control paywall (WIP)

* fix(editor): remove version control docs link

* feat(editor): Adding version control settings (WIP)

* feat(editor): Adding version control settings (WIP)

* fix(editor): use rest api root path in version control

* fix(editor): adding preferences

* fix(editor): adding preferences

* fix(editor): change store action name
This commit is contained in:
Csaba Tuncsik
2023-04-26 17:52:53 +02:00
committed by GitHub
parent f91923a04b
commit 0c9ce3a2ec
8 changed files with 358 additions and 20 deletions

View File

@@ -26,19 +26,39 @@
/>
</div>
</template>
<template #menuSuffix v-if="hasVersionUpdates">
<div :class="$style.updates" @click="openUpdatesPanel">
<div :class="$style.giftContainer">
<GiftNotificationIcon />
<template #menuSuffix>
<div v-if="hasVersionUpdates || versionControlStore.state.currentBranch">
<div v-if="hasVersionUpdates" :class="$style.updates" @click="openUpdatesPanel">
<div :class="$style.giftContainer">
<GiftNotificationIcon />
</div>
<n8n-text
:class="{ ['ml-xs']: true, [$style.expanded]: fullyExpanded }"
color="text-base"
>
{{ nextVersions.length > 99 ? '99+' : nextVersions.length }} update{{
nextVersions.length > 1 ? 's' : ''
}}
</n8n-text>
</div>
<div :class="$style.sync" v-if="versionControlStore.state.currentBranch">
<span>
<n8n-icon icon="code-branch" class="mr-xs" />
{{ currentBranch }}
</span>
<n8n-button
:title="
$locale.baseText('settings.versionControl.sync.prompt.title', {
interpolate: { branch: currentBranch },
})
"
icon="sync"
type="tertiary"
:size="isCollapsed ? 'mini' : 'small'"
square
@click="sync"
/>
</div>
<n8n-text
:class="{ ['ml-xs']: true, [$style.expanded]: fullyExpanded }"
color="text-base"
>
{{ nextVersions.length > 99 ? '99+' : nextVersions.length }} update{{
nextVersions.length > 1 ? 's' : ''
}}
</n8n-text>
</div>
</template>
<template #footer v-if="showUserArea">
@@ -114,6 +134,7 @@ import { useWorkflowsStore } from '@/stores/workflows';
import { useRootStore } from '@/stores/n8nRootStore';
import { useVersionsStore } from '@/stores/versions';
import { isNavigationFailure } from 'vue-router';
import { useVersionControlStore } from '@/stores/versionControl';
export default mixins(
genericHelpers,
@@ -143,7 +164,11 @@ export default mixins(
useUsersStore,
useVersionsStore,
useWorkflowsStore,
useVersionControlStore,
),
currentBranch(): string {
return this.versionControlStore.state.currentBranch;
},
hasVersionUpdates(): boolean {
return this.versionsStore.hasVersionUpdates;
},
@@ -458,6 +483,29 @@ export default mixins(
});
}
},
async sync() {
const prompt = await this.$prompt(
this.$locale.baseText('settings.versionControl.sync.prompt.description', {
interpolate: { branch: this.versionControlStore.state.currentBranch },
}),
this.$locale.baseText('settings.versionControl.sync.prompt.title', {
interpolate: { branch: this.versionControlStore.state.currentBranch },
}),
{
confirmButtonText: 'Sync',
cancelButtonText: 'Cancel',
inputPlaceholder: this.$locale.baseText(
'settings.versionControl.sync.prompt.placeholder',
),
inputPattern: /^.+$/,
inputErrorMessage: this.$locale.baseText('settings.versionControl.sync.prompt.error'),
},
);
if (prompt.value) {
this.versionControlStore.sync({ commitMessage: prompt.value });
}
},
},
});
</script>
@@ -596,4 +644,27 @@ export default mixins(
display: none;
}
}
.sync {
display: flex;
align-items: center;
justify-content: space-between;
padding: var(--spacing-s) var(--spacing-s) var(--spacing-s) var(--spacing-l);
margin: 0 calc(var(--spacing-l) * -1) calc(var(--spacing-m) * -1);
background: var(--color-background-light);
border-top: 1px solid var(--color-foreground-light);
font-size: var(--font-size-2xs);
span {
color: var(--color-text-light);
}
.sideMenuCollapsed & {
justify-content: center;
margin-left: calc(var(--spacing-xl) * -1);
> span {
display: none;
}
}
}
</style>