diff --git a/src/i18n/cn.js b/src/i18n/cn.js index 92aa5af4..ca9dc609 100644 --- a/src/i18n/cn.js +++ b/src/i18n/cn.js @@ -166,7 +166,8 @@ export default { config: '配置管理', plugin: '插件', system: '系统设置', - trigger: '触发器' + trigger: '触发器', + git: 'Git 设置', }, common: { diff --git a/src/i18n/en.js b/src/i18n/en.js index 8b606e9a..8ef902a9 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -167,6 +167,7 @@ export default { config: 'Configs', plugin: 'Plugins', system: 'System', + git: 'Git', trigger: 'Triggers' }, diff --git a/src/router/index.js b/src/router/index.js index 63030d03..ec5c4661 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -40,6 +40,10 @@ import SettingsTriggerHome from '@/view/Settings/Trigger/Index' import SettingsTriggerNew from '@/view/Settings/Trigger/New' import SettingsTriggerEdit from '@/view/Settings/Trigger/Edit' +import SettingsGitHome from '@/view/Settings/Git/Index' +import SettingsGitNew from '@/view/Settings/Git/New' +import SettingsGitEdit from '@/view/Settings/Git/Edit' + import SettingsSystemHome from '@/view/Settings/System/Index' Vue.use(Router) @@ -215,6 +219,24 @@ export default new Router({ props: true }, + // git settings + { + path: 'git', + name: 'SettingsGitHome', + component: SettingsGitHome + }, + { + path: 'git/new', + name: 'SettingsGitNew', + component: SettingsGitNew + }, + { + path: 'git/edit', + name: 'SettingsGitEdit', + component: SettingsGitEdit, + props: true + }, + // system settings { path: 'system', diff --git a/src/store/actions.js b/src/store/actions.js index 597be591..321f943d 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -156,5 +156,11 @@ export default { settings: { get: 'settings/get', save: 'settings/save' + }, + + git: { + list: 'git/list', + save: 'git/save', + delete: 'git/delete' } } diff --git a/src/store/index.js b/src/store/index.js index 19f7d4a1..f82dbe76 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -18,6 +18,7 @@ import { Store as ConfigStore } from './module/configs' import { Store as TtyStore } from './module/tty' import { Store as SettingStore } from './module/settings' import { Store as TriggerStore } from './module/triggers' +import { Store as GitStore } from './module/git' Vue.use(Vuex) @@ -39,7 +40,8 @@ const store = new Vuex.Store({ 'configs': ConfigStore, 'tty': TtyStore, 'settings': SettingStore, - 'triggers': TriggerStore + 'triggers': TriggerStore, + 'git': GitStore } }) diff --git a/src/store/module/git.js b/src/store/module/git.js new file mode 100644 index 00000000..a701101a --- /dev/null +++ b/src/store/module/git.js @@ -0,0 +1,52 @@ +import http from '../http' + +const state = { + items: [], + loaded: {} +} + +const mutations = { + list(state, items) { + state.items = items + }, + + add(state, git) { + state.items.push(git) + }, + + delete(state, source) { + for (let i = 0; i < state.items.length; i++) { + if (state.items[i].source === source) { + state.items.splice(i, 1) + return + } + } + } +} + +const actions = { + async list({commit}) { + await http.get(`gitconfig`, (items) => { + commit('list', items) + }) + }, + + async save({commit}, payload) { + await http.post(`gitconfig`, (item) => { + commit('add', item) + }, payload) + }, + + async delete({commit}, source) { + await http.delete(`gitconfig/${source}`, () => { + commit('delete', source) + }) + } +} + +export const Store = { + namespaced: true, + state, + mutations, + actions +} \ No newline at end of file diff --git a/src/util/git.js b/src/util/git.js new file mode 100644 index 00000000..34201d8e --- /dev/null +++ b/src/util/git.js @@ -0,0 +1,36 @@ +export const GIT_SOURCE_GITLAB = "GITLAB" +export const GIT_SOURCE_GITHUB = "GITHUB" +export const GIT_SOURCE_GOGS = "GOGS" +export const GIT_SOURCE_GITEE = "GITEE" +export const GIT_SOURCE_GERRIT = "GERRIT" + +export const GitSourceSelection = [ + {name: 'GitHub', value: GIT_SOURCE_GITHUB, icon: 'mdi-github'}, + {name: 'GitLab', value: GIT_SOURCE_GITLAB, icon: 'mdi-gitlab'}, + {name: 'Gogs', value: GIT_SOURCE_GOGS, icon: 'mdi-git'}, + {name: 'Gitee', value: GIT_SOURCE_GITEE, icon: 'mdi-git'}, + {name: 'Gerrit', value: GIT_SOURCE_GERRIT, icon: 'mdi-git'} +] + +export const GitSources = { + [GIT_SOURCE_GITHUB]: { + name: 'GitHub', + icon: 'mdi-github' + }, + [GIT_SOURCE_GITLAB]: { + name: 'GitLab', + icon: 'mdi-gitlab' + }, + [GIT_SOURCE_GOGS]: { + name: 'Gogs', + icon: 'mdi-git' + }, + [GIT_SOURCE_GITEE]: { + name: 'Gitee', + icon: 'mdi-git' + }, + [GIT_SOURCE_GERRIT]: { + name: 'Gerrit', + icon: 'mdi-git' + } +} \ No newline at end of file diff --git a/src/view/Settings/Config/Index.vue b/src/view/Settings/Config/Index.vue index 7897a8d9..a6ed86a6 100644 --- a/src/view/Settings/Config/Index.vue +++ b/src/view/Settings/Config/Index.vue @@ -12,8 +12,8 @@ {{ getCategoryData(item.category).icon }} {{ getCategoryData(item.category).name }} - {{ timeFormatInMins(item.createdAt) }} - {{ item.createdBy }} + {{ timeFormatInMins(item.updatedAt) }} + {{ item.updatedBy }} mdi-pencil @@ -47,8 +47,8 @@ headers: [ {text: 'Name', value: 'name', align: 'left'}, {text: 'Category', value: 'category'}, - {text: 'Created At', value: 'createdAt'}, - {text: 'Created By', value: 'createdBy'}, + {text: 'Updated At', value: 'updatedAt'}, + {text: 'Updated By', value: 'updatedBy'}, {text: '', align: 'right'} ] } diff --git a/src/view/Settings/Config/New.vue b/src/view/Settings/Config/New.vue index 69c5e553..e5234ab0 100644 --- a/src/view/Settings/Config/New.vue +++ b/src/view/Settings/Config/New.vue @@ -109,7 +109,7 @@ }, methods: { onBackClick() { - this.$router.push('/settings/configs') + this.$router.replace('/settings/configs') }, onSaveClick() { diff --git a/src/view/Settings/FunList.vue b/src/view/Settings/FunList.vue index 2838abd3..85fa64ec 100644 --- a/src/view/Settings/FunList.vue +++ b/src/view/Settings/FunList.vue @@ -62,6 +62,11 @@ path: 'triggers', icon: 'mdi-bell-outline' }, + { + i18n: 'settings.li.git', + path: 'git', + icon: 'mdi-git' + }, { i18n: 'settings.li.system', path: 'system', diff --git a/src/view/Settings/Git/Edit.vue b/src/view/Settings/Git/Edit.vue new file mode 100644 index 00000000..4414ce52 --- /dev/null +++ b/src/view/Settings/Git/Edit.vue @@ -0,0 +1,136 @@ + + + + + \ No newline at end of file diff --git a/src/view/Settings/Git/Index.vue b/src/view/Settings/Git/Index.vue new file mode 100644 index 00000000..03fb5b2f --- /dev/null +++ b/src/view/Settings/Git/Index.vue @@ -0,0 +1,85 @@ + + + + + \ No newline at end of file diff --git a/src/view/Settings/Git/New.vue b/src/view/Settings/Git/New.vue new file mode 100644 index 00000000..766573e5 --- /dev/null +++ b/src/view/Settings/Git/New.vue @@ -0,0 +1,109 @@ + + + + + \ No newline at end of file diff --git a/src/view/Settings/Home.vue b/src/view/Settings/Home.vue index 7436019e..c3e0d21a 100644 --- a/src/view/Settings/Home.vue +++ b/src/view/Settings/Home.vue @@ -20,7 +20,7 @@ mdi-plus-box @@ -59,6 +59,13 @@ onConfigNav (val) { this.navs = val.navs this.showAddBtn = val.showAddBtn + }, + + onAddBtnClick() { + const func = this.$refs.childView.onAddBtnClick + if (func) { + func() + } } } }