Stackedit/src/components/menus/WorkspacesMenu.vue

115 lines
3.4 KiB
Vue
Raw Normal View History

2017-12-10 23:49:20 +00:00
<template>
<div class="side-bar__panel side-bar__panel--menu">
<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>
<div class="workspace__name"><div class="menu-entry__label" v-if="currentWorkspace === workspace">current</div>{{workspace.name}}</div>
2017-12-10 23:49:20 +00:00
</menu-entry>
</div>
<hr>
2018-01-24 07:31:54 +00:00
<menu-entry @click.native="addCouchdbWorkspace">
<icon-provider slot="icon" provider-id="couchdbWorkspace"></icon-provider>
2018-09-20 09:00:07 +00:00
<span>Add a <b>CouchDB</b> backed workspace</span>
2018-01-24 07:31:54 +00:00
</menu-entry>
2018-04-27 14:37:05 +00:00
<menu-entry @click.native="addGithubWorkspace">
<icon-provider slot="icon" provider-id="githubWorkspace"></icon-provider>
2018-09-20 09:00:07 +00:00
<span>Add a <b>GitHub</b> backed workspace</span>
2018-04-27 14:37:05 +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>
2018-09-20 09:00:07 +00:00
<span>Add a <b>GitLab</b> backed workspace</span>
2018-09-19 08:59:22 +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>
2018-09-20 09:00:07 +00:00
<span>Add a <b>Google Drive</b> backed workspace</span>
2018-04-27 14:37:05 +00:00
</menu-entry>
2017-12-10 23:49:20 +00:00
<menu-entry @click.native="manageWorkspaces">
<icon-database slot="icon"></icon-database>
<span><div class="menu-entry__label menu-entry__label--count">{{workspaceCount}}</div> Manage workspaces</span>
2017-12-10 23:49:20 +00:00
</menu-entry>
</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';
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', [
'workspacesById',
2017-12-17 15:08:52 +00:00
'currentWorkspace',
]),
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',
});
} 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',
});
} 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,
});
} 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
});
} catch (e) {
// Cancel
}
2017-12-10 23:49:20 +00:00
},
manageWorkspaces() {
2018-09-19 08:59:22 +00:00
store.dispatch('modal/open', 'workspaceManagement');
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>