11import VueSelect from 'vue-select' ;
22
3+ import { hydrateAppWithData } from "./hydration" ;
4+
35export const IssueLabel = {
46 template : `
57<span class="gh-label" :class="className">
@@ -25,7 +27,7 @@ export const IssueLabel = {
2527 * @returns {string } the name of the class to apply to the label
2628 */
2729 className ( ) {
28- return window . categories [ this . name ] || 'miscellaneous'
30+ return this . $root . categories [ this . name ] || 'miscellaneous'
2931 }
3032 }
3133}
@@ -68,7 +70,7 @@ export const IssueCard = {
6870 } ,
6971 computed : {
7072 dateCreated ( ) {
71- const dateCreated = new Date ( this . issue . createdAt * 1000 )
73+ const dateCreated = new Date ( this . issue . createdAt * 1000 )
7274 return dateCreated . toLocaleDateString ( )
7375 }
7476 }
@@ -80,7 +82,7 @@ export const App = {
8082<div class="find-issues">
8183 <div class="columns">
8284 <div class="column is-one-quarter">
83- <form id="filters">
85+ <form id="filters" v-if="options.skills.length" >
8486 <label for="skills">
8587 <strong>Skill set</strong><br/>
8688 Choose up to three skills that you would like to see issues for.
@@ -108,6 +110,9 @@ export const App = {
108110 :reduce="experience => experience.code"
109111 :clearable="false"/>
110112 </form>
113+ <div v-else>
114+ Loading filters, please wait...
115+ </div>
111116 </div>
112117 <div class="column">
113118 <template v-if="filteredIssues.length">
@@ -131,7 +136,7 @@ export const App = {
131136 data ( ) {
132137 return {
133138 options : {
134- skills : window . skills ,
139+ skills : [ ] ,
135140 experiences : [
136141 { name : 'Yes, it is' , code : 'beginner' } ,
137142 { name : 'No, it isn\'t' , code : 'experienced' }
@@ -141,6 +146,7 @@ export const App = {
141146 skills : [ ] ,
142147 experience : 'experienced'
143148 } ,
149+ categories : { } ,
144150 issues : [ ]
145151 }
146152 } ,
@@ -166,5 +172,23 @@ export const App = {
166172 return true
167173 } ) . sort ( ( a , b ) => b . createdAt - a . createdAt )
168174 }
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 ) )
169193 }
170- }
194+ }
0 commit comments