1
1
import VueSelect from 'vue-select' ;
2
2
3
+ import { hydrateAppWithData } from "./hydration" ;
4
+
3
5
export const IssueLabel = {
4
6
template : `
5
7
<span class="gh-label" :class="className">
@@ -25,7 +27,7 @@ export const IssueLabel = {
25
27
* @returns {string } the name of the class to apply to the label
26
28
*/
27
29
className ( ) {
28
- return window . categories [ this . name ] || 'miscellaneous'
30
+ return this . $root . categories [ this . name ] || 'miscellaneous'
29
31
}
30
32
}
31
33
}
@@ -68,7 +70,7 @@ export const IssueCard = {
68
70
} ,
69
71
computed : {
70
72
dateCreated ( ) {
71
- const dateCreated = new Date ( this . issue . createdAt * 1000 )
73
+ const dateCreated = new Date ( this . issue . createdAt * 1000 )
72
74
return dateCreated . toLocaleDateString ( )
73
75
}
74
76
}
@@ -80,7 +82,7 @@ export const App = {
80
82
<div class="find-issues">
81
83
<div class="columns">
82
84
<div class="column is-one-quarter">
83
- <form id="filters">
85
+ <form id="filters" v-if="options.skills.length" >
84
86
<label for="skills">
85
87
<strong>Skill set</strong><br/>
86
88
Choose up to three skills that you would like to see issues for.
@@ -108,6 +110,9 @@ export const App = {
108
110
:reduce="experience => experience.code"
109
111
:clearable="false"/>
110
112
</form>
113
+ <div v-else>
114
+ Loading filters, please wait...
115
+ </div>
111
116
</div>
112
117
<div class="column">
113
118
<template v-if="filteredIssues.length">
@@ -131,7 +136,7 @@ export const App = {
131
136
data ( ) {
132
137
return {
133
138
options : {
134
- skills : window . skills ,
139
+ skills : [ ] ,
135
140
experiences : [
136
141
{ name : 'Yes, it is' , code : 'beginner' } ,
137
142
{ name : 'No, it isn\'t' , code : 'experienced' }
@@ -141,6 +146,7 @@ export const App = {
141
146
skills : [ ] ,
142
147
experience : 'experienced'
143
148
} ,
149
+ categories : { } ,
144
150
issues : [ ]
145
151
}
146
152
} ,
@@ -166,5 +172,23 @@ export const App = {
166
172
return true
167
173
} ) . sort ( ( a , b ) => b . createdAt - a . createdAt )
168
174
}
175
+ } ,
176
+ mounted ( ) {
177
+ const BASE_URL = 'https://raw.githubusercontent.com/creativecommons/ccos-scripts/master/normalize_repos'
178
+ const FILE_URL = name => `${ BASE_URL } /${ name } .json`
179
+
180
+ Promise
181
+ . all ( [
182
+ fetch ( FILE_URL ( 'skills' ) )
183
+ . then ( response => response . json ( ) ) ,
184
+ fetch ( FILE_URL ( 'labels' ) )
185
+ . then ( response => response . json ( ) )
186
+ ] )
187
+ . then ( ( [ skillResponse , labelResponse ] ) => {
188
+ const [ skills , categories ] = hydrateAppWithData ( skillResponse , labelResponse )
189
+ this . categories = categories
190
+ this . options . skills = skills
191
+ } )
192
+ . catch ( err => console . error ( err ) )
169
193
}
170
194
}
0 commit comments