1
1
import VueSelect from 'vue-select' ;
2
+ import { Octokit } from '@octokit/rest' ;
2
3
3
4
import { hydrateAppWithData } from "./hydration" ;
4
5
@@ -40,7 +41,7 @@ export const IssueCard = {
40
41
</h4>
41
42
<p class="is-size-6">
42
43
<a
43
- :href="issue.url "
44
+ :href="issue.html_url "
44
45
target="_blank">
45
46
<span class="has-color-forest-green">
46
47
{{ issue.repo }}#{{ issue.number }}
@@ -70,8 +71,7 @@ export const IssueCard = {
70
71
} ,
71
72
computed : {
72
73
dateCreated ( ) {
73
- const dateCreated = new Date ( this . issue . createdAt * 1000 )
74
- const [ dateComponent , ] = dateCreated . toISOString ( ) . split ( "T" )
74
+ const [ dateComponent , ] = this . issue . created_at . split ( "T" )
75
75
return dateComponent
76
76
}
77
77
}
@@ -84,6 +84,20 @@ export const App = {
84
84
<div class="columns">
85
85
<div class="column is-one-quarter">
86
86
<form id="filters" v-if="options.skills.length">
87
+ <label for="aim">
88
+ <strong>Aim</strong><br/>
89
+ I am interested in...
90
+ </label>
91
+ <VueSelect
92
+ v-model="filters.aim"
93
+ id="aim"
94
+ name="aim"
95
+ :options="options.aims"
96
+ label="name"
97
+ :reduce="aim => aim.code"
98
+ :clearable="false"/>
99
+ <br/>
100
+ <template v-if="filters.aim === 'contribute'">
87
101
<label for="skills">
88
102
<strong>Skill set*</strong><br/>
89
103
Choose up to three skills that you would like to see issues for.
@@ -110,6 +124,7 @@ export const App = {
110
124
label="name"
111
125
:reduce="experience => experience.code"
112
126
:clearable="false"/>
127
+ </template>
113
128
</form>
114
129
<p class="disclaimer">
115
130
*Not all issues have skills marked on them, especially if they are
@@ -144,18 +159,24 @@ export const App = {
144
159
data ( ) {
145
160
return {
146
161
options : {
162
+ aims : [
163
+ { name : 'Contributing code' , code : 'contribute' } ,
164
+ { name : 'Triaging issues' , code : 'triage' }
165
+ ] ,
147
166
skills : [ ] ,
148
167
experiences : [
149
168
{ name : 'Yes, it is' , code : 'beginner' } ,
150
169
{ name : 'No, it isn\'t' , code : 'experienced' }
151
170
]
152
171
} ,
153
172
filters : {
173
+ aim : 'contribute' ,
154
174
skills : [ ] ,
155
175
experience : 'experienced'
156
176
} ,
157
177
categories : { } ,
158
- issues : [ ]
178
+ issues : [ ] ,
179
+ octokit : null
159
180
}
160
181
} ,
161
182
computed : {
@@ -165,26 +186,61 @@ export const App = {
165
186
* @returns {array } the array of filtered issues
166
187
*/
167
188
filteredIssues ( ) {
168
- return window . issues . filter ( issue => {
189
+ return this . issues . filter ( issue => {
190
+ // If aim is to triage issues
191
+ if ( this . filters . aim === 'triage' ) {
192
+ // Show all issues as they all have the label "🚦 status: awaiting triage"
193
+ return true
194
+ }
195
+
169
196
// Check experience match
170
197
if ( this . filters . experience === 'beginner' && ! issue . labels . includes ( 'good first issue' ) ) {
171
198
return false
172
199
}
173
200
174
201
// Check skill set match
175
202
const joinedLabels = issue . labels . join ( ',' )
176
- if ( this . filters . skills . length && ! this . filters . skills . some ( skill => joinedLabels . includes ( skill ) ) ) {
177
- return false
178
- }
179
-
180
- return true
203
+ return ! ( this . filters . skills . length && ! this . filters . skills . some ( skill => joinedLabels . includes ( skill ) ) ) ;
181
204
} ) . sort ( ( a , b ) => b . createdAt - a . createdAt )
182
205
}
183
206
} ,
207
+ watch : {
208
+ 'filters.aim' ( to , from ) {
209
+ if ( to !== from ) {
210
+ this . loadIssues ( )
211
+ }
212
+ }
213
+ } ,
214
+ methods : {
215
+ loadIssues ( ) {
216
+ const q = [ 'org:creativecommons' , 'is:open' , 'is:issue' ]
217
+ if ( this . filters . aim === 'contribute' ) {
218
+ q . push ( 'label:"help wanted"' )
219
+ } else if ( this . filters . aim === 'triage' ) {
220
+ q . push ( 'label:"🚦 status: awaiting triage"' )
221
+ }
222
+ this . octokit . search . issuesAndPullRequests ( {
223
+ q : q . join ( ' ' ) ,
224
+ per_page : 100 ,
225
+ sort : 'updated'
226
+ } ) . then ( res => {
227
+ this . issues = res . data . items
228
+ this . issues . forEach ( issue => {
229
+ issue . labels = issue . labels . map ( label => label . name )
230
+
231
+ const repoUrl = issue . repository_url
232
+ issue . repo = repoUrl . slice ( repoUrl . lastIndexOf ( '/' ) + 1 )
233
+ } )
234
+ } )
235
+ }
236
+ } ,
184
237
mounted ( ) {
185
238
const BASE_URL = 'https://raw.githubusercontent.com/creativecommons/ccos-scripts/master/normalize_repos'
186
239
const FILE_URL = name => `${ BASE_URL } /${ name } .json`
187
240
241
+ this . octokit = new Octokit ( )
242
+ this . loadIssues ( )
243
+
188
244
Promise
189
245
. all ( [
190
246
fetch ( FILE_URL ( 'skills' ) )
0 commit comments