aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--application/components/app.vue2
-rw-r--r--application/components/github/api.js (renamed from application/github.js)2
-rw-r--r--application/components/github/invalid-repo.vue (renamed from application/components/messages/invalid-repo.vue)0
-rw-r--r--application/components/github/picker.vue (renamed from application/components/github-picker.vue)25
-rw-r--r--application/components/github/storage.js18
-rw-r--r--application/components/initialize.vue2
-rw-r--r--application/components/keyboard-picker.vue2
-rw-r--r--application/components/messages/too-many-repos.vue37
8 files changed, 35 insertions, 53 deletions
diff --git a/application/components/app.vue b/application/components/app.vue
index e53345c..766f901 100644
--- a/application/components/app.vue
+++ b/application/components/app.vue
@@ -6,7 +6,7 @@ import KeyboardPicker from './keyboard-picker.vue'
import Spinner from './spinner.vue'
import * as config from '../config'
-import * as github from '../github'
+import * as github from './github/api'
export default {
components: {
diff --git a/application/github.js b/application/components/github/api.js
index 0d0782c..b2e29e9 100644
--- a/application/github.js
+++ b/application/components/github/api.js
@@ -1,4 +1,4 @@
-import * as config from './config'
+import * as config from '../../config'
let token
export let installation
diff --git a/application/components/messages/invalid-repo.vue b/application/components/github/invalid-repo.vue
index eee706f..eee706f 100644
--- a/application/components/messages/invalid-repo.vue
+++ b/application/components/github/invalid-repo.vue
diff --git a/application/components/github-picker.vue b/application/components/github/picker.vue
index e52fcce..73520a1 100644
--- a/application/components/github-picker.vue
+++ b/application/components/github/picker.vue
@@ -35,10 +35,11 @@
import find from 'lodash/find'
import map from 'lodash/map'
-import * as github from '../github'
-import InvalidRepo from './messages/invalid-repo.vue'
-import Selector from './selector.vue'
-import Spinner from './spinner.vue'
+import * as github from './api'
+import * as storage from './storage'
+import InvalidRepo from './invalid-repo.vue'
+import Selector from '../selector.vue'
+import Spinner from '../spinner.vue'
export default {
name: 'GithubPicker',
@@ -59,7 +60,7 @@ export default {
return
}
- const selectedRepository = JSON.parse(localStorage.getItem('selectedGithubRepository'))
+ const selectedRepository = storage.getPersistedRepository()
if (github.repositories.length === 1) {
this.repo = github.repositories[0].full_name
@@ -70,15 +71,15 @@ export default {
}
},
watch: {
- repo(current, previous) {
- if (previous !== current) {
- localStorage.setItem('selectedGithubRepository', JSON.stringify(current))
+ repo(value) {
+ storage.setPersistedRepository(value)
+ if (value) {
this.loadBranches()
}
},
- branch(current, previous) {
- if (current && previous !== current) {
- localStorage.setItem('selectedGithubBranch', JSON.stringify(current))
+ branch(value) {
+ storage.setPersistedBranch(value)
+ if (value) {
this.loadKeyboard()
}
}
@@ -106,7 +107,7 @@ export default {
const available = map(branches, 'name')
const defaultBranch = repository.default_branch
const currentBranch = this.branch
- const previousBranch = JSON.parse(localStorage.getItem('selectedGithubBranch'))
+ const previousBranch = storage.getPersistedBranch()
const onlyBranch = branches.length === 1 ? branches[0].name : null
for (let branch of [onlyBranch, currentBranch, previousBranch, defaultBranch]) {
diff --git a/application/components/github/storage.js b/application/components/github/storage.js
new file mode 100644
index 0000000..87603a0
--- /dev/null
+++ b/application/components/github/storage.js
@@ -0,0 +1,18 @@
+const REPOSITORY = 'selectedGithubRepository'
+const BRANCH = 'selectedGithubBranch'
+
+export function getPersistedRepository() {
+ return JSON.parse(localStorage.getItem(REPOSITORY))
+}
+
+export function setPersistedRepository(repository) {
+ localStorage.setItem(REPOSITORY, JSON.stringify(repository))
+}
+
+export function getPersistedBranch() {
+ return JSON.parse(localStorage.getItem(BRANCH))
+}
+
+export function setPersistedBranch(branch) {
+ localStorage.setItem(BRANCH, JSON.stringify(branch))
+}
diff --git a/application/components/initialize.vue b/application/components/initialize.vue
index c0146a4..0d5fc1f 100644
--- a/application/components/initialize.vue
+++ b/application/components/initialize.vue
@@ -1,7 +1,7 @@
<script>
import keyBy from 'lodash/keyBy'
-import * as github from '../github'
+import * as github from './github/api'
import { healthcheck, loadBehaviours } from '../api'
import { loadKeycodes } from '../keycodes'
diff --git a/application/components/keyboard-picker.vue b/application/components/keyboard-picker.vue
index 12008c2..c3b6383 100644
--- a/application/components/keyboard-picker.vue
+++ b/application/components/keyboard-picker.vue
@@ -21,7 +21,7 @@ import * as config from '../config'
import { loadLayout } from '../layout.js'
import { loadKeymap } from '../keymap.js'
-import GithubPicker from './github-picker.vue'
+import GithubPicker from './github/picker.vue'
import Selector from './selector.vue'
export default {
diff --git a/application/components/messages/too-many-repos.vue b/application/components/messages/too-many-repos.vue
deleted file mode 100644
index 086e471..0000000
--- a/application/components/messages/too-many-repos.vue
+++ /dev/null
@@ -1,37 +0,0 @@
-<template>
- <modal>
- <div class="dialog">
- <h2>Hold up a second!</h2>
- <p>The Keymap Editor app has been installed for more than one GitHub repository.</p>
- <p>
- I'm still working on things, including the ability to pick a specific
- repo, but in the meantime you should go back to your <a :href="getInstallationUrl()">app configuration</a>
- and select a single repository containing your keyboard's zmk-config.
- </p>
- </div>
- </modal>
-</template>
-
-<script>
-import Modal from '../modal.vue'
-import * as github from '../../github'
-
-export default {
- name: 'TooManyRepos',
- components: { Modal },
- methods: {
- getInstallationUrl() {
- return `https://github.com/settings/installations/${github.installation.id}`
- }
- }
-}
-</script>
-
-<style scoped>
-.dialog {
- background-color: white;
- padding: 40px;
- margin: 40px;
- max-width: 500px;
-}
-</style> \ No newline at end of file