@spotify/backstage-plugin-soundcheck 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/config.d.ts +4 -0
- package/dist/esm/{EntitySoundcheckContent-ac967308.esm.js → EntitySoundcheckContent-52a2a214.esm.js} +2 -2
- package/dist/esm/{OverviewPageContent-cee8c2bb.esm.js → OverviewPageContent-dbbba0be.esm.js} +2 -2
- package/dist/esm/{RefetchingIndicator-50e5cc94.esm.js → RefetchingIndicator-7160bb11.esm.js} +2 -2
- package/dist/esm/{index-39051bf4.esm.js → index-0024f6e1.esm.js} +2 -2
- package/dist/esm/index-37aedac7.esm.js +299 -0
- package/dist/esm/{index-d27c0b4b.esm.js → index-829d0670.esm.js} +2 -2
- package/dist/esm/index-c29fd0e9.esm.js +2 -0
- package/dist/images/catalog.svg +1 -0
- package/dist/images/git.svg +4 -0
- package/dist/images/octocat.svg +17 -0
- package/dist/images/settings.svg +90 -0
- package/dist/images/soundcheck.png +0 -0
- package/dist/images/tech_insights.png +0 -0
- package/dist/index.esm.js +1 -1
- package/package.json +14 -11
- package/dist/esm/index-094c5781.esm.js +0 -306
- package/dist/esm/index-ee6cc5f1.esm.js +0 -2
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import{createApiRef as Fe,createRouteRef as S,createSubRouteRef as C,createPlugin as Le,createApiFactory as Ae,discoveryApiRef as xe,fetchApiRef as Oe,createRoutableExtension as $,createComponentExtension as qe,useApi as B,errorApiRef as Te,useRouteRef as j}from"@backstage/core-plugin-api";import{GraphQLClient as Be}from"graphql-request";import s from"graphql-tag";import a,{createContext as V,useState as P,useCallback as E,useContext as K,useRef as Me,useEffect as ze,Fragment as Ge}from"react";import{QueryClient as Ue,QueryClientProvider as We,useQuery as _}from"@tanstack/react-query";import{memoize as He}from"lodash";import Qe from"@material-ui/core/styles/makeStyles";import{makeStyles as p,Typography as u,Modal as je,Box as J,Button as X,Fade as Ve,alpha as w,Tooltip as Ke,withStyles as N,Divider as _e}from"@material-ui/core";import{MarkdownContent as Y,Link as Z,EmptyState as ee,InfoCard as Je}from"@backstage/core-components";import{useEntity as te,humanizeEntityRef as Xe}from"@backstage/plugin-catalog-react";import{useAutoUpdatingRelativeTime as Ye,SpotifyLicenseBanner as Ze}from"@spotify/backstage-plugin-core";import{stringifyEntityRef as re,parseEntityRef as et}from"@backstage/catalog-model";import{Alert as tt,Skeleton as f}from"@material-ui/lab";import{Link as rt}from"react-router-dom";import I from"classnames";import at from"@material-ui/icons/Schedule";import{DateTime as ae}from"luxon";import nt from"@material-ui/icons/Check";import it from"@material-ui/icons/Close";import ot from"@material-ui/icons/RemoveCircleOutline";import ct from"@material-ui/icons/HelpOutline";var ne=(e=>(e.Medal="MEDAL",e))(ne||{}),g=(e=>(e.Failed="FAILED",e.NotApplicable="NOT_APPLICABLE",e.NotReported="NOT_REPORTED",e.Passed="PASSED",e))(g||{});const st=s`
|
|
2
|
-
fragment CertificationSummary on Certification {
|
|
3
|
-
entityRef
|
|
4
|
-
program {
|
|
5
|
-
id
|
|
6
|
-
name
|
|
7
|
-
}
|
|
8
|
-
highestLevel {
|
|
9
|
-
ordinal
|
|
10
|
-
name
|
|
11
|
-
description
|
|
12
|
-
badge {
|
|
13
|
-
... on BadgeVariantMedal {
|
|
14
|
-
variant
|
|
15
|
-
options {
|
|
16
|
-
level
|
|
17
|
-
color
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
`,lt=s`
|
|
24
|
-
fragment check on Check {
|
|
25
|
-
id
|
|
26
|
-
name
|
|
27
|
-
description
|
|
28
|
-
}
|
|
29
|
-
`,mt=s`
|
|
30
|
-
fragment level on Level {
|
|
31
|
-
ordinal
|
|
32
|
-
name
|
|
33
|
-
description
|
|
34
|
-
checks {
|
|
35
|
-
...check
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
${lt}`,dt=s`
|
|
39
|
-
fragment CheckResultSummary on CheckResult {
|
|
40
|
-
id
|
|
41
|
-
name
|
|
42
|
-
result
|
|
43
|
-
timestamp
|
|
44
|
-
}
|
|
45
|
-
`,ut=s`
|
|
46
|
-
fragment LevelResultDetails on LevelResult {
|
|
47
|
-
ordinal
|
|
48
|
-
name
|
|
49
|
-
description
|
|
50
|
-
badge {
|
|
51
|
-
... on BadgeVariantMedal {
|
|
52
|
-
variant
|
|
53
|
-
options {
|
|
54
|
-
level
|
|
55
|
-
color
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
certified
|
|
60
|
-
checks {
|
|
61
|
-
...CheckResultSummary
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
${dt}`,pt=s`
|
|
65
|
-
fragment CheckResultDetails on CheckResult {
|
|
66
|
-
id
|
|
67
|
-
name
|
|
68
|
-
description
|
|
69
|
-
result
|
|
70
|
-
timestamp
|
|
71
|
-
notes
|
|
72
|
-
}
|
|
73
|
-
`,ht=s`
|
|
74
|
-
fragment OverviewLevelResult on OverviewLevelResult {
|
|
75
|
-
ordinal
|
|
76
|
-
name
|
|
77
|
-
checks {
|
|
78
|
-
check {
|
|
79
|
-
id
|
|
80
|
-
name
|
|
81
|
-
description
|
|
82
|
-
}
|
|
83
|
-
results {
|
|
84
|
-
id
|
|
85
|
-
entityRef
|
|
86
|
-
result
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
`,ie=s`
|
|
91
|
-
fragment HighestLevel on LevelResult {
|
|
92
|
-
entityRef
|
|
93
|
-
ordinal
|
|
94
|
-
name
|
|
95
|
-
badge {
|
|
96
|
-
... on BadgeVariantMedal {
|
|
97
|
-
variant
|
|
98
|
-
options {
|
|
99
|
-
color
|
|
100
|
-
level
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
`,gt=s`
|
|
106
|
-
mutation createCheck($input: CheckerInput!) {
|
|
107
|
-
check: createChecker(input: $input) {
|
|
108
|
-
id
|
|
109
|
-
filter
|
|
110
|
-
name
|
|
111
|
-
description
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
`,ft=s`
|
|
115
|
-
mutation createProgram($input: ProgramInput!) {
|
|
116
|
-
program: createProgram(input: $input) {
|
|
117
|
-
id
|
|
118
|
-
ownerEntityRef
|
|
119
|
-
name
|
|
120
|
-
description
|
|
121
|
-
documentationURL
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
`,kt=s`
|
|
125
|
-
mutation deleteChecker($checkerId: String!) {
|
|
126
|
-
deleteChecker(checkerId: $checkerId)
|
|
127
|
-
}
|
|
128
|
-
`,yt=s`
|
|
129
|
-
mutation deleteProgram($programId: String!) {
|
|
130
|
-
programDeleted: deleteProgram(programId: $programId)
|
|
131
|
-
}
|
|
132
|
-
`,vt=s`
|
|
133
|
-
mutation updateCheck($input: CheckerInput!) {
|
|
134
|
-
check: updateChecker(input: $input) {
|
|
135
|
-
id
|
|
136
|
-
filter
|
|
137
|
-
name
|
|
138
|
-
description
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
`,Ct=s`
|
|
142
|
-
mutation updateProgram($input: ProgramInput!) {
|
|
143
|
-
program: updateProgram(input: $input) {
|
|
144
|
-
id
|
|
145
|
-
ownerEntityRef
|
|
146
|
-
name
|
|
147
|
-
description
|
|
148
|
-
documentationURL
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
`,Et=s`
|
|
152
|
-
query getAllCertifications($entityRef: String!) {
|
|
153
|
-
certifications(entityRef: $entityRef, includeFilteredChecks: false) {
|
|
154
|
-
...CertificationSummary
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
${st}`,wt=s`
|
|
158
|
-
query getAllPrograms($programIds: [String!], $first: Int, $after: String) {
|
|
159
|
-
programs(programIds: $programIds, first: $first, after: $after) {
|
|
160
|
-
totalCount
|
|
161
|
-
endCursor
|
|
162
|
-
hasNextPage
|
|
163
|
-
edges {
|
|
164
|
-
cursor
|
|
165
|
-
program {
|
|
166
|
-
id
|
|
167
|
-
ownerEntityRef
|
|
168
|
-
name
|
|
169
|
-
description
|
|
170
|
-
documentationURL
|
|
171
|
-
filter
|
|
172
|
-
levels {
|
|
173
|
-
...level
|
|
174
|
-
}
|
|
175
|
-
isEditable
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
${mt}`,Rt=s`
|
|
181
|
-
query getCertificationDetails($entityRef: String!, $programId: String!) {
|
|
182
|
-
programCertification(
|
|
183
|
-
entityRef: $entityRef
|
|
184
|
-
programId: $programId
|
|
185
|
-
includeFilteredChecks: false
|
|
186
|
-
) {
|
|
187
|
-
program {
|
|
188
|
-
id
|
|
189
|
-
name
|
|
190
|
-
description
|
|
191
|
-
documentationURL
|
|
192
|
-
}
|
|
193
|
-
highestLevel {
|
|
194
|
-
...HighestLevel
|
|
195
|
-
}
|
|
196
|
-
levels {
|
|
197
|
-
...LevelResultDetails
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
${ie}
|
|
202
|
-
${ut}`,bt=s`
|
|
203
|
-
query getCheckResultDetails($entityRef: String!, $programId: String!, $checkId: String!) {
|
|
204
|
-
checkResult(entityRef: $entityRef, programId: $programId, checkId: $checkId) {
|
|
205
|
-
...CheckResultDetails
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
${pt}`,St=s`
|
|
209
|
-
query getCheckers($ids: [String!], $first: Int, $after: String, $orderAlphabetical: String, $searchByOwner: String, $searchByName: String) {
|
|
210
|
-
checkers(
|
|
211
|
-
ids: $ids
|
|
212
|
-
first: $first
|
|
213
|
-
after: $after
|
|
214
|
-
orderAlphabetical: $orderAlphabetical
|
|
215
|
-
searchByOwner: $searchByOwner
|
|
216
|
-
searchByName: $searchByName
|
|
217
|
-
) {
|
|
218
|
-
totalCount
|
|
219
|
-
endCursor
|
|
220
|
-
hasNextPage
|
|
221
|
-
edges {
|
|
222
|
-
cursor
|
|
223
|
-
checker {
|
|
224
|
-
id
|
|
225
|
-
ownerEntityRef
|
|
226
|
-
supportChannel
|
|
227
|
-
name
|
|
228
|
-
description
|
|
229
|
-
rule
|
|
230
|
-
passedMessage
|
|
231
|
-
failedMessage
|
|
232
|
-
filter
|
|
233
|
-
isEditable
|
|
234
|
-
schedule
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
`,$t=s`
|
|
240
|
-
query getFacetsForOwner($ownerEntityRef: String!) {
|
|
241
|
-
facetsForOwner(ownerEntityRef: $ownerEntityRef) {
|
|
242
|
-
types {
|
|
243
|
-
kind
|
|
244
|
-
type
|
|
245
|
-
count
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
`,Pt=s`
|
|
250
|
-
query getCollectors($ids: [String!]) {
|
|
251
|
-
collectors(ids: $ids) {
|
|
252
|
-
id
|
|
253
|
-
factNames
|
|
254
|
-
collectionConfigs {
|
|
255
|
-
factRefs
|
|
256
|
-
filter
|
|
257
|
-
frequency
|
|
258
|
-
cache {
|
|
259
|
-
... on HumanDuration {
|
|
260
|
-
years
|
|
261
|
-
months
|
|
262
|
-
weeks
|
|
263
|
-
days
|
|
264
|
-
hours
|
|
265
|
-
minutes
|
|
266
|
-
seconds
|
|
267
|
-
milliseconds
|
|
268
|
-
}
|
|
269
|
-
... on CacheBoolean {
|
|
270
|
-
cache
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
`,Nt=s`
|
|
277
|
-
query getFactSchemas($collectorId: String!, $factName: String!) {
|
|
278
|
-
factSchema(collectorId: $collectorId, factName: $factName) {
|
|
279
|
-
schema
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
`,It=s`
|
|
283
|
-
query getProgramOverviewForOwner($ownerEntityRef: String!, $facet: FacetInput) {
|
|
284
|
-
programOverviewForOwner(
|
|
285
|
-
ownerEntityRef: $ownerEntityRef
|
|
286
|
-
facet: $facet
|
|
287
|
-
includeFilteredChecks: false
|
|
288
|
-
) {
|
|
289
|
-
programs {
|
|
290
|
-
program {
|
|
291
|
-
id
|
|
292
|
-
name
|
|
293
|
-
}
|
|
294
|
-
highestLevels {
|
|
295
|
-
...HighestLevel
|
|
296
|
-
}
|
|
297
|
-
levels {
|
|
298
|
-
...OverviewLevelResult
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
entityRefs
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
${ie}
|
|
305
|
-
${ht}`,Dt=(e,t,r)=>e();function Ft(e,t=Dt){return{createCheck(r,n){return t(i=>e.request(gt,r,{...n,...i}),"createCheck","mutation")},createProgram(r,n){return t(i=>e.request(ft,r,{...n,...i}),"createProgram","mutation")},deleteChecker(r,n){return t(i=>e.request(kt,r,{...n,...i}),"deleteChecker","mutation")},deleteProgram(r,n){return t(i=>e.request(yt,r,{...n,...i}),"deleteProgram","mutation")},updateCheck(r,n){return t(i=>e.request(vt,r,{...n,...i}),"updateCheck","mutation")},updateProgram(r,n){return t(i=>e.request(Ct,r,{...n,...i}),"updateProgram","mutation")},getAllCertifications(r,n){return t(i=>e.request(Et,r,{...n,...i}),"getAllCertifications","query")},getAllPrograms(r,n){return t(i=>e.request(wt,r,{...n,...i}),"getAllPrograms","query")},getCertificationDetails(r,n){return t(i=>e.request(Rt,r,{...n,...i}),"getCertificationDetails","query")},getCheckResultDetails(r,n){return t(i=>e.request(bt,r,{...n,...i}),"getCheckResultDetails","query")},getCheckers(r,n){return t(i=>e.request(St,r,{...n,...i}),"getCheckers","query")},getFacetsForOwner(r,n){return t(i=>e.request($t,r,{...n,...i}),"getFacetsForOwner","query")},getCollectors(r,n){return t(i=>e.request(Pt,r,{...n,...i}),"getCollectors","query")},getFactSchemas(r,n){return t(i=>e.request(Nt,r,{...n,...i}),"getFactSchemas","query")},getProgramOverviewForOwner(r,n){return t(i=>e.request(It,r,{...n,...i}),"getProgramOverviewForOwner","query")}}}var oe=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},o=(e,t,r)=>(oe(e,t,"read from private field"),r?r.call(e):t.get(e)),R=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},M=(e,t,r,n)=>(oe(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),D,F,m,z,d;const L=Fe({id:"plugin.soundcheck"}),Lt=e=>"response"in e&&"errors"in e.response,At=e=>"response"in e&&"message"in e.response;class xt{constructor(t){R(this,D,void 0),R(this,F,void 0),R(this,m,void 0),R(this,z,n=>{var i,c,l;return Lt(n)?(l=(c=(i=n.response)==null?void 0:i.errors)==null?void 0:c[0].message)!=null?l:`${n}`:At(n)?n.response.message:`${n}`}),R(this,d,async n=>{try{return await n()}catch(i){throw new Error(`Error from Soundcheck backend: ${o(this,z).call(this,i)}`)}}),M(this,D,t.fetchApi),M(this,F,t.discoveryApi);const r=new Be("/graphql",{fetch:async(n,i)=>{const c=`${await o(this,F).getBaseUrl("soundcheck")}${n}`;return o(this,D).fetch(c,i)}});M(this,m,Ft(r))}async getAllCertifications(t){return o(this,d).call(this,async()=>{const{certifications:r}=await o(this,m).getAllCertifications({entityRef:t});return r})}async getCertificationDetails(t,r){return o(this,d).call(this,async()=>{const{programCertification:n}=await o(this,m).getCertificationDetails({entityRef:t,programId:r});return n})}async getCheckResultDetails(t,r,n){return o(this,d).call(this,async()=>{const{checkResult:i}=await o(this,m).getCheckResultDetails({entityRef:t,programId:r,checkId:n});return i})}async getFacetsForOwner(t){return o(this,d).call(this,async()=>{const{facetsForOwner:r}=await o(this,m).getFacetsForOwner({ownerEntityRef:t});return r})}async getProgramOverviewForOwner(t,r){return o(this,d).call(this,async()=>{const{programOverviewForOwner:n}=await o(this,m).getProgramOverviewForOwner({ownerEntityRef:t,facet:r});return n})}async getAllPrograms(t,r,n){return o(this,d).call(this,async()=>{const{programs:i}=await o(this,m).getAllPrograms({programIds:t,first:r,after:n});return i})}async createProgram(t){return o(this,d).call(this,async()=>{const{program:r}=await o(this,m).createProgram({input:t});return r})}async updateProgram(t){return o(this,d).call(this,async()=>{const{program:r}=await o(this,m).updateProgram({input:t});return r})}async deleteProgram(t){return o(this,d).call(this,async()=>{const{programDeleted:r}=await o(this,m).deleteProgram({programId:t});return r})}async getChecks(t,r,n){return o(this,d).call(this,async()=>{const{checkers:i}=await o(this,m).getCheckers({ids:t,first:r,after:n});return i})}async createCheck(t){return o(this,d).call(this,async()=>{const{check:r}=await o(this,m).createCheck({input:t});return r})}async updateCheck(t){return o(this,d).call(this,async()=>{const{check:r}=await o(this,m).updateCheck({input:t});return r})}async deleteCheck(t){return o(this,d).call(this,async()=>await o(this,m).deleteChecker({checkerId:t}))}async getCollectors(t){return o(this,d).call(this,async()=>{const{collectors:r}=await o(this,m).getCollectors({ids:t});return r})}async getFactSchema(t,r){if(!(!t||!r))return o(this,d).call(this,async()=>{const{factSchema:n}=await o(this,m).getFactSchemas({collectorId:t,factName:r});return n})}}D=new WeakMap,F=new WeakMap,m=new WeakMap,z=new WeakMap,d=new WeakMap;const A=S({id:"soundcheck-entity"}),Ot=S({id:"soundcheck-group"}),ce=C({id:"soundcheck-entity-certification-track-redirect",parent:A,path:"/:trackId"}),se=C({id:"soundcheck-entity-certification",parent:A,path:"/:trackId/:checkId"}),qt=S({id:"soundcheck-overview"}),x=S({id:"soundcheck"});C({id:"soundcheck-checks",parent:x,path:"/checks"}),C({id:"soundcheck-tracks",parent:x,path:"/tracks"}),C({id:"soundcheck-track-details",parent:x,path:"/tracks/:trackId"});const y=Le({id:"soundcheck",apis:[Ae({api:L,deps:{discoveryApi:xe,fetchApi:Oe},factory:e=>new xt(e)})],routes:{entityContent:A}}),Tt=y.provide($({name:"EntitySoundcheckContent",component:()=>import("./EntitySoundcheckContent-ac967308.esm.js").then(e=>e.EntitySoundcheckContent),mountPoint:A})),Bt=y.provide(qe({name:"EntitySoundcheckCard",component:{lazy:()=>import("./index-39051bf4.esm.js").then(e=>e.EntitySoundcheckCard)}})),Mt=y.provide($({name:"GroupSoundcheckContent",component:()=>import("./index-d27c0b4b.esm.js").then(e=>e.FixedGroupOverviewPage),mountPoint:Ot})),zt=y.provide($({name:"SoundcheckOverviewPage",component:()=>import("./index-d27c0b4b.esm.js").then(e=>e.OverviewPage),mountPoint:qt})),Gt=y.provide($({name:"SoundcheckRoutingPage",component:()=>import("./index-ee6cc5f1.esm.js").then(e=>e.RoutingPage),mountPoint:x})),Ut=He(e=>new Ue({defaultOptions:{queries:{refetchInterval:6e4,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",retry:2,retryDelay:t=>{const r=450+Math.ceil(Math.random()*100);return Math.min(r*2**t,3e4)},onError:t=>e.post(t)}}})),Wt=e=>{const t=B(Te),r=Ut(t);return a.createElement(We,{client:r},e.children)};function le(e){const t=B(L),r=re(e);return _(["soundcheck/certifications",r],async()=>t.getAllCertifications(r))}function me(e,t){const r=B(L),n=re(e);return _(["soundcheck/certifications",n,t],async()=>r.getCertificationDetails(n,t),{enabled:!!t})}var de=(e=>(e.GetAllPrograms="soundcheck/programs",e.GetChecks="soundcheck/checks",e.GetCollectors="soundcheck/collectors",e.GetFactSchema="soundcheck/collectors/schema",e.GetEntityFacets="soundcheck/catalog/facets",e))(de||{}),ue=(e=>(e.DeleteCheck="soundcheck/deleteCheck",e.CreateCheck="soundcheck/createCheck",e.UpdateCheck="soundcheck/updateCheck",e.DeleteProgram="soundcheck/deleteProgram",e.CreateProgram="soundcheck/createProgram",e.UpdateProgram="soundcheck/updateProgram",e))(ue||{});const Ht=p(e=>({root:{padding:e.spacing(3)},icon:{display:"none"},message:{padding:0},type:{fontWeight:700,lineHeight:1.75}})),O=e=>{const{type:t,...r}=Ht();return a.createElement(tt,{severity:e.severity,elevation:1,classes:r,onClose:e.onClose},a.createElement(u,{classes:{root:t}},e.title),e.children)},pe=V({}),Qt=e=>{const[t,r]=P(),n=E(c=>{r(c)},[]),i=E(()=>{r(null)},[]);return a.createElement(pe.Provider,{value:{showAlert:n,clearAlert:i}},t&&a.createElement(O,{severity:t.severity,title:t.title,onClose:i},t.message),e.children)},jt=()=>K(pe),Vt=p(e=>({modalContent:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",padding:"25px",backgroundColor:e.palette.type==="dark"?e.palette.grey[800]:e.palette.grey[200]},modalButtons:{display:"flex",justifyContent:"space-evenly","& button":{width:"40%",maxWidth:"185px"}},modalMessage:{margin:"15px 0 35px"}})),he=V({}),Kt=e=>{const t=Vt(),[r,n]=P(!1),[i,c]=P(),l=Me(),h=E(({title:b,message:Ne,error:Ie})=>(c({title:b,message:Ne,error:Ie}),n(!0),new Promise(De=>{l.current=De})),[]),v=E(()=>{l.current&&l.current(!0),n(!1)},[]),k=E(()=>{l.current&&l.current(!1),n(!1)},[]);return a.createElement(he.Provider,{value:{showModal:h}},e.children,i&&a.createElement(je,{open:r,onClose:k,"aria-labelledby":"confirmation-modal-title","aria-describedby":"confirmation-modal-description"},a.createElement(J,{className:t.modalContent},a.createElement(u,{id:"confirmation-modal-title",variant:"h6"},i.title),a.createElement(u,{className:t.modalMessage,id:"confirmation-modal-description",variant:"body1"},i.message),a.createElement("div",{className:t.modalButtons},!i.error&&a.createElement(X,{onClick:k,variant:"contained","aria-label":"cancel"},"Cancel"),a.createElement(X,{color:"primary",onClick:v,variant:"contained","aria-label":"confirm"},i.error?"Ok":"Confirm")))))},_t=()=>K(he),ge=24,Jt=11,G=e=>e==="small"?1:2,Xt=p({root:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",borderWidth:"2px",fontWeight:700,width:({size:e})=>`${ge*G(e)}px`,height:({size:e})=>`${ge*G(e)}px`,fontSize:({size:e})=>`${Jt*G(e)}px`}}),fe=({className:e,label:t,size:r="small"})=>{const n=Xt({size:r});return a.createElement("span",{className:I(e,n.root),role:"img","aria-label":`${t} badge`},t)},Yt=p(e=>({root:{background:({color:t})=>t,color:e.palette.common.black,borderColor:e.palette.common.black,borderStyle:"solid","&::after":{position:"absolute",display:"block",content:'""',top:0,left:0,width:"100%",height:"100%",borderRadius:"50%",boxShadow:["inset 0 -0.18em 0 0 rgba(0, 0, 0, 0.25)","inset 0px 0.18em 0px 0px rgba(255, 255, 255, 0.5)","inset 0px 1.3em 0px -0.5em rgba(255, 255, 255, 0.2)"].join(",")}}})),U=({className:e,badge:t,size:r="small"})=>{const n=Yt({color:t.options.color,size:r});return a.createElement(fe,{className:I(e,n.root),size:r,label:`L${t.options.level}`})},Zt=p({root:{borderColor:"currentColor",borderStyle:"dashed"}}),ke=({className:e,size:t="small"})=>{const r=Zt();return a.createElement(fe,{className:I(e,r.root),size:t,label:"NL"})},W=p(e=>({description:{padding:0,margin:0,display:"block","& p":{margin:0}},root:{padding:e.spacing(2),margin:0,display:"grid",gridTemplateColumns:"min-content auto",gridGap:e.spacing(2)},title:{fontSize:e.typography.pxToRem(18),fontWeight:700,lineHeight:1.235,marginBottom:"6px"},level:{textTransform:"uppercase",color:e.palette.text.secondary,fontWeight:700,letterSpacing:"1px"}}));function er({description:e,documentationUrl:t}){const r=W();return t?a.createElement("div",{className:r.description},a.createElement(Y,{content:e}),a.createElement(Z,{to:t},"Learn more")):a.createElement("div",{className:r.description},a.createElement(Y,{content:e}))}const ye=({name:e,level:t,badge:r,description:n,documentationUrl:i})=>{const c=W();return a.createElement("div",{className:c.root},r?a.createElement(U,{size:"large",badge:r}):a.createElement(ke,{size:"large"}),a.createElement("div",null,a.createElement(u,{variant:"caption",className:c.level},t!=null?t:"No Level"),a.createElement(u,{className:c.title},e),n&&a.createElement(er,{description:n,documentationUrl:i})))},q=({children:e})=>{const[t,r]=P(!1);return ze(()=>{const n=setTimeout(()=>{r(!0)},250);return()=>clearTimeout(n)},[]),a.createElement(Ve,{in:t,timeout:250},e)},H=({hideDescription:e=!1})=>{const t=W();return a.createElement(q,null,a.createElement("div",{className:t.root},a.createElement(f,{width:44,height:44}),a.createElement("div",null,a.createElement(u,{variant:"caption",className:t.level},a.createElement(f,{width:100})),a.createElement(u,{variant:"h4",className:t.title},a.createElement(f,{width:300})),!e&&a.createElement(u,{variant:"body2"},a.createElement(f,null)))))},ve=p(e=>{const t=e.palette.type==="dark"?e.palette.grey[700]:e.palette.grey[100];return{wrapper:{backgroundColor:t,color:w(e.palette.getContrastText(t),.8),fontSize:e.typography.caption.fontSize,minHeight:"auto",borderTop:`1px solid ${e.palette.divider}`,borderBottom:`1px solid ${e.palette.divider}`,padding:e.spacing(1),display:"grid",gridTemplateAreas:({badge:r})=>[`"${r?"badge":"title"} title"`,`"${r?".":"description"} description"`].join(" "),gridTemplateColumns:"auto 1fr"},title:{gridArea:"title",textTransform:"uppercase",fontWeight:"bold",color:w(e.palette.getContrastText(t),.8),fontSize:e.typography.body2.fontSize,paddingTop:e.spacing(.5),paddingBottom:e.spacing(.5),lineHeight:1},badge:{gridArea:"badge",marginRight:e.spacing(1)},description:{gridArea:"description",color:w(e.palette.getContrastText(t),.8),fontSize:e.typography.subtitle2.fontSize,marginTop:e.spacing(1)}}}),tr=e=>{const t=ve({badge:e.badge});return a.createElement("div",{className:t.wrapper},e.badge?a.createElement(U,{className:t.badge,badge:e.badge}):null,a.createElement(u,{className:t.title},e.title),e.description?a.createElement(u,{className:t.description},e.description):null)},rr=()=>{const e=ve({});return a.createElement(q,null,a.createElement("div",{className:e.wrapper},a.createElement(f,{className:e.title}),a.createElement(u,{className:e.description},a.createElement(f,null))))},ar=p(e=>({root:{display:"inline-flex",alignItems:"center",gap:e.spacing(1)}})),Ce=({timestamp:e,description:t})=>{const r=ar(),n=ae.fromISO(e).toLocaleString(ae.DATETIME_FULL),i=Ye(e),c=t?`${t}: ${i}`:void 0;return a.createElement("div",{className:r.root},a.createElement(Ke,{title:n},a.createElement(u,{variant:"caption","aria-label":c},i)),a.createElement(at,null))},nr=e=>({[g.Passed]:"Check passed",[g.NotReported]:"Check not reported",[g.Failed]:"Check failed",[g.NotApplicable]:"Check not applicable"})[e],ir=N(e=>({root:{color:e.palette.success.main}}))(nt),or=N(e=>({root:{color:e.palette.error.main}}))(it),cr=N(e=>({root:{color:e.palette.info.main}}))(ct),sr=N(e=>({root:{color:e.palette.text.disabled}}))(ot),Ee=({result:e,className:t})=>{const r={className:t,"aria-label":nr(e),"aria-hidden":!1};return e===g.Passed?a.createElement(ir,{...r}):e===g.NotReported?a.createElement(cr,{...r}):e===g.Failed?a.createElement(or,{...r}):e===g.NotApplicable?a.createElement(sr,{...r}):null},we=p(e=>({root:{display:"grid",width:"100%",gridTemplateColumns:"auto 1fr auto",gridColumnGap:e.spacing(1),padding:e.spacing(1),alignItems:"center","&.selected":{backgroundColor:w(e.palette.primary[e.palette.type],.2)},"&:hover, &:active, &:focus":{backgroundColor:w(e.palette.primary[e.palette.type],.3)}}})),lr=({className:e,href:t,children:r})=>t?a.createElement(rt,{to:t,className:e},r):a.createElement("div",{className:e},r),mr=({result:e,name:t,timestamp:r,selected:n=!1,href:i})=>{const c=we(),l=I(c.root,{selected:n});return a.createElement(lr,{href:i,className:l},a.createElement(Ee,{result:e}),a.createElement(u,{variant:"body2"},t),r?a.createElement(Ce,{timestamp:r}):null)},Q=()=>{const e=we();return a.createElement(q,null,a.createElement("div",{className:e.root},a.createElement(f,{width:24,height:24}),a.createElement(u,{variant:"body2"},a.createElement(f,null)),a.createElement(f,{width:100,height:24})))},dr=()=>{const e=Re();return a.createElement("div",{className:e.root},a.createElement(H,null),new Array(3).fill(null).map((t,r)=>a.createElement(a.Fragment,{key:`skeleton-level-${r}`},a.createElement(rr,null),a.createElement("ul",{className:e.checks},a.createElement(Q,null),a.createElement(Q,null),a.createElement(Q,null)))))},ur=p(e=>({noChecks:{padding:e.spacing(1)},checks:{padding:0,margin:0,flex:1,listStyle:"none"},checkItem:{borderBottom:`1px solid ${e.palette.divider}`,"&:last-of-type":{borderBottom:"0"}}})),pr=({checks:e,trackId:t,checkId:r})=>{const n=ur(),i=j(se);return e.length?a.createElement("ul",{className:n.checks},e.map(c=>a.createElement("li",{key:c.id,className:n.checkItem},a.createElement(mr,{...c,selected:c.id===r,href:i({trackId:t,checkId:c.id})})))):a.createElement(u,{variant:"body2",className:n.noChecks},"No applicable checks at this level.")},hr=({level:e,checkId:t,trackId:r})=>{var n;return a.createElement(a.Fragment,null,a.createElement(tr,{badge:e.badge,title:e.name,description:e.description}),a.createElement(pr,{checks:(n=e.checks)!=null?n:[],trackId:r,checkId:t}))},Re=p(e=>({root:{borderRight:`1px solid ${e.palette.divider}`},checks:{padding:0,margin:0,flex:1,listStyle:"none"}})),gr=({trackId:e,checkId:t})=>{var r,n;const i=Re(),{entity:c}=te(),{data:l,isLoading:h,isError:v}=me(c,e);return v?a.createElement("div",{className:i.root},a.createElement(J,{padding:2},a.createElement(O,{severity:"error",title:"Error loading certification"}))):h||!e?a.createElement(dr,null):l?a.createElement("div",{className:i.root},a.createElement(ye,{name:l.program.name,level:(r=l.highestLevel)==null?void 0:r.name,badge:(n=l.highestLevel)==null?void 0:n.badge,description:l.program.description,documentationUrl:l.program.documentationURL}),l==null?void 0:l.levels.map(k=>a.createElement(hr,{key:k.ordinal,level:k,checkId:t,trackId:e}))):null},fr=()=>a.createElement(a.Fragment,null,a.createElement(H,{hideDescription:!0}),a.createElement(H,{hideDescription:!0})),be=({className:e,description:t="There are no tracks configured that apply to this entity."})=>a.createElement("div",{className:e},a.createElement(ee,{title:"No certifications available",missing:"data",description:t})),kr=({ownerEntityRef:e})=>e?a.createElement(ee,{missing:"data",title:"Missing entities",description:a.createElement(a.Fragment,null,"Looks like the group"," ",Xe(et(e),{defaultKind:"Group"})," ","doesn't own any entities.",a.createElement("br",null),a.createElement("br",null),"Please select another group from the dropdown in the corner of the header.")}):null,Se="soundcheck",$e="Submitted check results will still be stored, but it will not be possible to view certifications or individual results until a valid license is present.",Pe=Qe(e=>({certificationWrapper:{display:"flex",justifyContent:"space-between",alignItems:"center"},infoCard:{display:"grid",gridRowGap:e.spacing(2)},emptyState:{"& > div":{backgroundColor:e.palette.background.paper}}})),T=({children:e,title:t})=>{const r=Pe();return a.createElement(Je,{title:t},a.createElement("div",{className:r.infoCard},a.createElement(Ze,{inline:!0,backend:Se,invalidLicenseMessage:$e}),e))},yr=({title:e="Soundcheck"})=>{const{entity:t}=te(),r=Pe(),{data:n,isError:i,isLoading:c}=le(t),l=j(ce);return i?a.createElement(T,{title:e},a.createElement(O,{severity:"error",title:"Error loading certifications"})):c||!n?a.createElement(T,{title:e},a.createElement(fr,null)):n.length===0?a.createElement(T,{title:e},a.createElement(be,{className:r.emptyState})):a.createElement(T,{title:e},n.map((h,v)=>{var k,b;return a.createElement(Ge,{key:h.program.name},a.createElement("div",{className:r.certificationWrapper,"data-testid":"soundcheck-track-row"},a.createElement(ye,{key:h.program.id,name:h.program.name,badge:(k=h.highestLevel)==null?void 0:k.badge,level:(b=h.highestLevel)==null?void 0:b.name}),a.createElement(Z,{to:l({trackId:h.program.id})},"View Details")),v<n.length-1?a.createElement(_e,null):null)}))};export{O as A,ne as B,gr as C,Tt as E,q as F,Mt as G,U as L,ue as M,ke as N,de as Q,g as R,Wt as S,Ce as a,le as b,ce as c,be as d,Se as e,se as f,yr as g,Ee as h,$e as i,kr as j,jt as k,_t as l,Qt as m,y as n,Bt as o,zt as p,Gt as q,L as s,me as u,Kt as w};
|
|
306
|
-
//# sourceMappingURL=index-094c5781.esm.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import t,{useState as v,useEffect as D,useCallback as G,createContext as $e,useContext as Me,useMemo as j,useReducer as we}from"react";import{useSearchParams as Ve,useLocation as Ft,Routes as $t,Route as Mt}from"react-router-dom";import{MarkdownContent as Vt,Link as Bt,DismissableBanner as Gt,Page as zt,Header as Wt,TabbedLayout as fe}from"@backstage/core-components";import{SpotifyLicenseBanner as qt}from"@spotify/backstage-plugin-core";import{Box as I,Paper as Ne,Grid as u,Button as A,Slide as Kt,Dialog as Ut,AppBar as Ht,Toolbar as jt,Typography as C,IconButton as he,TextField as z,Collapse as _t,makeStyles as k,ButtonGroup as Be,Menu as Ge,MenuItem as ye,FormControl as Qt,InputLabel as Jt,Select as Yt,FormControlLabel as Zt,Checkbox as Xt,Card as Le,ListItemIcon as Y,ListItemText as _,withStyles as ze,CardContent as We,CardHeader as ea,Divider as ta,CardActions as aa,List as be,ListItem as Z,Tooltip as X,InputAdornment as qe,NativeSelect as Se,Chip as Pe,CircularProgress as na}from"@material-ui/core";import{makeStyles as ee,createStyles as Ke}from"@material-ui/core/styles";import{a as ra,b as Ue,u as la,U as oa,G as sa,O as ia}from"./OverviewPageContent-cee8c2bb.esm.js";import He from"@material-ui/icons/Close";import{Controller as Ee,useWatch as je,useForm as ca}from"react-hook-form";import da from"@material-ui/icons/AddCircleOutline";import ma from"@material-ui/icons/ArrowDropDown";import _e from"@material-ui/icons/Delete";import{useApi as R,alertApiRef as pa}from"@backstage/core-plugin-api";import{useQuery as te,useQueryClient as ae,useMutation as ne}from"@tanstack/react-query";import{s as M,Q as F,k as Q,M as re,l as Ce,m as ua,S as ga,w as ha}from"./index-094c5781.esm.js";import{asArray as Ea,parseFactRef as Te,stringifyFactRef as va,soundcheckCheckUpdatePermission as fa,soundcheckCheckDeletePermission as ya,soundcheckCheckCreatePermission as ba,soundcheckTrackUpdatePermission as Ca,soundcheckTrackDeletePermission as ka,soundcheckTrackCreatePermission as xa}from"@spotify/backstage-plugin-soundcheck-common";import{Autocomplete as Qe,Skeleton as Je}from"@material-ui/lab";import wa from"@material-ui/icons/CheckBox";import Na from"@material-ui/icons/CheckBoxOutlineBlank";import La from"@material-ui/icons/ExpandMore";import{catalogApiRef as Sa,EntityRefLink as Ye}from"@backstage/plugin-catalog-react";import"@backstage/catalog-model";import{v4 as Ze}from"uuid";import Pa from"@material-ui/icons/MoreVert";import Xe from"@material-ui/icons/Group";import{usePermission as le}from"@backstage/plugin-permission-react";import Ta from"@material-ui/icons/Search";import{useDrag as Da,useDrop as Ia,DndProvider as Aa}from"react-dnd";import{HTML5Backend as Ra}from"react-dnd-html5-backend";import Oa from"@material-ui/icons/OpenInNew";import Fa from"@material-ui/icons/DoneAllRounded";import $a from"@material-ui/icons/Menu";import et from"@material-ui/icons/DragIndicator";import Ma from"@material-ui/icons/Visibility";import Va from"@material-ui/icons/Add";import Ba from"@material-ui/icons/Remove";import"@material-ui/lab/Autocomplete";import"react-use/lib/useAsync";import"./RefetchingIndicator-50e5cc94.esm.js";import"react-use/lib/useDebounce";import"lodash";import"react-window";import"graphql-request";import"graphql-tag";import"@material-ui/core/styles/makeStyles";import"classnames";import"@material-ui/icons/Schedule";import"luxon";import"@material-ui/icons/Check";import"@material-ui/icons/RemoveCircleOutline";import"@material-ui/icons/HelpOutline";function Ga(e,n,a){const r=R(M);return te([F.GetAllPrograms,e,n,a],async()=>r.getAllPrograms(e,n,a))}function za(e){const n=R(M);return te([F.GetAllPrograms,e],async()=>n.getAllPrograms([e]))}const Wa="Error Creating Track";function qa(){const e=R(M),n=ae(),{showAlert:a}=Q(),r=async l=>{const o=await e.createProgram(l);if(!o)throw new Error("Failed to create track.");return o};return ne([re.CreateProgram],r,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[F.GetAllPrograms]})},onError:l=>{let o="Failed to create track.";l instanceof Error&&(o=l.message),a({severity:"error",title:Wa,message:o})}})}function tt(e,n,a){const r=R(M);return te([F.GetChecks,e,n,a],async()=>r.getChecks(e,n,a))}const Ka=e=>{const[n,a]=v(void 0),[r,l]=v([[]]),[o,s]=v([!1]);D(()=>{n===void 0&&e!=null&&e.length&&a(e)},[e,n]);const c=G((h,g)=>{l(E=>{const f=[...E];return f[g]=[...f[g],h],f}),a(E=>E==null?void 0:E.filter(f=>f.id!==h.id)),s(E=>{if(E[g]){const f=[...E];return f[g]=!1,f}return E})},[]),d=G((h,g)=>{l(E=>{const f=[...E];return f[g]=f[g].filter(x=>x.id!==h.id),f}),a(E=>[...E!=null?E:[],h])},[]),m=G(()=>{l(h=>[...h,[]]),s(h=>[...h,!1])},[]),p=G(h=>{r.length>1&&l(g=>{const E=[...g],f=E.splice(h,1)[0];return a(x=>[...x!=null?x:[],...f]),E})},[r]),i=G(()=>{const h=r.map(g=>g.length===0);return s(h),!h.some(g=>g)},[r]);return{chips:n,inputChipsList:r,handleDrop:c,handleDelete:d,addInput:m,removeInput:p,inputErrors:o,setInputErrors:s,areInputsValid:i,setInputChipsList:l}},Ua=ee(e=>({box:{zIndex:9,position:"fixed",bottom:"0",width:"100%"},footer:{padding:e.spacing(2)}})),at=({onCancel:e,saveButtonText:n,isLoading:a,onSave:r,disableSave:l})=>{const o=Ua();return t.createElement(I,{className:o.box},t.createElement(Ne,{elevation:3,className:o.footer},t.createElement(u,{container:!0,item:!0,spacing:2,justifyContent:"space-between"},t.createElement(u,{item:!0},t.createElement(A,{variant:"contained",color:"primary",onClick:e},"Cancel")),t.createElement(u,{item:!0},r&&t.createElement(A,{variant:"contained",color:"primary",disabled:a||l,onClick:r?()=>r():void 0},n)))))},nt=$e({selectedProgram:null,setSelectedProgram:()=>{},isLoading:!1,setIsLoading:()=>{},showAddModal:!1,setShowAddModal:()=>{}}),Ha=({children:e})=>{const[n,a]=v(null),[r,l]=v(!1),[o,s]=v(!1);return t.createElement(nt.Provider,{value:{selectedProgram:n,setSelectedProgram:a,isLoading:r,setIsLoading:l,showAddModal:o,setShowAddModal:s}},e)},oe=()=>Me(nt),rt=$e({selectedCheck:null,setSelectedCheck:()=>{},isLoading:!1,setIsLoading:()=>{},showAddModal:!1,setShowAddModal:()=>{},isReadOnly:!1,showReadOnlyModal:()=>{},hideModal:()=>{}}),ja=({children:e})=>{const[n,a]=v(null),[r,l]=v(!1),[o,s]=v(!1),[c,d]=v(!1),m=i=>{l(!0),a(i)},p=()=>{a(null),l(!1),d(!1)};return t.createElement(rt.Provider,{value:{selectedCheck:n,setSelectedCheck:a,isLoading:o,setIsLoading:s,showAddModal:c,setShowAddModal:d,isReadOnly:r,showReadOnlyModal:m,hideModal:p}},e)},W=()=>Me(rt),_a=ee(e=>({appBar:{position:"relative"},title:{flex:1,fontSize:e.typography.h6.fontSize},closeIcon:{marginRight:e.spacing(2)},content:{flex:"1 0 auto",padding:e.spacing(2),overflowX:"hidden",backgroundColor:e.palette.type==="dark"?"#333":e.palette.common.white}})),Qa=t.forwardRef(function(e,n){return t.createElement(Kt,{direction:"up",ref:n,...e})}),lt=({open:e,handleClose:n,title:a,children:r})=>{const l=_a();return t.createElement(Ut,{fullScreen:!0,open:e,onClose:n,TransitionComponent:Qa},t.createElement(Ht,{className:l.appBar},t.createElement(jt,null,t.createElement(C,{className:l.title},a),t.createElement(he,{edge:"end",color:"inherit",onClick:n,"aria-label":"close",className:l.closeIcon},t.createElement(He,null)))),t.createElement(I,{className:l.content},r))},ve=({name:e,control:n,error:a,label:r,placeholder:l,disabled:o,rules:s,messages:c,helperText:d,multiline:m,minRows:p})=>t.createElement(Ee,{name:e,control:n,defaultValue:"",rules:s,render:({field:i})=>t.createElement(z,{...i,fullWidth:!0,multiline:m,minRows:p,placeholder:l,label:r,disabled:o,variant:"outlined",margin:"normal",error:!!a,helperText:a&&c?c[a.type]:d})}),Ja=ee(()=>({section:{gap:0}})),Ya=({control:e,error:n,isLoading:a,disabled:r})=>{const l=Ja();return t.createElement("div",{className:l.section},t.createElement(ve,{name:"checkName",control:e,error:n,label:"Check Name",placeholder:"Choose a name",disabled:a||r,rules:{required:!0,maxLength:100},messages:{required:"This field is required",maxLength:"Input must be less than 100 characters"}}))},Za=ee(e=>({root:{display:"flex",flexDirection:"column",gap:0},button:{marginLeft:-e.spacing(1)},title:{fontWeight:700,color:e.palette.primary.main}})),ke=({title:e,children:n})=>{const[a,r]=v(!1),l=Za(),o=()=>{r(!a)};return t.createElement("div",{className:l.root},t.createElement(u,{container:!0,alignItems:"center",spacing:0},t.createElement(u,{item:!0},t.createElement(he,{onClick:o,className:l.button},t.createElement(da,null))),t.createElement(u,{item:!0},t.createElement(C,{className:l.title},e))),t.createElement(_t,{in:a},n))},Xa=({control:e,passError:n,failError:a,isLoading:r,disabled:l})=>t.createElement(ke,{title:l?"Pass and fail messages":"Pass and fail messages (optional)"},t.createElement(ve,{name:"passMessage",control:e,error:n,label:"Pass Message",placeholder:"Enter pass message...",disabled:r||l}),t.createElement(ve,{name:"failMessage",control:e,error:a,label:"Fail Message",placeholder:"Enter fail message...",disabled:r||l})),en=({control:e,error:n,isLoading:a,disabled:r})=>t.createElement(ve,{name:"description",control:e,error:n,label:"Check Description",disabled:a||r,multiline:!0,minRows:4,placeholder:r?void 0:"Enter a brief description about the check",helperText:r?void 0:"Enter a brief description about the check",rules:{required:!0,maxLength:500},messages:{required:"This field is required",maxLength:"Description must be less than 500 characters"}}),tn=k(e=>({button:{backgroundColor:e.palette.background.default,color:e.palette.primary.main},label:{paddingRight:e.spacing(2)},icon:{borderLeft:`1px solid ${e.palette.primary.main}`,padding:e.spacing(1,0,0,1)},menu:{marginTop:"52px"}})),an=({onAddCondition:e,onAddExpression:n})=>{const a=tn(),[r,l]=v(null),o=!!r,s=d=>{l(d.currentTarget)},c=()=>{l(null)};return t.createElement(I,null,t.createElement(Be,{color:"primary"},t.createElement(A,{id:"add-button",className:a.button,"aria-controls":o?"add-menu":void 0,"aria-haspopup":"true","aria-expanded":o?"true":void 0,onClick:s},t.createElement(I,{className:a.label},"Add"),t.createElement(I,{className:a.icon},t.createElement(ma,null)))),t.createElement(Ge,{id:"add-menu",anchorEl:r,open:o,onClose:c,classes:{paper:a.menu},MenuListProps:{"aria-labelledby":"add-button"}},t.createElement(ye,{onClick:()=>{e(),c()}},"Add Condition"),t.createElement(ye,{onClick:()=>{n(),c()}},"Add Expression")))},ot=({name:e,control:n,selectLabel:a,options:r,disabled:l})=>t.createElement(Ee,{name:e,control:n,render:({field:o})=>t.createElement(Qt,{variant:"outlined",style:{minWidth:200}},t.createElement(Jt,{id:`${e}-select-label`},a),t.createElement(Yt,{...o,disabled:l,"data-testid":`${e}-select`,labelId:`${e}-select-label`,label:a},r.map(({value:s,label:c})=>t.createElement(ye,{key:s,value:s},c))))});var H=(e=>(e.AllOf="all",e.AnyOf="any",e))(H||{});const nn={all:"ALL OF",any:"ANY OF"};var st=(e=>(e.Equal="equal",e.NotEqual="notEqual",e.Matches="matches",e.LessThan="lessThan",e.LessThanInclusive="lessThanInclusive",e.GreaterThan="greaterThan",e.GreaterThanInclusive="greaterThanInclusive",e.In="in",e.NotIn="notIn",e.Contains="contains",e.DoesNotContain="doesNotContain",e.SemverGt="semverGt",e.SemverGte="semverGte",e.SemverLt="semverLt",e.SemverLte="semverLte",e.SemverEq="semverEq",e.SemverNeq="semverNeq",e.SemverSatisfies="semverSatisfies",e.SemverGtr="semverGtr",e.SemverLtr="semverLtr",e))(st||{});const rn={equal:"Equals",notEqual:"Does Not Equal",matches:"Matches",semverGt:"Version Greater Than",semverGte:"Version Greater Than or Equals",semverLt:"Version Less Than",semverLte:"Version Less Than or Equals",semverEq:"Version Equals",semverNeq:"Version Not Equals",semverSatisfies:"Version Satisfies Range",semverGtr:"Version Greater Than Range",semverLtr:"Version Less Than Range",lessThan:"Less Than",lessThanInclusive:"Less Than or Equals",greaterThan:"Greater Than",greaterThanInclusive:"Greater Than or Equals",in:"In Array",notIn:"Not in Array",contains:"Contains",doesNotContain:"Does Not Contain"},ln=k(e=>({container:{borderLeft:`1px solid ${e.palette.grey[500]}`,marginLeft:e.spacing(2),padding:e.spacing(2,0,2,0),display:"flex",flexDirection:"row",alignItems:"center",gap:e.spacing(0)},connector:{borderBottom:`1px solid ${e.palette.grey[500]}`,padding:e.spacing(0),width:"15px",height:"45px"},innerContainer:{backgroundColor:e.palette.background.default,border:`1px solid ${e.palette.grey[500]}`,display:"flex",flexDirection:"column"},inputsContainer:{padding:e.spacing(2),display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:e.spacing(1)},header:{background:"linear-gradient(90deg, #007DFF 0%, #0057B2 100%)",width:"100%",height:"8px"},deleteButton:{marginLeft:e.spacing(1),width:"45px",height:"45px"},deleteIcon:{color:e.palette.type==="dark"?e.palette.background.default:e.palette.common.black}}));function on(e){const n=R(M);return te([F.GetCollectors,e],async()=>n.getCollectors(e))}function sn(e,n){const a=R(M);return te([F.GetFactSchema,e,n],()=>a.getFactSchema(e,n),{enabled:!!e&&!!n})}const cn=(e,n,a,r)=>{const l={};return r&&r.forEach(o=>{var s,c;o&&(l[o.id]={id:o.id,name:(s=o.name)!=null?s:o.id,description:(c=o.description)!=null?c:""})}),e.map((o,s)=>{const c=o.map(d=>l[d.id]);return{name:n[s],description:a[s],ordinal:s+1,checks:c}})},dn=e=>e.map(n=>n.checks.map(a=>{var r;return{id:a.id,label:(r=a.name)!=null?r:a.id}})),mn=e=>{var n;return{id:e.id,name:e.name,description:e.description||"",ownerEntityRef:e.ownerEntityRef,documentationURL:e.documentationURL||"",levels:((n=e.levels)==null?void 0:n.map(a=>({ordinal:a.ordinal,name:a.name||"",description:a.description||"",checks:a.checks.map(r=>({id:r.id,name:r.name,description:r.description}))})))||[],filter:e.filter}},De={selectedKinds:"kind",selectedTypes:"spec.type",selectedLifecycles:"spec.lifecycle",selectedOwners:"spec.owner",selectedSystems:"spec.system",selectedTags:"metadata.tags"},it=e=>!e||Object.values(e).every(n=>n.length===0)?void 0:{catalog:Object.entries(e).reduce((n,[a,r])=>{const l=De[a];return r.length>0&&(n[l]=r),n},{})},ct=e=>Object.keys(De).reduce((n,a)=>{var r,l;return n[a]=Ea((l=(r=e==null?void 0:e.catalog)==null?void 0:r[De[a]])!=null?l:[]),n},{}),pn=(e,n)=>{const a=e?dn(e.levels):[[]],r=a.flat().map(o=>o.id),l=n.filter(o=>!r.includes(o.id));return{inputChips:a,used:l}},Ie=e=>{var n,a;if(!e)return{};if(e.expressionType){const r={[e.expressionType]:(n=e.conditions)==null?void 0:n.map(l=>({factRef:l.factRef,path:l.path,operator:l.operator,value:l.value}))};return e.expression&&((a=r[e.expressionType])==null||a.push(Ie(e.expression))),r}if(e.expression)return Ie(e.expression);if(e.conditions&&e.conditions.length===1){const r=e.conditions[0];return{factRef:r.factRef,path:r.path,operator:r.operator,value:r.value}}return{}},dt=(e,n=!0)=>{if(!e)return{factRef:"",path:"",operator:"",value:"",conditions:[]};const a=Object.keys(e),r=a.includes("all")||n&&!a.includes("any")?H.AllOf:H.AnyOf;if(a.includes(r)||n){const l=e[r]||[e],o=[];let s=null;l.forEach(d=>{const m=Object.keys(d);m.includes("all")||m.includes("any")?s=dt(d,!1):o.push({factRef:d.factRef,path:d.path,operator:d.operator,value:d.value,conditions:[]})});const c={factRef:"",path:"",operator:"",value:"",expression:void 0,conditions:o,expressionType:r};return s&&(c.expression=s),c}return{factRef:e.factRef,path:e.path,operator:e.operator,value:e.value,expressionType:H.AllOf,conditions:[]}},un=e=>({checkName:e.name||"",description:e.description||"",teamOwner:e.ownerEntityRef||"",supportChannel:e.supportChannel||"",expression:dt(e.rule),passMessage:e.passedMessage||void 0,failMessage:e.failedMessage||void 0,filters:ct(e.filter)}),Ae=(e,n="$")=>{const a=[];if(e.type==="object"&&e.properties){const r=e.properties;for(const l in r)if(r.hasOwnProperty(l)){const o=`${n}.${l}`;a.push(o);const s=r[l];a.push(...Ae(s,o))}}if(e.type==="array"&&e.items){const r=`${n}[*]`;a.push(r);const l=Array.isArray(e.items)?e.items:[e.items];for(const o of l)a.push(...Ae(o,r))}return a},gn={checkName:"",description:"",teamOwner:"",supportChannel:"",expression:{factRef:"",path:"",operator:"",value:"",expressionType:H.AllOf,conditions:[{factRef:"",path:"",operator:"",value:"",conditions:[]}]},filters:{selectedKinds:[],selectedTypes:[],selectedLifecycles:[],selectedOwners:[],selectedSystems:[],selectedTags:[]}},hn=(e,n)=>{const{data:a}=on(),r=je({control:n,name:`${e}.factRef`}),[l,o]=v(()=>mt(r));D(()=>{o(mt(r))},[r]);const{data:s}=sn(l==null?void 0:l.source,l==null?void 0:l.name),c=j(()=>s?Ae(s.schema):[],[s]),d=j(()=>a==null?void 0:a.flatMap(m=>m.factNames.map(p=>{const i=Te(p,{defaultSource:m.id,defaultScope:"default"});return{label:i.name,value:va(i)}})),[a]);return{pathOptions:c,factRefOptions:d}};function mt(e){if(e)try{return Te(e,{defaultSource:"unknown",defaultScope:"default"})}catch{return null}return null}const pt=({name:e,rules:n,label:a,control:r,options:l,getOptionLabel:o,disabled:s})=>t.createElement(Ee,{name:e,control:r,rules:n,render:({field:c,fieldState:d})=>t.createElement(Qe,{...c,freeSolo:!0,"data-testid":`${e}-autocomplete`,style:{minWidth:250},disabled:s,options:l,getOptionLabel:o,renderInput:m=>t.createElement(z,{...m,variant:"outlined",label:a,error:d.invalid,helperText:d.error?d.error.message:null}),onChange:(m,p)=>c.onChange(p),onInputChange:(m,p)=>c.onChange(p)})}),En=e=>{try{return Te(e),!0}catch{return"Invalid fact reference. [source]:[scope]/[name]."}},vn=({control:e,name:n,handleDelete:a,disabled:r})=>{var l;const o=ln(),s=j(()=>Object.values(st).map(m=>({value:m,label:rn[m]})),[]),{pathOptions:c,factRefOptions:d}=hn(n,e);return t.createElement(I,{className:o.container},t.createElement(I,{className:o.connector}),t.createElement(I,{className:o.innerContainer},t.createElement(I,{className:o.header}),t.createElement(I,{className:o.inputsContainer},t.createElement(pt,{name:`${n}.factRef`,control:e,rules:{required:!0,maxLength:500,validate:En},label:"Fact",options:(l=d==null?void 0:d.map(m=>m.value))!=null?l:[],getOptionLabel:m=>{var p,i;return(i=(p=d==null?void 0:d.find(h=>m===h.value))==null?void 0:p.label)!=null?i:m},disabled:r}),t.createElement(pt,{name:`${n}.path`,label:"Path",control:e,disabled:r,options:c}),t.createElement(ot,{name:`${n}.operator`,control:e,selectLabel:"Operator",options:s,disabled:r}),t.createElement(Ee,{name:`${n}.value`,control:e,defaultValue:"",render:({field:m})=>t.createElement(z,{...m,label:"Value",variant:"outlined",placeholder:"Enter a value",disabled:r})}))),!r&&t.createElement(he,{onClick:a,className:o.deleteButton,"data-test-id":`${n}-delete-button`},t.createElement(_e,{className:o.deleteIcon})))},fn=({conditions:e,control:n,name:a,handleDelete:r,disabled:l,setValue:o})=>t.createElement(t.Fragment,null,e.filter(s=>!s.expressionType).map((s,c)=>t.createElement(u,{item:!0,key:c},t.createElement(vn,{control:n,name:`${a}.conditions[${c}]`,"data-testid":`${a}-condition-input`,handleDelete:()=>r(c),disabled:l,setValue:o})))),yn=({expression:e,control:n,name:a,depth:r,getValues:l,setValue:o,trigger:s,disabled:c})=>e?t.createElement(u,{item:!0},t.createElement(ut,{control:n,name:`${a}.expression`,depth:r+1,getValues:l,setValue:o,trigger:s,disabled:c})):null,bn=k(e=>({button:{fontWeight:700,backgroundColor:e.palette.background.default,color:e.palette.primary.main,"&:hover":{backgroundColor:"rgba(46, 119, 208, 0.2)"}},selectedButton:{backgroundColor:"rgba(46, 119, 208, 0.15)"}})),Cn=({control:e,name:n,getValues:a,disabled:r})=>{const l=bn(),o=`${n}`,s=a(o),[c,d]=v(s||H.AllOf),m=p=>{d(p)};return t.createElement(Ee,{control:e,name:n,render:({field:{onChange:p}})=>t.createElement(Be,{color:"primary"},Object.values(H).map(i=>t.createElement(A,{key:i,className:c===i?`${l.selectedButton} ${l.button}`:`${l.button}`,onClick:()=>{m(i),p(i)},disabled:r},nn[i])))})},kn=(e,n,a,r)=>({handleAddCondition:async()=>{const l=`${e}`,o=n(l),s=[...(o==null?void 0:o.conditions)||[],{factRef:"",path:"",operator:"",value:""}],c=`${e}.conditions`;a(c,s),await r(c)},handleAddExpression:async()=>{a(`${e}.expression`,{factRef:"",path:"",operator:"",value:"",expressionType:H.AllOf,conditions:[{factRef:"",path:"",operator:"",value:""}]}),await r(`${e}.expression`)},handleDeleteCondition:async l=>{const o=`${e}`,s=[...n(o).conditions||[]];if(s.splice(l,1),s.length===0)a(o,void 0);else{const c=`${e}.conditions`;a(c,s)}await r(o)}}),xn=ee(e=>({root:{backgroundColor:e.palette.type==="dark"?e.palette.grey[700]:e.palette.grey[100],border:`1px solid ${e.palette.grey[500]}`,padding:e.spacing(2)},inner:{marginLeft:e.spacing(2),paddingBottom:e.spacing(2),borderLeft:`1px solid ${e.palette.grey[500]}`,display:"flex",flexDirection:"row",gap:0},connector:{borderBottom:`1px solid ${e.palette.grey[500]}`,padding:e.spacing(0),width:"15px",height:"20px"}})),ut=({control:e,name:n,depth:a,getValues:r,setValue:l,trigger:o,disabled:s})=>{const c=xn(),{handleAddCondition:d,handleAddExpression:m,handleDeleteCondition:p}=kn(n,r,l,o),i=`${n}`,h=r(i),g=(h==null?void 0:h.conditions)||[],E=h==null?void 0:h.expression;return t.createElement(I,{className:a>0?c.inner:c.root},a>0&&t.createElement(I,{className:c.connector}),t.createElement(u,{container:!0,spacing:0,direction:"column"},t.createElement(u,{item:!0},t.createElement(Cn,{control:e,disabled:s,name:`${n}.expressionType`,getValues:r})),t.createElement(u,{item:!0,container:!0,spacing:0,direction:"column"},t.createElement(fn,{handleDelete:p,disabled:s,conditions:g,control:e,name:n,setValue:l}),t.createElement(yn,{expression:E,control:e,name:n,depth:a,getValues:r,setValue:l,trigger:o,disabled:s})),!s&&t.createElement(u,{item:!0},t.createElement(an,{onAddCondition:d,onAddExpression:m}))))},wn=({control:e,supportContactError:n,disabled:a,isLoading:r,options:l})=>{var o;return t.createElement(ke,{title:a?"Team details":"Team details (optional)"},t.createElement(ot,{name:"teamOwner",control:e,selectLabel:"Check owner",options:(o=l==null?void 0:l.map(s=>({value:s.ref,label:s.name})))!=null?o:[],disabled:a||r}),t.createElement(ve,{name:"supportChannel",control:e,error:n,label:"Support channel",placeholder:"Enter a channel or email to get check support",disabled:a||r,rules:{},messages:{}}))},gt=[{facet:"kind",label:"Kind",stateKey:"selectedKinds"},{facet:"spec.type",label:"Type",stateKey:"selectedTypes"},{facet:"spec.lifecycle",label:"Lifecycle",stateKey:"selectedLifecycles"},{facet:"spec.owner",label:"Owner",stateKey:"selectedOwners"},{facet:"spec.system",label:"System",stateKey:"selectedSystems"},{facet:"metadata.tags",label:"Tags",stateKey:"selectedTags"}],Nn=e=>{const n=R(pa),a=R(Sa);return te([F.GetEntityFacets,e],async()=>{var r;return((r=(await a.getEntityFacets({facets:[e]})).facets[e])==null?void 0:r.map(l=>l.value).sort())||[]},{onError:()=>{n.post({message:`Failed to load facet: ${e}`,severity:"error"})}})},Ln=k({formControl:{flexGrow:1}}),ht=({facet:e,label:n,values:a,onChange:r,disabled:l})=>{const o=Ln(),{data:s,error:c}=Nn(e),d=j(()=>s==null?void 0:s.map(i=>i.toLocaleLowerCase("en-US")),[s]),m=G((i,h)=>{r(d&&d.every(g=>h.includes(g))?void 0:h)},[d,r]),p=G(()=>{r(a!=null&&a.length?a:void 0)},[a,r]);return!(s!=null&&s.length)||!(d!=null&&d.length)||c?t.createElement(C,{color:"error"},"Failed to load facet: ",e):t.createElement(I,{pb:1,pt:1},t.createElement(C,{variant:"subtitle2"},n),t.createElement(Qe,{className:o.formControl,multiple:!0,limitTags:4,disableCloseOnSelect:!0,"aria-label":n,options:d,value:a!=null?a:[],getOptionLabel:i=>{var h;return(h=s[d.indexOf(i)])!=null?h:i},onChange:m,onBlur:p,disabled:l,renderOption:(i,{selected:h})=>{var g;return t.createElement(Zt,{control:t.createElement(Xt,{icon:t.createElement(Na,{fontSize:"small"}),checkedIcon:t.createElement(wa,{fontSize:"small"}),checked:h}),label:(g=s[d.indexOf(i)])!=null?g:i})},size:"small",popupIcon:t.createElement(La,{"data-testid":"selected-facets-expand"}),renderInput:i=>t.createElement(z,{...i,variant:"outlined"})}))},Sn=k(e=>({title:{fontWeight:700},container:{padding:e.spacing(0,1.5)},filterContainer:{display:"flex",flexWrap:"wrap",padding:e.spacing(2)}})),Pn=({control:e,setFilters:n,disabled:a})=>{const r=Sn(),l=je({control:e,name:"filters",defaultValue:{selectedKinds:[],selectedTypes:[],selectedLifecycles:[],selectedOwners:[],selectedSystems:[],selectedTags:[]}}),o=s=>c=>{n(s,c)};return t.createElement(ke,{title:a?"Filters":"Filters (optional)"},t.createElement(u,{className:r.container,item:!0,xs:12},t.createElement(C,{variant:"body2"},"Apply filters so it's only applicable to relevant entities."),t.createElement(u,{item:!0,xs:12},t.createElement(Ne,null,t.createElement(u,{container:!0,className:r.filterContainer,spacing:2},gt.map(s=>t.createElement(u,{item:!0,xs:12,sm:6,md:4,key:s.stateKey},t.createElement(ht,{facet:s.facet,label:s.label,values:l==null?void 0:l[s.stateKey],onChange:o(s.stateKey),disabled:a}))))))))},Tn=({control:e,setValue:n,trigger:a,disabled:r})=>t.createElement(Pn,{control:e,setFilters:async(l,o)=>{n(`filters.${l}`,o!=null?o:[]),await a(`filters.${l}`)},disabled:r}),Dn=e=>{const{selectedCheck:n}=W();let a=gn;n&&(a=un(n));const{control:r,handleSubmit:l,getValues:o,setValue:s,trigger:c,formState:{errors:d}}=ca({defaultValues:a}),{showModal:m}=Ce();function p(i){var h,g,E,f,x;if(i===void 0)return!1;let L=!0;if((h=i.conditions)!=null&&h.length&&((g=i.conditions)==null?void 0:g.length)>0)for(const S in i.conditions)i.conditions.hasOwnProperty(S)&&(L=L&&p((E=i.conditions)==null?void 0:E[S]));return i.expression&&(L=L&&p(i.expression)),L?!!(i.value!==""&&i.path!==""&&i.factRef!==""&&i.operator!==""||(f=i.conditions)!=null&&f.length&&((x=i.conditions)==null?void 0:x.length)>0||i.expression!==void 0):!1}return{control:r,handleSubmit:l,getValues:o,setValue:s,trigger:c,errors:d,onSubmit:async i=>{var h,g,E,f,x,L,S,w;const N=o();let P=p(N.expression);if((g=(h=N.expression)==null?void 0:h.conditions)!=null&&g.length&&(P=P&&((f=(E=N.expression)==null?void 0:E.conditions)==null?void 0:f.length)>0),!P){await m({title:"Invalid Rule(s)",message:"The check is invalid as it is either missing a rule or a rule is missing a value.",error:!0});return}if(!await m({title:"Save Check",message:`Are you sure you want to save check: ${i.checkName}?`,error:!1}))return;const T={id:n?n.id:Ze(),ownerEntityRef:(x=i.teamOwner)!=null?x:void 0,name:i.checkName,description:i.description,passedMessage:(L=i.passMessage)!=null?L:void 0,failedMessage:(S=i.failMessage)!=null?S:void 0,rule:Ie(i.expression),filter:i.filters?it(i.filters):void 0,supportChannel:(w=i.supportChannel)!=null?w:void 0};e(T)}}},In=()=>t.createElement("div",{style:{display:"flex",gap:"10px",flexDirection:"column"}},t.createElement(C,{variant:"h6"},"Creating and managing checks"),t.createElement(C,{variant:"body1"},"Checks are entities created from four components: facts, paths, operators and values. These components are then organized via a boolean calculator in the UI."),t.createElement(C,{variant:"body1"},"To create a check, select the components that you want to use, organize them into rules and give your check a meaningful name and a description."),t.createElement(C,{variant:"body1"},"Once created, you will be able to manage and edit your track on its detail page.")),Et=ee(e=>({root:{overflow:"hidden",display:"flex",marginBottom:"53px"},card:{padding:e.spacing(3),display:"flex",gap:e.spacing(2.5)},sectionLabel:{fontWeight:700,margin:e.spacing(2,0),color:e.palette.primary.main}})),Re=({title:e,open:n,onSave:a})=>{const r=Et(),{hideModal:l,isLoading:o,isReadOnly:s}=W(),{control:c,handleSubmit:d,getValues:m,setValue:p,trigger:i,errors:h,onSubmit:g}=Dn(a),{options:E}=ra();return t.createElement(lt,{handleClose:l,title:e,open:n},t.createElement("form",{onSubmit:d(g)},t.createElement(u,{container:!0,spacing:2,className:r.root},t.createElement(u,{item:!0,xs:9},t.createElement(Le,{className:r.card},t.createElement(C,{className:r.sectionLabel,style:{margin:0}},"Check Details"),t.createElement(Ya,{control:c,error:h.checkName,isLoading:o,disabled:s}),t.createElement(en,{control:c,error:h.description,isLoading:o,disabled:s}),t.createElement(wn,{control:c,disabled:s,isLoading:o,options:E}),t.createElement(C,{className:r.sectionLabel},"Rules"),t.createElement(ut,{control:c,getValues:m,setValue:p,trigger:i,disabled:s,name:"expression",depth:0}),t.createElement(Tn,{control:c,setValue:p,trigger:i,disabled:s}),t.createElement(Xa,{control:c,passError:h.passMessage,failError:h.failMessage,isLoading:o,disabled:s}))),t.createElement(u,{item:!0,xs:3},t.createElement(In,null))),t.createElement(u,{container:!0,spacing:4,className:r.root},t.createElement(at,{onCancel:l,saveButtonText:"Save Check",isLoading:o,onSave:s?void 0:d(g)}))))},An="Error Creating Check";function Rn(){const e=R(M),n=ae(),{showAlert:a}=Q(),r=async l=>{const o=await e.updateCheck(l);if(!o)throw new Error("Failed to update check.");return o};return ne([re.UpdateCheck],r,{onSuccess:()=>{n.invalidateQueries({queryKey:[F.GetChecks]})},onError:l=>{let o="Failed to update check.";l instanceof Error&&(o=l.message),a({severity:"error",title:An,message:o})}})}const On=()=>{const{selectedCheck:e,hideModal:n}=W(),{setIsLoading:a}=W(),{mutateAsync:r,isLoading:l}=Rn();return D(()=>{a(l)},[a,l]),t.createElement(Re,{title:"Edit a Check",open:!!e,onSave:async o=>{await r(o)&&n()}})},Fn="Error Creating Check";function $n(){const e=R(M),n=ae(),{showAlert:a}=Q(),r=async l=>{const o=await e.createCheck(l);if(!o)throw new Error("Failed to create check.");return o};return ne([re.CreateCheck],r,{onSuccess:()=>{n.invalidateQueries({queryKey:[F.GetChecks]})},onError:l=>{let o="Failed to create check.";l instanceof Error&&(o=l.message),a({severity:"error",title:Fn,message:o})}})}const Mn=()=>{const{hideModal:e,showAddModal:n,setIsLoading:a}=W(),{mutateAsync:r,isLoading:l}=$n();return D(()=>{a(l)},[a,l]),t.createElement(Re,{title:"Create a Check",open:n,onSave:async o=>{await r(o)&&e()}})},Vn=({handleDelete:e})=>{const[n,a]=v(null),r=!!n,l=s=>{s.stopPropagation(),a(s.currentTarget)},o=s=>{s.stopPropagation(),a(null)};return t.createElement(t.Fragment,null,t.createElement(he,{"aria-label":"summary-card-actions",id:"summary-card-action-menu-button","aria-controls":r?"summary-card-action-menu":void 0,"aria-expanded":r?"true":void 0,"aria-haspopup":"true",onClick:l},t.createElement(Pa,null)),t.createElement(Ge,{id:"summary-card-action-menu",anchorEl:n,open:r,onClose:o,getContentAnchorEl:null,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{"aria-labelledby":"summary-card-action-menu-button"}},e&&t.createElement(ye,{"data-testid":"summary-card-action-delete",onClick:s=>{e(s),o(s)}},t.createElement(Y,null,t.createElement(_e,{fontSize:"small"})),t.createElement(_,null,"Delete"))))},Bn=ze(e=>Ke({root:{width:"100%",height:"100%",minHeight:"385px",display:"flex",flexDirection:"column",padding:e.spacing(2),position:"relative"}}))(Le),Gn=ze(()=>Ke({root:{display:"flex",flexDirection:"column",flex:1,gap:"3px"}}))(We),zn=k(e=>({root:{position:"relative",height:"100%"},cardSection:{marginBottom:e.spacing(2)},summaryName:{fontSize:e.typography.pxToRem(24),color:e.palette.primary.main,maxHeight:"75px",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:6,WebkitBoxOrient:"vertical","-webkit-line-clamp":2,"-webkit-box-orient":"vertical",wordBreak:"break-word"},summaryDescription:{maxHeight:"150px",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:6,WebkitBoxOrient:"vertical",wordBreak:"break-word"}})),vt=({title:e,description:n,children:a,handleDelete:r,handleEdit:l,handleView:o})=>{const s=zn();return t.createElement(Bn,null,t.createElement("div",{className:s.summaryName},t.createElement(ea,{title:e,action:r&&t.createElement(Vn,{handleDelete:r})})),t.createElement(Gn,null,t.createElement("div",{className:s.cardSection},t.createElement("div",{className:s.summaryDescription},t.createElement(Vt,{content:n!=null?n:""}))),a&&t.createElement("div",{className:s.cardSection},a)),t.createElement(ta,null),t.createElement(aa,null,t.createElement(A,{size:"small",color:"primary",role:"link",onClick:l||o},l?"Edit":"View")))},Wn="Error Deleting Check";function qn(){const e=R(M),n=ae(),{showAlert:a}=Q(),r=async l=>{const o=await e.deleteCheck(l);if(!o)throw new Error(`Failed to delete check ${l}`);return o};return ne([re.DeleteCheck],r,{onSuccess:()=>{n.invalidateQueries({queryKey:[F.GetChecks]})},onError:(l,o)=>{let s=`Failed to delete check ${o}`;l instanceof Error&&(s=l.message),a({severity:"error",title:Wn,message:s})}})}const Kn=k(e=>({root:{position:"relative",height:"100%"},cardSection:{marginBottom:e.spacing(2)},listItem:{padding:0},listItemText:{margin:0}})),Un=({check:e})=>{var n;const a=Kn();return t.createElement(be,{dense:!0,disablePadding:!0,className:a.cardSection},t.createElement(C,{variant:"overline",color:"textSecondary"},"Check Details"),t.createElement(Z,{disableGutters:!0,className:a.listItem},t.createElement(X,{title:"Owner"},t.createElement(Y,null,t.createElement(Xe,{color:"action",fontSize:"small"}))),t.createElement(_,{className:a.listItemText,primary:t.createElement(Ye,{entityRef:(n=e.ownerEntityRef)!=null?n:"No Owner"})})))},Hn=({check:e})=>{const{id:n,name:a,description:r,isEditable:l,ownerEntityRef:o}=e,{loading:s,allowed:c}=le({permission:fa,resourceRef:n}),{loading:d,allowed:m}=le({permission:ya,resourceRef:n}),{showModal:p}=Ce(),{mutate:i}=qn(),{showReadOnlyModal:h,setSelectedCheck:g}=W(),E=G(async()=>{await p({title:"Delete Check",message:`Are you sure you want to delete the check '${a!=null?a:n}'?`})&&i(n)},[p,a,i,n]);return t.createElement(vt,{title:a!=null?a:n,description:r,children:o&&t.createElement(Un,{check:e}),handleView:()=>h(e),handleEdit:l&&!s&&c?()=>g(e):void 0,handleDelete:l&&!d&&m?E:void 0})},jn=()=>t.createElement(t.Fragment,null,Array.from({length:10},(e,n)=>t.createElement(u,{key:`loading-${n}`,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem"},t.createElement(Je,{variant:"rect",height:385})))),_n=k(()=>({searchIcon:{opacity:".5"},clearButton:{height:"36px",width:"36px"}})),ft=({searchTerm:e,setSearchTerm:n,showClear:a=!0,placeholder:r="Search...",...l})=>{const o=_n(),s=d=>{n(d.target.value)},c=()=>{n("")};return t.createElement(z,{...l,fullWidth:!0,placeholder:r,value:e,onChange:s,InputProps:{startAdornment:t.createElement(qe,{position:"start"},t.createElement(Ta,{className:o.searchIcon,"data-testid":"search-icon"})),endAdornment:a&&e?t.createElement(qe,{position:"end"},t.createElement(he,{edge:"end",onClick:c,className:o.clearButton},t.createElement(He,null))):null}})},Qn=k(()=>({searchbar:{maxWidth:"350px"},filters:{display:"flex",alignItems:"center"},dropdownFilters:{margin:"0 15px",display:"flex",alignItems:"center"},selectHolder:{marginLeft:"10px"}})),yt=({searchPlaceholder:e,isLoading:n,searchTerm:a,setSearchTerm:r,filterAlpha:l,handleAlphabeticalFilterChange:o,filterOwner:s,handleOwnerFilterChange:c,owners:d})=>{const m=Qn();return t.createElement(u,{item:!0,xs:9,className:m.filters},t.createElement(ft,{searchTerm:a,disabled:n,setSearchTerm:r,placeholder:e||"Search",variant:"outlined",size:"small",className:m.searchbar}),t.createElement("div",{className:m.dropdownFilters},t.createElement(C,null,"Sort by: "),t.createElement(Se,{className:m.selectHolder,value:l,onChange:o},t.createElement("option",{value:"default"},"Default"),t.createElement("option",{value:"ascending"},"Name A-Z"),t.createElement("option",{value:"descending"},"Name Z-A"))),t.createElement("div",{className:m.dropdownFilters},t.createElement(C,null,"Filter by owner: "),t.createElement(Se,{className:m.selectHolder,value:s,onChange:c},t.createElement("option",{key:"all",value:"all"},"All"),d==null?void 0:d.map((p,i)=>t.createElement("option",{key:p+i,value:p},p)))))},Jn=(e,n)=>e==null?void 0:e.sort((a,r)=>{var l,o,s,c;const d=(o=(l=a==null?void 0:a.name)==null?void 0:l.toLocaleLowerCase())!=null?o:a==null?void 0:a.id.toLocaleLowerCase(),m=(c=(s=r==null?void 0:r.name)==null?void 0:s.toLocaleLowerCase())!=null?c:r==null?void 0:r.id.toLocaleLowerCase();return!d||!m?0:d<m?n==="ascending"?-1:1:d>m?n==="ascending"?1:-1:0}),bt=e=>{const n=e==null?void 0:e.map(a=>a==null?void 0:a.ownerEntityRef).filter(a=>a!=="");return[...new Set(n)]},se=({searchTermProp:e,filterAlphaProp:n,filterOwnerProp:a,checks:r,tracks:l})=>{var o,s;const c=r||l||[],d=(o=c==null?void 0:c.filter)==null?void 0:o.call(c,p=>{var i;return((i=p==null?void 0:p.name)!=null?i:p==null?void 0:p.id).toLocaleLowerCase().includes(e.toLocaleLowerCase())}),m=a&&a!=="all"?(s=d==null?void 0:d.filter)==null?void 0:s.call(d,p=>{var i;return((i=p==null?void 0:p.ownerEntityRef)==null?void 0:i.toLowerCase())===a.toLowerCase()}):d;return n==="default"?m:Jn(m!=null?m:[],n)},Yn=k(e=>({headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap",justifyContent:"end",alignItems:"center"},header:{padding:e.spacing(0,0,1)},pagination:{display:"flex",width:"-webkit-fill-available",justifyContent:"space-between",position:"fixed",bottom:0,marginRight:"40px",backgroundColor:"#424242"},pageTotal:{padding:e.spacing(1),marginLeft:"-20px"}})),Zn=({checksPerPage:e,currentCursor:n})=>{const a=Yn(),[r,l]=v(n),[o,s]=v([]),{data:c,isLoading:d}=tt(void 0,e,r),{loading:m,allowed:p}=le({permission:ba}),[i,h]=v(c);D(()=>{c&&h(()=>{var y;return{endCursor:c.endCursor,totalCount:c.totalCount,hasNextPage:(y=c==null?void 0:c.hasNextPage)!=null?y:!1,edges:c.edges}})},[c]);const g=i==null?void 0:i.edges[(i==null?void 0:i.edges.length)-1],E=i==null?void 0:i.edges.map(y=>y.checker),{setShowAddModal:f}=W(),[x,L]=v(),[S,w]=v(""),[N,P]=v("default"),[T,q]=v("all"),[ie,B]=v([]),ce=y=>{const O=se({searchTermProp:S,filterAlphaProp:y.target.value,filterOwnerProp:T,checks:E!=null?E:[]});P(y.target.value),L(O)},de=y=>{const O=se({searchTermProp:S,filterAlphaProp:N,filterOwnerProp:y.target.value,checks:E!=null?E:[]});q(y.target.value),L(O)};D(()=>{const y=i==null?void 0:i.edges.map(b=>b.checker),O=bt(y!=null?y:[]);L(y),B(O!=null?O:[])},[d,i]),D(()=>{const y=i==null?void 0:i.edges.map(b=>b.checker),O=se({searchTermProp:S,filterAlphaProp:N,filterOwnerProp:T,checks:y!=null?y:[]});L(O)},[S,N,T,i]);const me=()=>{s(y=>[...y,r]),l(g==null?void 0:g.cursor)},pe=()=>{l(o[o.length-1]),s(y=>y.slice(0,-1))},J=i!=null&&i.totalCount&&e?Math.ceil((i==null?void 0:i.totalCount)/e):0,ue=y=>{window.open(`/soundcheck/checks?checksPerPage=${y.target.value}`,"_self")};return t.createElement(u,{container:!0,direction:"row"},t.createElement(u,{container:!0,spacing:4,className:a.header},t.createElement(yt,{searchPlaceholder:"Search available checks",isLoading:d,searchTerm:S,setSearchTerm:w,filterAlpha:N,handleAlphabeticalFilterChange:ce,filterOwner:T,handleOwnerFilterChange:de,owners:ie}),t.createElement(u,{item:!0,xs:3},t.createElement("div",{className:a.headerButtons},t.createElement(C,null,"Checks shown:"),t.createElement(Se,{value:e,onChange:ue},["10","25","50","100"].map(y=>t.createElement("option",{value:y},y))),!m&&t.createElement(A,{disabled:!p,variant:"contained",color:"primary",onClick:()=>f(!0)},"Create Check")))),t.createElement(u,{container:!0,spacing:4,role:"list","aria-label":"checks"},d?t.createElement(jn,null):x==null?void 0:x.map(y=>t.createElement(u,{key:y.id,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem","aria-label":"result"},t.createElement(Hn,{check:y})))),((i==null?void 0:i.hasNextPage)||(o==null?void 0:o.length)>0)&&t.createElement("div",{className:a.pagination},t.createElement(A,{disabled:(o==null?void 0:o.length)<=0,onClick:pe},"Load Previous Checks"),t.createElement(C,{className:a.pageTotal},"Page ",o.length+1,"/",J),t.createElement(A,{disabled:!(i!=null&&i.hasNextPage),onClick:me},"Load Next Checks")))},Xn=()=>{const{selectedCheck:e}=W();return t.createElement(Re,{title:"Check Details",open:!!e,onSave:()=>{}})},er=k(e=>({checksPageContainer:{padding:e.spacing(3)}})),tr=()=>{const e=er(),[n]=Ve(),a=n.get("checksPerPage"),r=a?parseInt(a,10):10,{selectedCheck:l,showAddModal:o,isReadOnly:s}=W();return t.createElement("div",{className:e.checksPageContainer},t.createElement(Zn,{checksPerPage:r}),o&&t.createElement(Mn,null),l&&!s&&t.createElement(On,null),l&&s&&t.createElement(Xn,null))},ar=()=>t.createElement(ja,null,t.createElement(tr,null)),nr=k(e=>({root:{position:"relative",height:"100%"},cardSection:{marginBottom:e.spacing(2)},listItem:{padding:0},listItemText:{margin:0}})),rr=({program:e})=>{var n,a,r;const l=nr(),o=(a=(n=e.levels)==null?void 0:n.length)!=null?a:0,s=(r=e.levels)==null?void 0:r.reduce((c,d)=>c+d.checks.length,0);return t.createElement(be,{dense:!0,disablePadding:!0,className:l.cardSection},t.createElement(C,{variant:"overline",color:"textSecondary"},"Track Details"),t.createElement(Z,{disableGutters:!0,className:l.listItem},t.createElement(X,{title:"Levels"},t.createElement(Y,null,t.createElement($a,{color:"action",fontSize:"small"}))),t.createElement(_,{className:l.listItemText,primary:t.createElement(C,{variant:"body2",color:"textSecondary"},`${o} ${o===1?"Level":"Levels"}`)})),t.createElement(Z,{disableGutters:!0,className:l.listItem},t.createElement(X,{title:"Checks"},t.createElement(Y,null,t.createElement(Fa,{color:"action",fontSize:"small"}))),t.createElement(_,{className:l.listItemText,primary:t.createElement(C,{variant:"body2",color:"textSecondary"},`${s} ${s===1?"Check":"Checks"}`)})),e.documentationURL&&t.createElement(Z,{disableGutters:!0,className:l.listItem},t.createElement(X,{title:"Documentation"},t.createElement(Y,null,t.createElement(Oa,{color:"action",fontSize:"small"}))),t.createElement(_,{className:l.listItemText,primary:t.createElement(Bt,{to:e.documentationURL,target:"_blank",rel:"noopener noreferrer"},"Learn more")})),t.createElement(Z,{disableGutters:!0,className:l.listItem},t.createElement(X,{title:"Owner"},t.createElement(Y,null,t.createElement(Xe,{color:"action",fontSize:"small"}))),t.createElement(_,{className:l.listItemText,primary:t.createElement(Ye,{entityRef:e.ownerEntityRef})})))},lr="Error Deleting Track";function or(){const e=R(M),n=ae(),{showAlert:a}=Q(),r=async l=>{const o=await e.deleteProgram(l);if(!o)throw new Error(`Failed to delete track ${l}`);return o};return ne([re.DeleteProgram],r,{onSuccess:()=>{n.invalidateQueries({queryKey:[F.GetAllPrograms]})},onError:(l,o)=>{let s=`Failed to delete track ${o}`;l instanceof Error&&(s=l.message),a({severity:"error",title:lr,message:s})}})}const sr=({summary:e})=>{const{loading:n,allowed:a}=le({permission:Ca,resourceRef:e.id}),{loading:r,allowed:l}=le({permission:ka,resourceRef:e.id}),{showModal:o}=Ce(),{mutate:s}=or(),{setSelectedProgram:c}=oe(),d=G(async()=>{await o({title:"Delete Track",message:`Are you sure you want to delete track ${e.name}?`})&&s(e.id)},[o,e.id,e.name,s]);return t.createElement(vt,{title:e.name,description:e.description,children:t.createElement(rr,{program:e}),handleView:()=>{c(e)},handleEdit:e.isEditable&&!n&&a?()=>{c(e)}:void 0,handleDelete:e.isEditable&&!r&&l?d:void 0})},ir=()=>t.createElement(t.Fragment,null,Array.from({length:6},(e,n)=>t.createElement(u,{key:`loading-${n}`,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem"},t.createElement(Je,{variant:"rect",height:385})))),cr=k(e=>({headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap",justifyContent:"end"},header:{padding:e.spacing(0,0,1)},pagination:{display:"flex",width:"100%",justifyContent:"space-between"}})),dr=({programsPerPage:e,currentCursor:n})=>{var a;const r=cr(),{loading:l,allowed:o}=le({permission:xa}),{setShowAddModal:s}=oe(),[c,d]=v(n),[m,p]=v([]),{data:i,isLoading:h}=Ga(void 0,e,c),[g,E]=v(i);D(()=>{i&&E(()=>{var b;return{endCursor:i.endCursor,totalCount:i.totalCount,hasNextPage:(b=i==null?void 0:i.hasNextPage)!=null?b:!1,edges:i.edges}})},[i]);const f=(a=g==null?void 0:g.edges)==null?void 0:a.map(b=>b==null?void 0:b.program),x=g==null?void 0:g.edges[(g==null?void 0:g.edges.length)-1],{userEntityRef:L}=Ue(),{showAlert:S}=Q(),[w,N]=v(),[P,T]=v(""),[q,ie]=v("default"),[B,ce]=v("all"),[de,me]=v([]),pe=b=>{const $=se({searchTermProp:P,filterAlphaProp:b.target.value,filterOwnerProp:B,tracks:f!=null?f:[]});ie(b.target.value),N($)},J=b=>{const $=se({searchTermProp:P,filterAlphaProp:q,filterOwnerProp:b.target.value,tracks:f!=null?f:[]});ce(b.target.value),N($)};D(()=>{const b=g==null?void 0:g.edges.map(ge=>ge.program),$=bt(b!=null?b:[]);N(b),me($!=null?$:[])},[h,g]),D(()=>{const b=g==null?void 0:g.edges.map(ge=>ge.program),$=se({searchTermProp:P,filterAlphaProp:q,filterOwnerProp:B,tracks:b!=null?b:[]});N($)},[P,q,B,g]);const ue=()=>{p(b=>[...b,c]),d(x==null?void 0:x.cursor)},y=()=>{d(m[m.length-1]),p(b=>b.slice(0,-1))},O=()=>{L?s(!0):S({severity:"error",title:"User Error",message:"Logged in user has not been found in Catalog. Unable to create a Track at this time"})};return t.createElement(u,{container:!0,direction:"row"},t.createElement(u,{container:!0,spacing:4,className:r.header},t.createElement(yt,{searchPlaceholder:"Search available tracks",isLoading:h,searchTerm:P,setSearchTerm:T,filterAlpha:q,handleAlphabeticalFilterChange:pe,filterOwner:B,handleOwnerFilterChange:J,owners:de}),t.createElement(u,{item:!0,xs:3},t.createElement("div",{className:r.headerButtons},!l&&t.createElement(A,{disabled:!o,variant:"contained",color:"primary",onClick:()=>O()},"Create Track")))),t.createElement(u,{container:!0,spacing:4,role:"list","aria-label":"tracks"},h?t.createElement(ir,null):w==null?void 0:w.map(b=>t.createElement(u,{key:b.id,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem","aria-label":"result"},t.createElement(sr,{summary:b})))),((g==null?void 0:g.hasNextPage)||(m==null?void 0:m.length)>0)&&t.createElement("div",{className:r.pagination},t.createElement(A,{disabled:(m==null?void 0:m.length)<=0,onClick:y},"Load Previous Tracks"),t.createElement(A,{disabled:!(g!=null&&g.hasNextPage),onClick:ue},"Load Next Tracks")))},mr=k(e=>({titleInput:{marginBottom:e.spacing(1)},title:{fontWeight:700}})),Ct=({programName:e,programNameError:n,handleProgramNameChange:a,disabled:r})=>{const l=mr();return t.createElement(u,{item:!0,xs:12},t.createElement(z,{fullWidth:!0,placeholder:"Untitled track",value:e,onChange:a,disabled:r,className:l.titleInput,variant:"outlined",size:"small",margin:"normal",error:n,helperText:n?"Track name must be at least 1 character and less than 100 characters":""}))},kt=k(e=>{const n=e.palette.type==="dark",a=n?e.palette.common.white:e.palette.common.black,r=n?e.palette.grey[700]:e.palette.common.white,l=n?e.palette.grey[500]:e.palette.grey[300],o=n?e.palette.common.white:e.palette.common.black;return{chip:{width:"100%",height:"36px",color:a,justifyContent:"space-between",background:r,border:`1px solid ${l}`,borderRadius:4,boxShadow:"0px 2px 5px rgba(0, 0, 0, 0.1)",cursor:"move","& *":{fontWeight:700},"&:focus":{background:r,borderColor:o,"& $icon":{color:e.palette.primary.main}}},icon:{},deleteButton:{marginRight:"auto"}}}),pr=({chip:e,disabled:n})=>{var a;const[r,l]=Da(()=>({type:"chip",item:{id:e.id,label:e.label},collect:s=>({isDragging:s.isDragging()})})),o=kt();return t.createElement(Pe,{ref:l,label:e.label,className:o.chip,icon:t.createElement(et,{"data-testid":"drag-indicator-icon"}),disabled:n,onDelete:()=>{},deleteIcon:t.createElement(X,{title:(a=e.description)!=null?a:""},t.createElement(Ma,{className:o.icon,"data-testid":"visibility-icon"}))})},xt=k(e=>({columnHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},subtitle:{color:e.palette.primary.main,fontWeight:"bold"},chipContainer:{display:"flex",flexDirection:"column",alignItems:"flex-start",padding:e.spacing(1),gap:e.spacing(1)},loadingContainer:{marginTop:e.spacing(1),display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}})),ur=()=>{const e=xt();return t.createElement(u,{container:!0,className:e.loadingContainer},t.createElement(na,null))},gr=({chips:e,disabled:n})=>t.createElement(t.Fragment,null,e.map(a=>t.createElement(pr,{disabled:n,key:a.id,chip:a}))),hr=()=>t.createElement(C,{variant:"body1",color:"textSecondary"},"There are no matches."),Er=({isLoading:e,chips:n=[],disabled:a})=>{const r=xt(),[l,o]=v(""),s=j(()=>n.filter(m=>m.label.toLowerCase().includes(l.toLowerCase())),[n,l]),c=n.length>0||l,d=()=>{if(e)return t.createElement(ur,null);if(s.length>0)return t.createElement(gr,{disabled:a!=null?a:!1,chips:s});if(c)return t.createElement(hr,null)};return t.createElement(u,{container:!0},t.createElement(u,{item:!0,xs:12,className:r.columnHeader},t.createElement(C,{className:r.subtitle},"Checks")),t.createElement(u,{item:!0,xs:12},t.createElement(ft,{searchTerm:l,disabled:e||a,setSearchTerm:o,placeholder:"Search available checks",variant:"outlined",size:"small"})),t.createElement(u,{item:!0,className:r.chipContainer,xs:12},d()))},vr=k(e=>({button:{border:"none",fontWeight:700,fontSize:e.typography.subtitle2.fontSize,lineHeight:"19px",color:e.palette.primary.main,textTransform:"none"}})),wt=({label:e,...n})=>{const a=vr();return t.createElement(A,{className:a.button,...n},e)},fr=k(e=>({input:{border:`1px solid ${e.palette.grey[600]}`,borderRadius:4,padding:e.spacing(1),minHeight:80},hoverBackground:{background:e.palette.type==="dark"?e.palette.grey[600]:e.palette.grey[200]},normalBackground:{background:e.palette.type==="dark"?e.palette.grey[700]:e.palette.common.white},error:{border:"1px solid red"},chipContainer:{display:"flex",flexDirection:"column",fontWeight:"bold",fontSize:e.typography.pxToRem(16),color:e.palette.grey[600]}})),yr=({chips:e,onDelete:n,onDrop:a,error:r=!1,placeholder:l="",disabled:o})=>{const s=fr(),c=kt(),[{isOver:d},m]=Ia(()=>({accept:"chip",drop:p=>{a(p)},collect:p=>({isOver:p.isOver()})}));return t.createElement("div",{ref:m,className:`${s.input} ${r?s.error:""} ${d?s.hoverBackground:s.normalBackground}`,"data-testid":"droppable-input"},t.createElement("div",{className:s.chipContainer},e!=null&&e.length?e.map(p=>t.createElement(Pe,{key:p.id,label:p.label,className:c.chip,icon:t.createElement(et,null),style:{cursor:"pointer"},onDelete:()=>n(p),disabled:o})):l))},br=k(e=>({inputBase:{fontSize:e.typography.subtitle1.fontSize,fontWeight:700}})),Cr=({levelName:e,handleLevelNameChange:n,disabled:a})=>{const r=br();return t.createElement(z,{fullWidth:!0,placeholder:"Untitled level",value:e,size:"small",variant:"outlined",onChange:n,label:"Level Name",disabled:a,InputProps:{classes:{input:r.inputBase}}})},kr=k(e=>({inputBase:{fontSize:e.typography.fontSize,fontWeight:"normal"}})),xr=({levelDescription:e,levelNameLabel:n,handleLevelDescriptionChange:a,disabled:r})=>{const l=kr();return t.createElement(z,{fullWidth:!0,placeholder:"Enter description here",multiline:!0,value:e,size:"small",variant:"outlined",label:`${n} Description`,onChange:a,disabled:r,InputProps:{classes:{input:l.inputBase}}})},wr=k(e=>({columnHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},subtitle:{fontWeight:"bold",color:e.palette.primary.main},levelHeader:{display:"flex",alignItems:"center"},removeButton:{minWidth:150}})),Nr=({inputChipsList:e,handleDelete:n,handleDrop:a,addInput:r,removeInput:l,levelsErrors:o,levelNames:s,levelDescriptions:c,handleLevelNameChange:d,handleLevelDescriptionChange:m,disabled:p})=>{const i=wr();return t.createElement(u,{container:!0},t.createElement(u,{item:!0,xs:12,className:i.columnHeader},t.createElement(C,{className:i.subtitle},"Levels"),!p&&t.createElement(wt,{label:"Add Level",startIcon:t.createElement(Va,null),onClick:r,disabled:p})),t.createElement(u,{container:!0,item:!0,spacing:5},e.map((h,g)=>t.createElement(u,{container:!0,item:!0,xs:12,key:g,spacing:2},t.createElement(u,{item:!0,xs:12,className:i.levelHeader},t.createElement(u,{container:!0,spacing:1},t.createElement(u,{item:!0,xs:!0},t.createElement(Cr,{levelName:s[g],handleLevelNameChange:E=>d(E.target.value,g),disabled:p!=null?p:!1})),e.length>1&&!p&&t.createElement(u,{item:!0,className:i.removeButton},t.createElement(wt,{label:"Remove Level",startIcon:t.createElement(Ba,null),onClick:()=>l(g),disabled:p})))),t.createElement(u,{item:!0,xs:12},t.createElement(yr,{chips:h,onDelete:E=>n(E,g),onDrop:E=>a(E,g),error:o[g],placeholder:"Drag and drop checks here to include them in this level",disabled:p})),t.createElement(u,{item:!0,xs:12},t.createElement(xr,{levelDescription:c[g],levelNameLabel:s[g],handleLevelDescriptionChange:E=>m(E.target.value,g),disabled:p!=null?p:!1}))))))},Lr=k(e=>({titleInput:{marginBottom:e.spacing(1)},regularFontSize:{fontSize:e.typography.fontSize},title:{fontWeight:700,fontSize:e.typography.fontSize}})),Nt=({programDescription:e,programDescriptionError:n,handleProgramDescriptionChange:a,disabled:r})=>{const l=Lr();return t.createElement(u,{item:!0,xs:12},t.createElement(z,{fullWidth:!0,placeholder:"Example: Make sure the project has a ReadMe file and is using the latest version of JavaScript",value:e,onChange:a,disabled:r,className:l.titleInput,minRows:4,variant:"outlined",size:"small",margin:"normal",multiline:!0,InputProps:{classes:{input:l.regularFontSize}},error:n,helperText:n?"Track description must be at least 1 character and less than 250 characters":""}))};var Sr=(e=>(e.SetProgramNameError="VALIDATE_NAME",e.SetName="SET_NAME",e))(Sr||{});const Pr={programName:"",programNameError:!1},Tr=(e,n)=>{switch(n.type){case"SET_NAME":return{...e,programName:n.value};case"VALIDATE_NAME":return{...e,programNameError:n.value};default:return e}},Dr=(e="")=>{const[n,a]=we(Tr,{...Pr,programName:e}),r=()=>{const s=n.programName.trim().length,c=s>0&&s<=100;return a({type:"VALIDATE_NAME",value:!c}),c},l=s=>{a({type:"SET_NAME",value:s})},o=s=>{l(s.target.value),n.programNameError&&r()};return{programName:n.programName,programNameError:n.programNameError,handleProgramNameChange:o,setProgramName:l,isProgramNameValid:r}};var Ir=(e=>(e.SetProgramDescriptionError="VALIDATE_DESCRIPTION",e.SetDescription="SET_DESCRIPTION",e))(Ir||{});const Ar={programDescription:"",programDescriptionError:!1},Rr=(e,n)=>{switch(n.type){case"SET_DESCRIPTION":return{...e,programDescription:n.value};case"VALIDATE_DESCRIPTION":return{...e,programDescriptionError:n.value};default:return e}},Or=(e="")=>{const[n,a]=we(Rr,{...Ar,programDescription:e}),r=()=>{const s=n.programDescription.trim().length,c=s>0&&s<=250;return a({type:"VALIDATE_DESCRIPTION",value:!c}),c},l=s=>{a({type:"SET_DESCRIPTION",value:s})},o=s=>{l(s.target.value),n.programDescriptionError&&r()};return{programDescription:n.programDescription,programDescriptionError:n.programDescriptionError,handleProgramDescriptionChange:o,setProgramDescription:l,isProgramDescriptionValid:r}},Fr=({programName:e,programDescription:n,areInputsValid:a,isProgramNameValid:r,isProgramDescriptionValid:l,inputChipsList:o,checkers:s,onSave:c,programId:d,levelNames:m,levelDescriptions:p,filters:i})=>{const{showModal:h}=Ce(),{userEntityRef:g}=Ue();return async()=>{if(!(r()&&l()&&a())||!await h({title:"Save Track",message:`Are you sure you want to save track: ${e}?`})||!g)return;const E=d!=null?d:Ze(),f=cn(o,m,p,s),x={description:n,id:E,levels:f,name:e,ownerEntityRef:g,filter:it(i)};c(x)}},$r=e=>{const n=j(()=>e?mn(e):null,[e]),[a,r]=v([]),[l,o]=v(!1),{data:s,isLoading:c}=tt(),d=s==null?void 0:s.edges.map(w=>w.checker),m=j(()=>(d!=null?d:[]).filter(w=>!!w).map(w=>{var N,P,T;return{id:(N=w.id)!=null?N:"",label:(P=w.name)!=null?P:w.id,description:(T=w.description)!=null?T:""}}),[d]),{chips:p,inputChipsList:i,handleDrop:h,handleDelete:g,addInput:E,removeInput:f,inputErrors:x,areInputsValid:L,setInputChipsList:S}=Ka(a);return D(()=>{if(!a.length&&m.length&&!l){const{inputChips:w,used:N}=pn(n,m);S(w),r(N),o(!0)}},[m,S,a.length,n,l]),{checkers:d,checkersLoading:c,chips:p,inputChipsList:i,handleDrop:h,handleDelete:g,addInput:E,removeInput:f,inputErrors:x,areInputsValid:L}},Mr=e=>{const[n,a]=v(e);return{levelNames:n,handleLevelNameChange:(r,l)=>{a(n.map((o,s)=>s===l?r:o))},addLevelName:r=>{a([...n,r])},removeLevelName:r=>{a(n.filter((l,o)=>o!==r))}}},Vr=e=>{const[n,a]=v(e);return{levelDescriptions:n,handleLevelDescriptionChange:(r,l)=>{a(n.map((o,s)=>s===l?r:o))},addLevelDescription:r=>{a([...n,r])},removeLevelDescription:r=>{a(n.filter((l,o)=>o!==r))}}},Br=k(e=>({title:{fontWeight:700},filterContainer:{display:"flex",flexWrap:"wrap",padding:e.spacing(2)},description:{fontSize:e.typography.fontSize}})),Lt=({filters:e,setFilters:n,disabled:a})=>{const r=Br(),l=o=>s=>{n(o,s!=null?s:[])};return t.createElement(ke,{title:a?"Filters":"Filters (optional)"},t.createElement(u,{container:!0,item:!0,xs:12,spacing:2},!a&&t.createElement(u,{item:!0},t.createElement(C,{className:r.description},"Apply filters so it's only applicable to relevant entities.")),t.createElement(u,{item:!0,xs:12},t.createElement(Ne,null,t.createElement(u,{container:!0,className:r.filterContainer,spacing:2},gt.map(o=>t.createElement(u,{item:!0,xs:12,sm:6,md:4,key:o.stateKey},t.createElement(ht,{facet:o.facet,label:o.label,values:e[o.stateKey],onChange:l(o.stateKey),disabled:a}))))))))};var Gr=(e=>(e.SetFilter="SET_FILTER",e))(Gr||{});const zr={selectedKinds:[],selectedTypes:[],selectedLifecycles:[],selectedOwners:[],selectedSystems:[],selectedTags:[]},Wr=(e,n)=>{switch(n.type){case"SET_FILTER":return{...e,[n.key]:n.values};default:return e}},St=e=>{let n=zr;e&&(n=ct(e));const[a,r]=we(Wr,n);return{filters:a,setFilters:(l,o)=>{r({type:"SET_FILTER",key:l,values:o})}}},qr=k(e=>({regularFontSize:{fontSize:e.typography.fontSize,fontWeight:"bold"},description:{fontWeight:"normal",fontSize:e.typography.fontSize},root:{overflow:"hidden",display:"flex",padding:e.spacing(1),marginBottom:"53px"}})),Pt=({onSave:e,title:n,open:a,handleClose:r})=>{var l,o,s,c;const{selectedProgram:d,isLoading:m,setSelectedProgram:p}=oe(),{checkers:i,checkersLoading:h,chips:g,inputChipsList:E,handleDrop:f,handleDelete:x,addInput:L,removeInput:S,inputErrors:w,areInputsValid:N}=$r(d),{programName:P,programNameError:T,handleProgramNameChange:q,isProgramNameValid:ie}=Dr(d==null?void 0:d.name),{programDescription:B,programDescriptionError:ce,handleProgramDescriptionChange:de,isProgramDescriptionValid:me}=Or(d==null?void 0:d.description),pe=(o=d?(l=d.levels)==null?void 0:l.map(V=>{var U;return(U=V.name)!=null?U:`Level ${V.ordinal}`}):E.map((V,U)=>`Level ${U+1}`))!=null?o:[],{levelNames:J,handleLevelNameChange:ue,addLevelName:y,removeLevelName:O}=Mr(pe),b=(c=d?(s=d.levels)==null?void 0:s.map(V=>{var U;return(U=V.description)!=null?U:""}):E.map((V,U)=>""))!=null?c:[],{levelDescriptions:$,handleLevelDescriptionChange:ge,addLevelDescription:Tt,removeLevelDescription:Dt}=Vr(b),It=()=>{L(),y(`Level ${E.length+1}`),Tt("")},At=V=>{S(V),O(V),Dt(V)},{filters:Oe,setFilters:Rt}=St(d==null?void 0:d.filter),Ot=Fr({programName:P,programDescription:B,areInputsValid:N,isProgramNameValid:ie,isProgramDescriptionValid:me,inputChipsList:E,checkers:i,onSave:e,programId:d==null?void 0:d.id,levelNames:J,levelDescriptions:$,filters:Oe}),xe=qr(),Fe=Et(),K=d?!(d!=null&&d.isEditable):!1;return t.createElement(lt,{handleClose:r,title:n,open:a},t.createElement(u,{container:!0,spacing:4,className:xe.root},t.createElement(u,{item:!0,xs:12},t.createElement(u,{item:!0,xs:12},t.createElement(C,{className:Fe.sectionLabel,style:{margin:0}},"Track Details"),t.createElement(Ct,{disabled:m||K,programName:P,programNameError:T,handleProgramNameChange:q})),t.createElement(u,{item:!0,xs:12},t.createElement(Nt,{disabled:m||K,programDescription:B,programDescriptionError:ce,handleProgramDescriptionChange:de}))),t.createElement(u,{item:!0,xs:12},t.createElement(Lt,{disabled:K,filters:Oe,setFilters:Rt})),t.createElement(u,{item:!0,xs:12},t.createElement(u,{container:!0,spacing:4},t.createElement(u,{item:!0,xs:12},t.createElement(C,{className:Fe.sectionLabel,style:{margin:0}},"Track Levels"),!K&&t.createElement(C,{className:xe.description},"Add the checks that apply to each level. You can preview the checks to see the rules that apply to each check.")),!K&&t.createElement(u,{item:!0,xs:5},t.createElement(Er,{chips:g,isLoading:h||m,disabled:K})),t.createElement(u,{item:!0,xs:7},t.createElement(Nr,{inputChipsList:E,handleDelete:x,handleDrop:f,addInput:It,removeInput:At,levelsErrors:w,levelNames:J,handleLevelNameChange:ue,levelDescriptions:$,handleLevelDescriptionChange:ge,disabled:K}))))),t.createElement(u,{container:!0,spacing:4,className:xe.root},t.createElement(at,{onCancel:()=>{p(null),r()},saveButtonText:"Save Track",isLoading:m||h,onSave:Ot,disableSave:K})))},Kr=()=>{const{setIsLoading:e,setShowAddModal:n,showAddModal:a}=oe(),{mutateAsync:r,isLoading:l}=qa();return D(()=>{e(l)},[e,l]),t.createElement(Pt,{handleClose:()=>n(!1),title:"Create Track",open:a,onSave:async o=>{await r(o)&&n(!1)}})},Ur="Error Updating Track";function Hr(){const e=R(M),n=ae(),{showAlert:a}=Q(),r=async l=>{const o=await e.updateProgram(l);if(!o)throw new Error("Failed to update track.");return o};return ne([re.UpdateProgram],r,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[F.GetAllPrograms]})},onError:l=>{let o="Failed to update track.";l instanceof Error&&(o=l.message),a({severity:"error",title:Ur,message:o})}})}const jr=()=>{const{setSelectedProgram:e,setIsLoading:n,selectedProgram:a}=oe(),{mutateAsync:r,isLoading:l}=Hr();D(()=>n(l),[n,l]);const o=async s=>{await r(s)&&e(null)};return t.createElement(Pt,{handleClose:()=>e(null),title:a!=null&&a.isEditable?"Edit Track":"View Track",open:!!a,onSave:o})},_r=k(e=>({programsPageContainer:{padding:e.spacing(3)},headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap"}})),Qr=()=>{const{selectedProgram:e,showAddModal:n}=oe(),[a]=Ve(),r=a.get("tracksPerPage"),l=r?parseInt(r,10):10,o=_r(),s="Programs will now be referred to as Tracks throughout the Soundcheck UI.";return t.createElement("div",{className:o.programsPageContainer},t.createElement(Gt,{variant:"info",message:s,id:"programTrackBanner"}),t.createElement(Aa,{backend:Ra},t.createElement(dr,{programsPerPage:l}),n&&t.createElement(Kr,null),e&&t.createElement(jr,null)))},Jr=k(e=>({programsPageContainer:{padding:e.spacing(3)},lists:{padding:e.spacing(2)},checksDescription:{padding:"0 0 10px 5px"},levelHeader:{marginBottom:"10px"},chip:{marginTop:"10px"}})),Yr=({})=>{var e,n;const a=Jr(),r=window.location.pathname.split("tracks/")[1],{data:l,isLoading:o}=za(r||""),s=(e=l==null?void 0:l.edges[0])==null?void 0:e.program,{filters:c,setFilters:d}=St(s==null?void 0:s.filter),m=()=>{window.open("/soundcheck/tracks","_self")};return t.createElement(t.Fragment,null,t.createElement("div",{className:a.programsPageContainer},o?"loading":t.createElement(u,{container:!0,spacing:3},t.createElement(u,{item:!0,xs:12},t.createElement(C,{variant:"h4"},"Owner: ",s==null?void 0:s.ownerEntityRef)),t.createElement(u,{item:!0,xs:12},t.createElement(Ct,{disabled:!0,programName:s?s.name:"",programNameError:!1,handleProgramNameChange:()=>null})),t.createElement(u,{item:!0,xs:12},t.createElement(Nt,{disabled:!0,programDescription:s!=null&&s.description?s.description:"",programDescriptionError:!1,handleProgramDescriptionChange:()=>null})),t.createElement(u,{item:!0,xs:12},t.createElement(Lt,{disabled:!0,filters:c,setFilters:d})),t.createElement(u,{item:!0,xs:12},t.createElement(Le,null,t.createElement(We,null,t.createElement(u,{container:!0,spacing:4},t.createElement(u,{item:!0,xs:12},t.createElement(be,{dense:!0,className:a.lists},(n=s==null?void 0:s.levels)==null?void 0:n.map((p,i)=>t.createElement("div",{key:`levels-${i}`},t.createElement(C,{className:a.levelHeader,variant:"h6"},p.name),t.createElement(_,null,"Description: ",p.description),t.createElement(be,{key:`levels-${i}`,dense:!0,className:a.lists},t.createElement(C,{variant:"h6"},"Checks"),p.checks.map((h,g)=>t.createElement("div",{key:`checks-${g}`},t.createElement(Pe,{key:h.name+g,label:h.name,className:a.chip}),t.createElement(Z,{divider:!0,className:a.checksDescription},h.description)))))))))))))),t.createElement(A,{variant:"contained",color:"primary",onClick:m},"Track List"))},Zr=()=>{const e=window.location.pathname.split("tracks/");return t.createElement(Ha,null,e[1]?t.createElement(Yr,null):t.createElement(Qr,null))},Xr=k(()=>({tabContent:{margin:0,padding:0}})),el=({title:e="Soundcheck"})=>{const n=Xr(),[a,r]=la(),{group:l}=a,[o,s]=v(void 0),c=m=>{m&&r({...a,group:m})},d=Ft();return t.createElement(ua,null,t.createElement(oa,null,t.createElement(ga,null,t.createElement(ha,null,t.createElement(zt,{themeId:"website"},t.createElement(qt,{backend:"soundcheck",invalidLicenseMessage:"Submitted facts and check results will still be stored, but it will not be possible to view certifications or individual results until a valid license is present."}),t.createElement(Wt,{title:e},d.pathname.split("/").length-1===1&&t.createElement(sa,{onChange:c,initialValue:l,setError:s})),t.createElement($t,null,t.createElement(Mt,{path:"/*",element:t.createElement(fe,null,t.createElement(fe.Route,{title:"Overview",path:"/"},t.createElement("div",{className:n.tabContent},t.createElement(ia,{groupSelectorError:o,searchParams:a,setSearchParams:r}))),t.createElement(fe.Route,{title:"Checks",path:"/checks"},t.createElement(ar,null)),t.createElement(fe.Route,{title:"Tracks",path:"/tracks"},t.createElement(Zr,null)))})))))))};export{el as RoutingPage};
|
|
2
|
-
//# sourceMappingURL=index-ee6cc5f1.esm.js.map
|