-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(editor): Add version controls settings (WIP) #6036
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a2244f8
feat(editor): Version control paywall (WIP)
cstuncsik 2a0d4ca
fix(editor): remove version control docs link
cstuncsik 98576f3
Merge remote-tracking branch 'origin/pay-363-add-paywall-state' into …
cstuncsik f98366a
feat(editor): Adding version control settings (WIP)
cstuncsik edabd72
Merge remote-tracking branch 'origin/master' into pay-408-add-version…
cstuncsik 3076db4
feat(editor): Adding version control settings (WIP)
cstuncsik 22afdec
Merge remote-tracking branch 'origin/master' into pay-408-add-version…
cstuncsik da0c34a
Merge remote-tracking branch 'origin/master' into pay-408-add-version…
cstuncsik f914b73
fix(editor): use rest api root path in version control
cstuncsik eef9983
fix(editor): adding preferences
cstuncsik 43a6aba
fix(editor): adding preferences
cstuncsik cfac669
fix(editor): change store action name
cstuncsik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { IRestApiContext, VersionControlPreferences } from '@/Interface'; | ||
import { makeRestApiRequest } from '@/utils'; | ||
import type { IDataObject } from 'n8n-workflow'; | ||
|
||
const versionControlApiRoot = '/version-control'; | ||
|
||
export const initSsh = (context: IRestApiContext, data: IDataObject): Promise<string> => { | ||
return makeRestApiRequest(context, 'POST', `${versionControlApiRoot}/init-ssh`, data); | ||
}; | ||
|
||
export const initRepository = ( | ||
context: IRestApiContext, | ||
): Promise<{ branches: string[]; currentBranch: string }> => { | ||
return makeRestApiRequest(context, 'POST', `${versionControlApiRoot}/init-repository`); | ||
}; | ||
|
||
export const sync = (context: IRestApiContext, data: IDataObject): Promise<void> => { | ||
return makeRestApiRequest(context, 'POST', `${versionControlApiRoot}/push`, data); | ||
}; | ||
|
||
export const getConfig = ( | ||
context: IRestApiContext, | ||
): Promise<{ remoteRepository: string; name: string; email: string; currentBranch: string }> => { | ||
return makeRestApiRequest(context, 'GET', `${versionControlApiRoot}/config`); | ||
}; | ||
|
||
export const setPreferences = ( | ||
context: IRestApiContext, | ||
preferences: Partial<VersionControlPreferences>, | ||
): Promise<VersionControlPreferences> => { | ||
return makeRestApiRequest(context, 'POST', `${versionControlApiRoot}/preferences`, preferences); | ||
}; | ||
|
||
export const getPreferences = (context: IRestApiContext): Promise<VersionControlPreferences> => { | ||
return makeRestApiRequest(context, 'GET', `${versionControlApiRoot}/preferences`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1296,6 +1296,24 @@ | |
"settings.versionControl.actionBox.title": "Available on Enterprise plan", | ||
"settings.versionControl.actionBox.description": "Use Version Control to connect your instance to an external Git repository to backup and track changes made to your workflows, variables, and credentials. With Version Control you can also sync instances across multiple environments (development, production...).", | ||
"settings.versionControl.actionBox.buttonText": "See plans", | ||
"settings.versionControl.description": "Versioning allows you to connect your n8n instance to a Git branch of a repository. You can connect your branches to multiples n8n instances to create a multi environments setup. Learn how to set up versioning and environments in n8n.", | ||
"settings.versionControl.repoUrl": "Git repository URL", | ||
"settings.versionControl.repoUrlPlaceholder": "e.g. [email protected]:my-team/my-repository", | ||
"settings.versionControl.repoUrlDescription": "The SSH url of your Git repository", | ||
"settings.versionControl.authorName": "Author name", | ||
"settings.versionControl.authorEmail": "Author email", | ||
"settings.versionControl.sshKey": "SSH Key", | ||
"settings.versionControl.sshKeyDescription": "Paste the SSH key in yout git repository settings. {link}.", | ||
"settings.versionControl.sshKeyDescriptionLink": "More info.", | ||
"settings.versionControl.button.continue": "Continue", | ||
"settings.versionControl.button.connect": "Connect", | ||
"settings.versionControl.branches": "Select branch", | ||
"settings.versionControl.switchBranch.title": "Switch to {branch} branch", | ||
"settings.versionControl.switchBranch.description": "Please confirm you want to switch the current n8n instance to the branch: {branch}", | ||
"settings.versionControl.sync.prompt.title": "Sync changes in {branch} branch", | ||
"settings.versionControl.sync.prompt.description": "All the changes on your n8n instances will be synced with branch {branch} on the remote git repository. The following git sequence will be executed: pull > commit > push.", | ||
"settings.versionControl.sync.prompt.placeholder": "Commit message", | ||
"settings.versionControl.sync.prompt.error": "Please enter a commit message", | ||
"showMessage.cancel": "@:_reusableBaseText.cancel", | ||
"showMessage.ok": "OK", | ||
"showMessage.showDetails": "Show Details", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,88 @@ | ||
import { computed } from 'vue'; | ||
import { computed, reactive } from 'vue'; | ||
import { defineStore } from 'pinia'; | ||
import type { IDataObject } from 'n8n-workflow'; | ||
import { EnterpriseEditionFeature } from '@/constants'; | ||
import { useSettingsStore } from '@/stores/settings'; | ||
import * as vcApi from '@/api/versionControl'; | ||
import { useRootStore } from '@/stores/n8nRootStore'; | ||
import type { VersionControlPreferences } from '@/Interface'; | ||
|
||
export const useVersionControlStore = defineStore('versionControl', () => { | ||
const rootStore = useRootStore(); | ||
const settingsStore = useSettingsStore(); | ||
|
||
const isEnterpriseVersionControlEnabled = computed(() => | ||
settingsStore.isEnterpriseFeatureEnabled(EnterpriseEditionFeature.VersionControl), | ||
); | ||
|
||
const preferences = reactive<VersionControlPreferences>({ | ||
branchName: '', | ||
authorName: '', | ||
authorEmail: '', | ||
repositoryUrl: '', | ||
branchReadOnly: false, | ||
branchColor: '#000000', | ||
connected: false, | ||
publicKey: '', | ||
}); | ||
|
||
const state = reactive({ | ||
branches: [] as string[], | ||
currentBranch: '', | ||
authorName: '', | ||
authorEmail: '', | ||
repositoryUrl: '', | ||
sshKey: '', | ||
commitMessage: 'commit message', | ||
}); | ||
|
||
const initSsh = async (data: IDataObject) => { | ||
state.sshKey = await vcApi.initSsh(rootStore.getRestApiContext, data); | ||
}; | ||
|
||
const initRepository = async () => { | ||
const { branches, currentBranch } = await vcApi.initRepository(rootStore.getRestApiContext); | ||
state.branches = branches; | ||
state.currentBranch = currentBranch; | ||
}; | ||
|
||
const sync = async (data: { commitMessage: string }) => { | ||
state.commitMessage = data.commitMessage; | ||
return vcApi.sync(rootStore.getRestApiContext, { message: data.commitMessage }); | ||
}; | ||
const getConfig = async () => { | ||
const { remoteRepository, name, email, currentBranch } = await vcApi.getConfig( | ||
rootStore.getRestApiContext, | ||
); | ||
state.repositoryUrl = remoteRepository; | ||
state.authorName = name; | ||
state.authorEmail = email; | ||
state.currentBranch = currentBranch; | ||
}; | ||
|
||
const setPreferences = (data: Partial<VersionControlPreferences>) => { | ||
Object.assign(preferences, data); | ||
}; | ||
|
||
const getPreferences = async () => { | ||
const data = await vcApi.getPreferences(rootStore.getRestApiContext); | ||
setPreferences(data); | ||
}; | ||
|
||
const savePreferences = async (preferences: Partial<VersionControlPreferences>) => { | ||
const data = await vcApi.setPreferences(rootStore.getRestApiContext, preferences); | ||
setPreferences(data); | ||
}; | ||
|
||
return { | ||
isEnterpriseVersionControlEnabled, | ||
state, | ||
initSsh, | ||
initRepository, | ||
sync, | ||
getConfig, | ||
getPreferences, | ||
setPreferences, | ||
savePreferences, | ||
}; | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these endpoints are still based on the mvp i think, which is not current any more.... (we can leave them in, but they won't work....)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I know, I just kept them to not to break the build and satisfy the type checker. I'll remove them in the upcoming chages.