Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/i18n/cn.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ export default {
config: '配置管理',
plugin: '插件',
system: '系统设置',
trigger: '触发器'
trigger: '触发器',
git: 'Git 设置',
},

common: {
Expand Down
1 change: 1 addition & 0 deletions src/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export default {
config: 'Configs',
plugin: 'Plugins',
system: 'System',
git: 'Git',
trigger: 'Triggers'
},

Expand Down
22 changes: 22 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,11 @@ export default {
settings: {
get: 'settings/get',
save: 'settings/save'
},

git: {
list: 'git/list',
save: 'git/save',
delete: 'git/delete'
}
}
4 changes: 3 additions & 1 deletion src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -39,7 +40,8 @@ const store = new Vuex.Store({
'configs': ConfigStore,
'tty': TtyStore,
'settings': SettingStore,
'triggers': TriggerStore
'triggers': TriggerStore,
'git': GitStore
}
})

Expand Down
52 changes: 52 additions & 0 deletions src/store/module/git.js
Original file line number Diff line number Diff line change
@@ -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
}
36 changes: 36 additions & 0 deletions src/util/git.js
Original file line number Diff line number Diff line change
@@ -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'
}
}
8 changes: 4 additions & 4 deletions src/view/Settings/Config/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<v-icon small class="mr-2">{{ getCategoryData(item.category).icon }}</v-icon>
<span class="caption">{{ getCategoryData(item.category).name }}</span>
</td>
<td>{{ timeFormatInMins(item.createdAt) }}</td>
<td>{{ item.createdBy }}</td>
<td>{{ timeFormatInMins(item.updatedAt) }}</td>
<td>{{ item.updatedBy }}</td>
<td>
<v-btn icon class="ma-0" @click="onEditClick(item)">
<v-icon small>mdi-pencil</v-icon>
Expand Down Expand Up @@ -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'}
]
}
Expand Down
2 changes: 1 addition & 1 deletion src/view/Settings/Config/New.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
},
methods: {
onBackClick() {
this.$router.push('/settings/configs')
this.$router.replace('/settings/configs')
},

onSaveClick() {
Expand Down
5 changes: 5 additions & 0 deletions src/view/Settings/FunList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
136 changes: 136 additions & 0 deletions src/view/Settings/Git/Edit.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<template>
<div>
<v-row>
<v-col cols="7">
<text-select :items="gitSourceList"
label="Git Source"
v-model="gitObj.source"
:onChange="onGitSourceChange"
></text-select>
</v-col>
</v-row>

<v-row>
<v-col cols="7">
<text-select :items="secretNameList"
label="Secret"
v-model="gitObj.secret"
></text-select>
</v-col>
</v-row>

<v-row no-gutters dense v-if="error">
<v-col cols="9">
<span class="error--text">Error: {{ error }}</span>
</v-col>
</v-row>

<v-row>
<v-col cols="7" class="text-end">
<back-btn :on-click="onBackClick" class="mr-5"></back-btn>
<confirm-btn :text="$t('delete')"
icon="mdi-delete"
color="error"
clazz="mr-5"
@click="onDeleteClick">
<template v-slot:title>
<span class="red--text subheading">
Revoke git setting for {{ gitObj.source }}?
</span>
</template>
</confirm-btn>
<save-btn :on-click="onSaveClick"></save-btn>
</v-col>
</v-row>
</div>
</template>

<script>
import SaveBtn from '@/components/Settings/SaveBtn'
import BackBtn from '@/components/Settings/BackBtn'
import ConfirmBtn from '@/components/Common/ConfirmBtn'
import TextSelect from '@/components/Common/TextSelect'
import {GIT_SOURCE_GITHUB, GitSourceSelection} from "@/util/git";
import {mapState} from "vuex";
import actions from "@/store/actions";
import {CATEGORY_TOKEN} from "@/util/secrets";

export default {
name: "SettingsGitEdit",
props: {
gitObj: {
type: Object,
required: true,
}
},
components: {
ConfirmBtn,
SaveBtn,
BackBtn,
TextSelect
},
data() {
return {
gitSourceList: GitSourceSelection,
error: null
}
},
mounted() {
this.loadRelatedSecret()
},
computed: {
...mapState({
secrets: state => state.secrets.items
}),

secretNameList() {
const nameList = []
for (let c of this.secrets) {
nameList.push(c.name)
}
return nameList
}
},
methods: {
onGitSourceChange() {

},

onBackClick() {
this.error = null
this.$router.replace('/settings/git')
},

onDeleteClick() {
this.$store.dispatch(actions.git.delete, this.gitObj.source)
.then(() => {
this.showSnackBar(`Git setting for ${this.gitObj.source} has been deleted`)
this.onBackClick()
})
.catch(e => {
this.error = e.message
})
},

onSaveClick() {
this.$store.dispatch(actions.git.save, this.gitObj)
.then(() => {
this.onBackClick()
})
.catch(e => {
this.error = e.message
})
},

loadRelatedSecret() {
if (this.gitObj.source === GIT_SOURCE_GITHUB) {
this.$store.dispatch(actions.secrets.listNameOnly, CATEGORY_TOKEN).then()
}
}
}
}
</script>

<style scoped>

</style>
Loading