Skip to content

Commit

Permalink
feat: git drawer UI (wip) + various improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
NGPixel committed Feb 22, 2024
1 parent 2e6694e commit ef57281
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 21 deletions.
14 changes: 13 additions & 1 deletion src-electron/menu.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Menu, app, shell } from 'electron'
import os from 'node:os'

import { openDocument } from './handlers'
import { openDocument, selectDirectory } from './handlers'

export function registerMenu (mainWindow) {
const platform = process.platform || os.platform()
Expand Down Expand Up @@ -51,6 +51,18 @@ export function registerMenu (mainWindow) {
{
type: 'separator'
},
{
label: 'Set Working Directory...',
async click () {
const wdPath = await selectDirectory(mainWindow, null, 'Select Working Directory...')
if (wdPath) {
mainWindow.webContents.send('setWorkingDirectory', wdPath)
}
}
},
{
type: 'separator'
},
{
label: 'Save',
accelerator: 'CommandOrControl+S',
Expand Down
118 changes: 101 additions & 17 deletions src/components/DrawerGit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@
.text-caption.text-light-blue-3
strong Git
q-space
template(v-if='editorStore.isGitRepo')
q-btn(
flat
size='sm'
icon='mdi-sync'
padding='xs xs'
text-color='light-blue-3'
)
q-tooltip Fetch
q-btn(
flat
size='sm'
icon='mdi-content-duplicate'
padding='xs xs'
text-color='light-blue-3'
@click='cloneRepo'
)
q-tooltip Clone Repository...
q-btn(
flat
size='sm'
icon='mdi-archive-plus-outline'
padding='xs xs'
text-color='light-blue-3'
)
q-tooltip Initialize New...
q-btn(
flat
size='sm'
Expand All @@ -13,31 +39,66 @@
@click='gitSettings'
)
q-tooltip Git Settings
q-btn.full-width.q-mt-sm(
icon='mdi-cloud-download'
label='Clone Repository...'
color='primary'
no-caps
unelevated
@click='cloneRepo'
)
q-btn.full-width.q-mt-sm(
icon='mdi-git'
label='Initialize New...'
color='primary'
no-caps
unelevated
)
template(v-if='!editorStore.isGitRepo')
q-btn.full-width.q-mt-sm(
icon='mdi-cloud-download'
label='Clone Repository...'
color='primary'
no-caps
unelevated
@click='cloneRepo'
)
q-btn.full-width.q-mt-sm(
icon='mdi-git'
label='Initialize New...'
color='primary'
no-caps
unelevated
)
template(v-else)
.drawer-git-branch.q-mt-sm
q-icon.q-mr-sm(name='mdi-source-branch')
span Branch: #[strong main]
q-space
q-btn(
flat
size='sm'
icon='mdi-swap-horizontal'
padding='xs xs'
text-color='grey-5'
)
q-tooltip Checkout Branch...
.drawer-git-changes.q-mt-sm
.flex.items-center.text-caption.text-grey-4
q-icon.q-mr-sm(name='mdi-list-status')
strong Changes
q-space
q-btn(
flat
size='sm'
icon='mdi-refresh'
padding='xs xs'
text-color='grey-5'
)
q-tooltip Refresh
.text-center.text-caption.q-mt-sm
em.text-grey-5 No changes.
.drawer-git-history.q-mt-sm
.flex.items-center.text-caption.text-grey-4
q-icon.q-mr-sm(name='mdi-list-box-outline')
strong History
.text-center.text-caption.q-mt-sm
em.text-grey-5 No commit yet.
</template>

<script setup>
import { defineAsyncComponent } from 'vue'
import { useQuasar } from 'quasar'
// import { useEditorStore } from 'src/stores/editor'
import { useEditorStore } from 'src/stores/editor'
const $q = useQuasar()
// const editorStore = useEditorStore()
const editorStore = useEditorStore()
// METHODS
Expand All @@ -57,3 +118,26 @@ function cloneRepo () {
}
</script>

<style lang="scss">
.drawer-git {
&-branch {
display: flex;
align-items: center;
font-size: 12px;
background-color: rgba(255,255,255,.1);
border-radius: 4px;
padding: 5px 8px;
}
&-changes {
background-color: rgba(255,255,255,.1);
border-radius: 4px;
padding: 5px 8px;
}
&-history {
background-color: rgba(255,255,255,.1);
border-radius: 4px;
padding: 5px 8px;
}
}
</style>
3 changes: 2 additions & 1 deletion src/components/DrawerPane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ q-drawer.bg-dark-4(
q-scroll-area.fit(
:horizontal-thumb-style='{ opacity: 0 }'
)
component(:is='panes[editorStore.drawerPane]')
keep-alive
component(:is='panes[editorStore.drawerPane]')
</template>

<script setup>
Expand Down
4 changes: 2 additions & 2 deletions src/stores/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export const useEditorStore = defineStore('editor', {
}),
getters: {
hasErrors: (state) => state.errors?.length > 0,
isDarkTheme: (state) => ['ietf-dark', 'hc-black'].includes(state.theme)
isDarkTheme: (state) => ['ietf-dark', 'hc-black'].includes(state.theme),
isGitRepo: (state) => state.workingDirFiles.some(f => f.name === '.git')
},
actions: {
async fetchGitConfig () {
Expand Down Expand Up @@ -65,7 +66,6 @@ export const useEditorStore = defineStore('editor', {
paths: [
'cursorBlinking',
'cursorStyle',
'drawerPane',
'fontSize',
'formatOnType',
'previewPaneShown',
Expand Down

0 comments on commit ef57281

Please sign in to comment.