2017-12-10 23:49:20 +00:00
|
|
|
<template>
|
|
|
|
<div class="side-bar__panel side-bar__panel--menu">
|
2019-06-29 16:33:21 +00:00
|
|
|
<menu-entry @click.native="manageWorkspaces">
|
|
|
|
<icon-database slot="icon"></icon-database>
|
2022-05-26 23:55:37 +00:00
|
|
|
<div><div class="menu-entry__label menu-entry__label--count">{{workspaceCount}}</div> 管理工作区</div>
|
|
|
|
<span>列出、重命名、删除工作区</span>
|
2019-06-29 16:33:21 +00:00
|
|
|
</menu-entry>
|
|
|
|
<hr>
|
2018-07-03 23:41:24 +00:00
|
|
|
<div class="workspace" v-for="(workspace, id) in workspacesById" :key="id">
|
2017-12-10 23:49:20 +00:00
|
|
|
<menu-entry :href="workspace.url" target="_blank">
|
2017-12-17 15:08:52 +00:00
|
|
|
<icon-provider slot="icon" :provider-id="workspace.providerId"></icon-provider>
|
2022-05-26 23:55:37 +00:00
|
|
|
<div class="workspace__name"><div class="menu-entry__label" v-if="currentWorkspace === workspace">当前</div>{{workspace.name}}</div>
|
2017-12-10 23:49:20 +00:00
|
|
|
</menu-entry>
|
|
|
|
</div>
|
|
|
|
<hr>
|
2018-04-27 14:37:05 +00:00
|
|
|
<menu-entry @click.native="addGithubWorkspace">
|
|
|
|
<icon-provider slot="icon" provider-id="githubWorkspace"></icon-provider>
|
2022-05-26 23:55:37 +00:00
|
|
|
<span>新增 <b>GitHub</b> 工作区</span>
|
2018-04-27 14:37:05 +00:00
|
|
|
</menu-entry>
|
2022-05-23 03:29:54 +00:00
|
|
|
<menu-entry @click.native="addGiteeWorkspace">
|
|
|
|
<icon-provider slot="icon" provider-id="giteeWorkspace"></icon-provider>
|
2022-05-26 23:55:37 +00:00
|
|
|
<span>新增 <b>Gitee</b> 工作区</span>
|
2022-05-23 03:29:54 +00:00
|
|
|
</menu-entry>
|
2018-09-19 08:59:22 +00:00
|
|
|
<menu-entry @click.native="addGitlabWorkspace">
|
|
|
|
<icon-provider slot="icon" provider-id="gitlabWorkspace"></icon-provider>
|
2022-05-26 23:55:37 +00:00
|
|
|
<span>新增 <b>GitLab</b> 工作区</span>
|
2018-09-19 08:59:22 +00:00
|
|
|
</menu-entry>
|
2022-05-25 05:43:45 +00:00
|
|
|
<menu-entry @click.native="addGiteaWorkspace">
|
|
|
|
<icon-provider slot="icon" provider-id="giteaWorkspace"></icon-provider>
|
2022-05-26 23:55:37 +00:00
|
|
|
<span>新增 <b>Gitea</b> 工作区</span>
|
2022-05-25 05:43:45 +00:00
|
|
|
</menu-entry>
|
2018-04-27 14:37:05 +00:00
|
|
|
<menu-entry @click.native="addGoogleDriveWorkspace">
|
|
|
|
<icon-provider slot="icon" provider-id="googleDriveWorkspace"></icon-provider>
|
2022-05-26 23:55:37 +00:00
|
|
|
<span>新增 <b>Google Drive</b> 工作区</span>
|
|
|
|
</menu-entry>
|
|
|
|
<menu-entry @click.native="addCouchdbWorkspace">
|
|
|
|
<icon-provider slot="icon" provider-id="couchdbWorkspace"></icon-provider>
|
|
|
|
<span>新增 <b>CouchDB</b> 工作区</span>
|
2018-04-27 14:37:05 +00:00
|
|
|
</menu-entry>
|
2017-12-10 23:49:20 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import MenuEntry from './common/MenuEntry';
|
|
|
|
import googleHelper from '../../services/providers/helpers/googleHelper';
|
2018-09-19 08:59:22 +00:00
|
|
|
import gitlabHelper from '../../services/providers/helpers/gitlabHelper';
|
2022-05-25 05:43:45 +00:00
|
|
|
import giteaHelper from '../../services/providers/helpers/giteaHelper';
|
2018-09-19 08:59:22 +00:00
|
|
|
import store from '../../store';
|
2017-12-10 23:49:20 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
MenuEntry,
|
|
|
|
},
|
|
|
|
computed: {
|
2017-12-17 15:08:52 +00:00
|
|
|
...mapGetters('workspace', [
|
2018-07-03 23:41:24 +00:00
|
|
|
'workspacesById',
|
2017-12-17 15:08:52 +00:00
|
|
|
'currentWorkspace',
|
|
|
|
]),
|
2018-07-03 23:41:24 +00:00
|
|
|
workspaceCount() {
|
|
|
|
return Object.keys(this.workspacesById).length;
|
|
|
|
},
|
2017-12-10 23:49:20 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2018-05-13 13:27:33 +00:00
|
|
|
async addCouchdbWorkspace() {
|
|
|
|
try {
|
2018-09-19 08:59:22 +00:00
|
|
|
store.dispatch('modal/open', {
|
2018-05-13 13:27:33 +00:00
|
|
|
type: 'couchdbWorkspace',
|
|
|
|
});
|
2019-06-30 12:28:37 +00:00
|
|
|
} catch (e) { /* Cancel */ }
|
2018-04-27 14:37:05 +00:00
|
|
|
},
|
2018-05-13 13:27:33 +00:00
|
|
|
async addGithubWorkspace() {
|
|
|
|
try {
|
2018-09-19 08:59:22 +00:00
|
|
|
store.dispatch('modal/open', {
|
2018-05-13 13:27:33 +00:00
|
|
|
type: 'githubWorkspace',
|
|
|
|
});
|
2019-06-30 12:28:37 +00:00
|
|
|
} catch (e) { /* Cancel */ }
|
2022-05-23 03:29:54 +00:00
|
|
|
},
|
|
|
|
async addGiteeWorkspace() {
|
|
|
|
try {
|
|
|
|
store.dispatch('modal/open', {
|
|
|
|
type: 'giteeWorkspace',
|
|
|
|
});
|
|
|
|
} catch (e) { /* Cancel */ }
|
2018-04-27 14:37:05 +00:00
|
|
|
},
|
2018-09-19 08:59:22 +00:00
|
|
|
async addGitlabWorkspace() {
|
|
|
|
try {
|
|
|
|
const { serverUrl, applicationId } = await store.dispatch('modal/open', { type: 'gitlabAccount' });
|
|
|
|
const token = await gitlabHelper.addAccount(serverUrl, applicationId);
|
|
|
|
store.dispatch('modal/open', {
|
|
|
|
type: 'gitlabWorkspace',
|
|
|
|
token,
|
|
|
|
});
|
2019-06-30 12:28:37 +00:00
|
|
|
} catch (e) { /* Cancel */ }
|
2018-09-19 08:59:22 +00:00
|
|
|
},
|
2022-05-25 05:43:45 +00:00
|
|
|
async addGiteaWorkspace() {
|
|
|
|
try {
|
|
|
|
const { serverUrl, applicationId, applicationSecret } = await store.dispatch('modal/open', { type: 'giteaAccount' });
|
|
|
|
const token = await giteaHelper.addAccount(serverUrl, applicationId, applicationSecret);
|
|
|
|
store.dispatch('modal/open', {
|
|
|
|
type: 'giteaWorkspace',
|
|
|
|
token,
|
|
|
|
});
|
|
|
|
} catch (e) { /* Cancel */ }
|
|
|
|
},
|
2018-05-13 13:27:33 +00:00
|
|
|
async addGoogleDriveWorkspace() {
|
|
|
|
try {
|
|
|
|
const token = await googleHelper.addDriveAccount(true);
|
2018-09-19 08:59:22 +00:00
|
|
|
store.dispatch('modal/open', {
|
2017-12-10 23:49:20 +00:00
|
|
|
type: 'googleDriveWorkspace',
|
|
|
|
token,
|
2018-05-13 13:27:33 +00:00
|
|
|
});
|
2019-06-30 12:28:37 +00:00
|
|
|
} catch (e) { /* Cancel */ }
|
2017-12-10 23:49:20 +00:00
|
|
|
},
|
|
|
|
manageWorkspaces() {
|
2019-06-30 12:28:37 +00:00
|
|
|
try {
|
|
|
|
store.dispatch('modal/open', 'workspaceManagement');
|
|
|
|
} catch (e) { /* Cancel */ }
|
2017-12-10 23:49:20 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
2018-05-06 00:46:33 +00:00
|
|
|
@import '../../styles/variables.scss';
|
2017-12-17 15:08:52 +00:00
|
|
|
|
|
|
|
.workspace .menu-entry {
|
|
|
|
padding-top: 12px;
|
|
|
|
padding-bottom: 12px;
|
|
|
|
}
|
|
|
|
|
2017-12-10 23:49:20 +00:00
|
|
|
.workspace__name {
|
|
|
|
font-weight: bold;
|
2017-12-17 15:08:52 +00:00
|
|
|
line-height: 1.2;
|
2017-12-10 23:49:20 +00:00
|
|
|
}
|
|
|
|
</style>
|