@@ -14,6 +14,7 @@ export interface Transform {
14
14
languages : string [ ] ;
15
15
drafts : JSONSchemaDraft [ ] ;
16
16
toolingTypes : string [ ] ;
17
+ environments : string [ ] ;
17
18
}
18
19
19
20
export type TransformUpdate =
@@ -34,6 +35,7 @@ const buildQueryString = (transform: Transform) => {
34
35
languages : transform . languages . join ( ',' ) ,
35
36
drafts : transform . drafts . join ( ',' ) ,
36
37
toolingTypes : transform . toolingTypes . join ( ',' ) ,
38
+ environments : transform . environments . join ( ',' ) ,
37
39
} ) . toString ( ) ;
38
40
} ;
39
41
@@ -50,6 +52,7 @@ export default function useToolsTransform(tools: JSONSchemaTool[]) {
50
52
licenses : [ ] ,
51
53
drafts : [ ] ,
52
54
toolingTypes : [ ] ,
55
+ environments : [ ] ,
53
56
} ) ;
54
57
55
58
useEffect ( ( ) => {
@@ -78,6 +81,9 @@ export default function useToolsTransform(tools: JSONSchemaTool[]) {
78
81
toolingTypes : parseArrayParam (
79
82
query . toolingTypes ,
80
83
) as Transform [ 'toolingTypes' ] ,
84
+ environments : parseArrayParam (
85
+ query . environments ,
86
+ ) as Transform [ 'environments' ] ,
81
87
} ;
82
88
83
89
const queryString = buildQueryString ( updatedTransform ) ;
@@ -124,6 +130,7 @@ export default function useToolsTransform(tools: JSONSchemaTool[]) {
124
130
licenses : [ ] ,
125
131
drafts : [ ] ,
126
132
toolingTypes : [ ] ,
133
+ environments : [ ] ,
127
134
} ;
128
135
129
136
const queryString = buildQueryString ( initialTransform ) ;
@@ -183,6 +190,7 @@ const filterTools = (
183
190
languages : lowerCaseArray ( transform . languages ) ,
184
191
licenses : lowerCaseArray ( transform . licenses ) ,
185
192
toolingTypes : lowerCaseArray ( transform . toolingTypes ) ,
193
+ environments : lowerCaseArray ( transform . environments ) ,
186
194
drafts : transform . drafts ,
187
195
} ;
188
196
@@ -204,14 +212,24 @@ const filterTools = (
204
212
lowerCaseTransform . toolingTypes . includes ( type . toLowerCase ( ) ) ,
205
213
) ;
206
214
215
+ const matchesEnvironment =
216
+ ! lowerCaseTransform . environments . length ||
217
+ ( tool . environments || [ ] ) . some ( ( environment ) =>
218
+ lowerCaseTransform . environments . includes ( environment . toLowerCase ( ) ) ,
219
+ ) ;
220
+
207
221
const matchesDraft =
208
222
! lowerCaseTransform . drafts . length ||
209
223
( tool . supportedDialects ?. draft || [ ] ) . some ( ( draft ) =>
210
224
lowerCaseTransform . drafts . includes ( draft ) ,
211
225
) ;
212
226
213
227
return (
214
- matchesLanguage && matchesLicense && matchesToolingType && matchesDraft
228
+ matchesLanguage &&
229
+ matchesLicense &&
230
+ matchesToolingType &&
231
+ matchesEnvironment &&
232
+ matchesDraft
215
233
) ;
216
234
} ) ;
217
235
} ;
0 commit comments