@spotify/backstage-plugin-soundcheck 0.5.0 → 0.6.1

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.
@@ -1,284 +0,0 @@
1
- import{createApiRef as Ne,createRouteRef as T,createSubRouteRef as v,createPlugin as Ie,createApiFactory as De,discoveryApiRef as Le,fetchApiRef as Ae,createRoutableExtension as q,createComponentExtension as Fe,useApi as B,errorApiRef as xe,useRouteRef as j}from"@backstage/core-plugin-api";import{GraphQLClient as Oe}from"graphql-request";import l from"graphql-tag";import a,{createContext as V,useState as b,useCallback as E,useContext as K,useRef as Te,useEffect as qe,Fragment as Be}from"react";import{QueryClient as Me,QueryClientProvider as ze,useQuery as _}from"@tanstack/react-query";import{memoize as Ue}from"lodash";import We from"@material-ui/core/styles/makeStyles";import{makeStyles as p,Typography as d,Modal as Ge,Box as J,Button as X,Fade as He,alpha as C,Tooltip as Qe,withStyles as S,Divider as je}from"@material-ui/core";import{MarkdownContent as Y,Link as Z,EmptyState as ee,InfoCard as Ve}from"@backstage/core-components";import{useEntity as te,humanizeEntityRef as Ke}from"@backstage/plugin-catalog-react";import{useAutoUpdatingRelativeTime as _e,SpotifyLicenseBanner as Je}from"@spotify/backstage-plugin-core";import{stringifyEntityRef as re,parseEntityRef as Xe}from"@backstage/catalog-model";import{Alert as Ye,Skeleton as f}from"@material-ui/lab";import{Link as Ze}from"react-router-dom";import P from"classnames";import et from"@material-ui/icons/Schedule";import{DateTime as ae}from"luxon";import tt from"@material-ui/icons/Check";import rt from"@material-ui/icons/Close";import at from"@material-ui/icons/RemoveCircleOutline";import nt from"@material-ui/icons/HelpOutline";var ne=(e=>(e.Medal="MEDAL",e))(ne||{}),h=(e=>(e.Failed="FAILED",e.NotApplicable="NOT_APPLICABLE",e.NotReported="NOT_REPORTED",e.Passed="PASSED",e))(h||{});const it=l`
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
- `,ot=l`
24
- fragment check on Check {
25
- id
26
- name
27
- description
28
- }
29
- `,ct=l`
30
- fragment level on Level {
31
- ordinal
32
- name
33
- description
34
- checks {
35
- ...check
36
- }
37
- }
38
- ${ot}`,st=l`
39
- fragment CheckResultSummary on CheckResult {
40
- id
41
- name
42
- result
43
- timestamp
44
- }
45
- `,lt=l`
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
- ${st}`,mt=l`
65
- fragment CheckResultDetails on CheckResult {
66
- id
67
- name
68
- description
69
- result
70
- timestamp
71
- notes
72
- }
73
- `,dt=l`
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=l`
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
- `,ut=l`
106
- mutation createCheck($input: CheckerInput!) {
107
- check: createChecker(input: $input) {
108
- id
109
- filter
110
- name
111
- description
112
- }
113
- }
114
- `,pt=l`
115
- mutation createProgram($input: ProgramInput!) {
116
- program: createProgram(input: $input) {
117
- id
118
- ownerEntityRef
119
- name
120
- description
121
- documentationURL
122
- }
123
- }
124
- `,gt=l`
125
- mutation deleteChecker($checkerId: String!) {
126
- deleteChecker(checkerId: $checkerId)
127
- }
128
- `,ht=l`
129
- mutation deleteProgram($programId: String!) {
130
- programDeleted: deleteProgram(programId: $programId)
131
- }
132
- `,ft=l`
133
- mutation updateCheck($input: CheckerInput!) {
134
- check: updateChecker(input: $input) {
135
- id
136
- filter
137
- name
138
- description
139
- }
140
- }
141
- `,kt=l`
142
- mutation updateProgram($input: ProgramInput!) {
143
- program: updateProgram(input: $input) {
144
- id
145
- ownerEntityRef
146
- name
147
- description
148
- documentationURL
149
- }
150
- }
151
- `,yt=l`
152
- query getAllCertifications($entityRef: String!) {
153
- certifications(entityRef: $entityRef, includeFilteredChecks: false) {
154
- ...CertificationSummary
155
- }
156
- }
157
- ${it}`,vt=l`
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
- levels {
172
- ...level
173
- }
174
- isEditable
175
- }
176
- }
177
- }
178
- }
179
- ${ct}`,Et=l`
180
- query getCertificationDetails($entityRef: String!, $programId: String!) {
181
- programCertification(
182
- entityRef: $entityRef
183
- programId: $programId
184
- includeFilteredChecks: false
185
- ) {
186
- program {
187
- id
188
- name
189
- description
190
- documentationURL
191
- }
192
- highestLevel {
193
- ...HighestLevel
194
- }
195
- levels {
196
- ...LevelResultDetails
197
- }
198
- }
199
- }
200
- ${ie}
201
- ${lt}`,Ct=l`
202
- query getCheckResultDetails($entityRef: String!, $programId: String!, $checkId: String!) {
203
- checkResult(entityRef: $entityRef, programId: $programId, checkId: $checkId) {
204
- ...CheckResultDetails
205
- }
206
- }
207
- ${mt}`,wt=l`
208
- query getCheckers($ids: [String!], $first: Int, $after: String, $orderAlphabetical: String, $searchByOwner: String, $searchByName: String) {
209
- checkers(
210
- ids: $ids
211
- first: $first
212
- after: $after
213
- orderAlphabetical: $orderAlphabetical
214
- searchByOwner: $searchByOwner
215
- searchByName: $searchByName
216
- ) {
217
- totalCount
218
- endCursor
219
- hasNextPage
220
- edges {
221
- cursor
222
- checker {
223
- id
224
- ownerEntityRef
225
- name
226
- description
227
- rule
228
- passedMessage
229
- failedMessage
230
- isEditable
231
- schedule {
232
- ... on Frequency {
233
- cron
234
- }
235
- ... on HumanDuration {
236
- years
237
- months
238
- weeks
239
- days
240
- hours
241
- minutes
242
- seconds
243
- milliseconds
244
- }
245
- }
246
- }
247
- }
248
- }
249
- }
250
- `,Rt=l`
251
- query getFacetsForOwner($ownerEntityRef: String!) {
252
- facetsForOwner(ownerEntityRef: $ownerEntityRef) {
253
- types {
254
- kind
255
- type
256
- count
257
- }
258
- }
259
- }
260
- `,$t=l`
261
- query getProgramOverviewForOwner($ownerEntityRef: String!, $facet: FacetInput) {
262
- programOverviewForOwner(
263
- ownerEntityRef: $ownerEntityRef
264
- facet: $facet
265
- includeFilteredChecks: false
266
- ) {
267
- programs {
268
- program {
269
- id
270
- name
271
- }
272
- highestLevels {
273
- ...HighestLevel
274
- }
275
- levels {
276
- ...OverviewLevelResult
277
- }
278
- }
279
- entityRefs
280
- }
281
- }
282
- ${ie}
283
- ${dt}`,bt=(e,t,r)=>e();function St(e,t=bt){return{createCheck(r,n){return t(i=>e.request(ut,r,{...n,...i}),"createCheck","mutation")},createProgram(r,n){return t(i=>e.request(pt,r,{...n,...i}),"createProgram","mutation")},deleteChecker(r,n){return t(i=>e.request(gt,r,{...n,...i}),"deleteChecker","mutation")},deleteProgram(r,n){return t(i=>e.request(ht,r,{...n,...i}),"deleteProgram","mutation")},updateCheck(r,n){return t(i=>e.request(ft,r,{...n,...i}),"updateCheck","mutation")},updateProgram(r,n){return t(i=>e.request(kt,r,{...n,...i}),"updateProgram","mutation")},getAllCertifications(r,n){return t(i=>e.request(yt,r,{...n,...i}),"getAllCertifications","query")},getAllPrograms(r,n){return t(i=>e.request(vt,r,{...n,...i}),"getAllPrograms","query")},getCertificationDetails(r,n){return t(i=>e.request(Et,r,{...n,...i}),"getCertificationDetails","query")},getCheckResultDetails(r,n){return t(i=>e.request(Ct,r,{...n,...i}),"getCheckResultDetails","query")},getCheckers(r,n){return t(i=>e.request(wt,r,{...n,...i}),"getCheckers","query")},getFacetsForOwner(r,n){return t(i=>e.request(Rt,r,{...n,...i}),"getFacetsForOwner","query")},getProgramOverviewForOwner(r,n){return t(i=>e.request($t,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)),w=(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),N,I,m,z,u;const D=Ne({id:"plugin.soundcheck"}),Pt=e=>"response"in e&&"errors"in e.response,Nt=e=>"response"in e&&"message"in e.response;class It{constructor(t){w(this,N,void 0),w(this,I,void 0),w(this,m,void 0),w(this,z,n=>{var i,c,s;return Pt(n)?(s=(c=(i=n.response)==null?void 0:i.errors)==null?void 0:c[0].message)!=null?s:`${n}`:Nt(n)?n.response.message:`${n}`}),w(this,u,async n=>{try{return await n()}catch(i){throw new Error(`Error from Soundcheck backend: ${o(this,z).call(this,i)}`)}}),M(this,N,t.fetchApi),M(this,I,t.discoveryApi);const r=new Oe("/graphql",{fetch:async(n,i)=>{const c=`${await o(this,I).getBaseUrl("soundcheck")}${n}`;return o(this,N).fetch(c,i)}});M(this,m,St(r))}async getAllCertifications(t){return o(this,u).call(this,async()=>{const{certifications:r}=await o(this,m).getAllCertifications({entityRef:t});return r})}async getCertificationDetails(t,r){return o(this,u).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,u).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,u).call(this,async()=>{const{facetsForOwner:r}=await o(this,m).getFacetsForOwner({ownerEntityRef:t});return r})}async getProgramOverviewForOwner(t,r){return o(this,u).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,u).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,u).call(this,async()=>{const{program:r}=await o(this,m).createProgram({input:t});return r})}async updateProgram(t){return o(this,u).call(this,async()=>{const{program:r}=await o(this,m).updateProgram({input:t});return r})}async deleteProgram(t){return o(this,u).call(this,async()=>{const{programDeleted:r}=await o(this,m).deleteProgram({programId:t});return r})}async getCheckers(t,r,n){return o(this,u).call(this,async()=>{const{checkers:i}=await o(this,m).getCheckers({ids:t,first:r,after:n});return i})}async createChecker(t){return o(this,u).call(this,async()=>{const{check:r}=await o(this,m).createCheck({input:t});return r})}async updateChecker(t){return o(this,u).call(this,async()=>{const{check:r}=await o(this,m).updateCheck({input:t});return r})}async deleteChecker(t){return o(this,u).call(this,async()=>await o(this,m).deleteChecker({checkerId:t}))}}N=new WeakMap,I=new WeakMap,m=new WeakMap,z=new WeakMap,u=new WeakMap;const L=T({id:"soundcheck-entity"}),ce=v({id:"soundcheck-entity-certification-track-redirect",parent:L,path:"/:trackId"}),se=v({id:"soundcheck-entity-certification",parent:L,path:"/:trackId/:checkId"}),Dt=T({id:"soundcheck-overview"}),A=T({id:"soundcheck"});v({id:"soundcheck-checks",parent:A,path:"/checks"}),v({id:"soundcheck-tracks",parent:A,path:"/tracks"}),v({id:"soundcheck-track-details",parent:A,path:"/tracks/:trackId"});const R=Ie({id:"soundcheck",apis:[De({api:D,deps:{discoveryApi:Le,fetchApi:Ae},factory:e=>new It(e)})],routes:{entityContent:L}}),Lt=R.provide(q({name:"EntitySoundcheckContent",component:()=>import("./EntitySoundcheckContent-8fdad07c.esm.js").then(e=>e.EntitySoundcheckContent),mountPoint:L})),At=R.provide(Fe({name:"EntitySoundcheckCard",component:{lazy:()=>import("./index-b3600988.esm.js").then(e=>e.EntitySoundcheckCard)}})),Ft=R.provide(q({name:"SoundcheckOverviewPage",component:()=>import("./index-92271e48.esm.js").then(e=>e.OverviewPage),mountPoint:Dt})),xt=R.provide(q({name:"SoundcheckRoutingPage",component:()=>import("./index-0a05659f.esm.js").then(e=>e.RoutingPage),mountPoint:A})),Ot=Ue(e=>new Me({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)}}})),Tt=e=>{const t=B(xe),r=Ot(t);return a.createElement(ze,{client:r},e.children)};function le(e){const t=B(D),r=re(e);return _(["soundcheck/certifications",r],async()=>t.getAllCertifications(r))}function me(e,t){const r=B(D),n=re(e);return _(["soundcheck/certifications",n,t],async()=>r.getCertificationDetails(n,t),{enabled:!!t})}var de=(e=>(e.GetAllPrograms="soundcheck/programs",e.GetCheckers="soundcheck/checkers",e))(de||{}),ue=(e=>(e.DeleteChecker="soundcheck/deleteChecker",e.CreateChecker="soundcheck/createChecker",e.UpdateChecker="soundcheck/updateChecker",e.DeleteProgram="soundcheck/deleteProgram",e.CreateProgram="soundcheck/createProgram",e.UpdateProgram="soundcheck/updateProgram",e))(ue||{});const qt=p(e=>({root:{padding:e.spacing(3)},icon:{display:"none"},message:{padding:0},type:{fontWeight:700,lineHeight:1.75}})),F=e=>{const{type:t,...r}=qt();return a.createElement(Ye,{severity:e.severity,elevation:1,classes:r,onClose:e.onClose},a.createElement(d,{classes:{root:t}},e.title),e.children)},pe=V({}),Bt=e=>{const[t,r]=b(),n=E(c=>{r(c)},[]),i=E(()=>{r(null)},[]);return a.createElement(pe.Provider,{value:{showAlert:n,clearAlert:i}},t&&a.createElement(F,{severity:t.severity,title:t.title,onClose:i},t.message),e.children)},Mt=()=>K(pe),zt=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"}})),ge=V({}),Ut=e=>{const t=zt(),[r,n]=b(!1),[i,c]=b(),s=Te(),g=E(({title:$,message:Se})=>(c({title:$,message:Se}),n(!0),new Promise(Pe=>{s.current=Pe})),[]),y=E(()=>{s.current&&s.current(!0),n(!1)},[]),k=E(()=>{s.current&&s.current(!1),n(!1)},[]);return a.createElement(ge.Provider,{value:{showModal:g}},e.children,i&&a.createElement(Ge,{open:r,onClose:k,"aria-labelledby":"confirmation-modal-title","aria-describedby":"confirmation-modal-description"},a.createElement(J,{className:t.modalContent},a.createElement(d,{id:"confirmation-modal-title",variant:"h6"},i.title),a.createElement(d,{className:t.modalMessage,id:"confirmation-modal-description",variant:"body1"},i.message),a.createElement("div",{className:t.modalButtons},a.createElement(X,{onClick:k,variant:"contained","aria-label":"cancel"},"Cancel"),a.createElement(X,{color:"primary",onClick:y,variant:"contained","aria-label":"confirm"},"Confirm")))))},Wt=()=>K(ge),he=24,Gt=11,U=e=>e==="small"?1:2,Ht=p({root:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",borderWidth:"2px",fontWeight:700,width:({size:e})=>`${he*U(e)}px`,height:({size:e})=>`${he*U(e)}px`,fontSize:({size:e})=>`${Gt*U(e)}px`}}),fe=({className:e,label:t,size:r="small"})=>{const n=Ht({size:r});return a.createElement("span",{className:P(e,n.root),role:"img","aria-label":`${t} badge`},t)},Qt=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(",")}}})),W=({className:e,badge:t,size:r="small"})=>{const n=Qt({color:t.options.color,size:r});return a.createElement(fe,{className:P(e,n.root),size:r,label:`L${t.options.level}`})},jt=p({root:{borderColor:"currentColor",borderStyle:"dashed"}}),ke=({className:e,size:t="small"})=>{const r=jt();return a.createElement(fe,{className:P(e,r.root),size:t,label:"NL"})},G=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 Vt({description:e,documentationUrl:t}){const r=G();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=G();return a.createElement("div",{className:c.root},r?a.createElement(W,{size:"large",badge:r}):a.createElement(ke,{size:"large"}),a.createElement("div",null,a.createElement(d,{variant:"caption",className:c.level},t!=null?t:"No Level"),a.createElement(d,{className:c.title},e),n&&a.createElement(Vt,{description:n,documentationUrl:i})))},x=({children:e})=>{const[t,r]=b(!1);return qe(()=>{const n=setTimeout(()=>{r(!0)},250);return()=>clearTimeout(n)},[]),a.createElement(He,{in:t,timeout:250},e)},H=({hideDescription:e=!1})=>{const t=G();return a.createElement(x,null,a.createElement("div",{className:t.root},a.createElement(f,{width:44,height:44}),a.createElement("div",null,a.createElement(d,{variant:"caption",className:t.level},a.createElement(f,{width:100})),a.createElement(d,{variant:"h4",className:t.title},a.createElement(f,{width:300})),!e&&a.createElement(d,{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:C(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:C(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:C(e.palette.getContrastText(t),.8),fontSize:e.typography.subtitle2.fontSize,marginTop:e.spacing(1)}}}),Kt=e=>{const t=ve({badge:e.badge});return a.createElement("div",{className:t.wrapper},e.badge?a.createElement(W,{className:t.badge,badge:e.badge}):null,a.createElement(d,{className:t.title},e.title),e.description?a.createElement(d,{className:t.description},e.description):null)},_t=()=>{const e=ve({});return a.createElement(x,null,a.createElement("div",{className:e.wrapper},a.createElement(f,{className:e.title}),a.createElement(d,{className:e.description},a.createElement(f,null))))},Jt=p(e=>({root:{display:"inline-flex",alignItems:"center",gap:e.spacing(1)}})),Ee=({timestamp:e,description:t})=>{const r=Jt(),n=ae.fromISO(e).toLocaleString(ae.DATETIME_FULL),i=_e(e),c=t?`${t}: ${i}`:void 0;return a.createElement("div",{className:r.root},a.createElement(Qe,{title:n},a.createElement(d,{variant:"caption","aria-label":c},i)),a.createElement(et,null))},Xt=e=>({[h.Passed]:"Check passed",[h.NotReported]:"Check not reported",[h.Failed]:"Check failed",[h.NotApplicable]:"Check not applicable"})[e],Yt=S(e=>({root:{color:e.palette.success.main}}))(tt),Zt=S(e=>({root:{color:e.palette.error.main}}))(rt),er=S(e=>({root:{color:e.palette.info.main}}))(nt),tr=S(e=>({root:{color:e.palette.text.disabled}}))(at),Ce=({result:e,className:t})=>{const r={className:t,"aria-label":Xt(e),"aria-hidden":!1};return e===h.Passed?a.createElement(Yt,{...r}):e===h.NotReported?a.createElement(er,{...r}):e===h.Failed?a.createElement(Zt,{...r}):e===h.NotApplicable?a.createElement(tr,{...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:C(e.palette.primary[e.palette.type],.2)},"&:hover, &:active, &:focus":{backgroundColor:C(e.palette.primary[e.palette.type],.3)}}})),rr=({className:e,href:t,children:r})=>t?a.createElement(Ze,{to:t,className:e},r):a.createElement("div",{className:e},r),ar=({result:e,name:t,timestamp:r,selected:n=!1,href:i})=>{const c=we(),s=P(c.root,{selected:n});return a.createElement(rr,{href:i,className:s},a.createElement(Ce,{result:e}),a.createElement(d,{variant:"body2"},t),r?a.createElement(Ee,{timestamp:r}):null)},Q=()=>{const e=we();return a.createElement(x,null,a.createElement("div",{className:e.root},a.createElement(f,{width:24,height:24}),a.createElement(d,{variant:"body2"},a.createElement(f,null)),a.createElement(f,{width:100,height:24})))},nr=()=>{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(_t,null),a.createElement("ul",{className:e.checks},a.createElement(Q,null),a.createElement(Q,null),a.createElement(Q,null)))))},ir=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"}}})),or=({checks:e,trackId:t,checkId:r})=>{const n=ir(),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(ar,{...c,selected:c.id===r,href:i({trackId:t,checkId:c.id})})))):a.createElement(d,{variant:"body2",className:n.noChecks},"No applicable checks at this level.")},cr=({level:e,checkId:t,trackId:r})=>{var n;return a.createElement(a.Fragment,null,a.createElement(Kt,{badge:e.badge,title:e.name,description:e.description}),a.createElement(or,{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"}})),sr=({trackId:e,checkId:t})=>{var r,n;const i=Re(),{entity:c}=te(),{data:s,isLoading:g,isError:y}=me(c,e);return y?a.createElement("div",{className:i.root},a.createElement(J,{padding:2},a.createElement(F,{severity:"error",title:"Error loading certification"}))):g||!e?a.createElement(nr,null):s?a.createElement("div",{className:i.root},a.createElement(ye,{name:s.program.name,level:(r=s.highestLevel)==null?void 0:r.name,badge:(n=s.highestLevel)==null?void 0:n.badge,description:s.program.description,documentationUrl:s.program.documentationURL}),s==null?void 0:s.levels.map(k=>a.createElement(cr,{key:k.ordinal,level:k,checkId:t,trackId:e}))):null},lr=()=>a.createElement(a.Fragment,null,a.createElement(H,{hideDescription:!0}),a.createElement(H,{hideDescription:!0})),$e=({className:e})=>a.createElement("div",{className:e},a.createElement(ee,{title:"No certifications available",missing:"data",description:"There are no tracks configured that apply to this entity."})),mr=({ownerEntityRef:e})=>e?a.createElement(ee,{missing:"data",title:"Missing entities",description:a.createElement(a.Fragment,null,"Looks like the group"," ",Ke(Xe(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,be=We(e=>({certificationWrapper:{display:"flex",justifyContent:"space-between",alignItems:"center"},infoCard:{display:"grid",gridRowGap:e.spacing(2)},emptyState:{"& > div":{backgroundColor:e.palette.background.paper}}})),O=({children:e,title:t})=>{const r=be();return a.createElement(Ve,{title:t},a.createElement("div",{className:r.infoCard},a.createElement(Je,{inline:!0,backend:"soundcheck",invalidLicenseMessage:"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."}),e))},dr=({title:e="Soundcheck"})=>{const{entity:t}=te(),r=be(),{data:n,isError:i,isLoading:c}=le(t),s=j(ce);return i?a.createElement(O,{title:e},a.createElement(F,{severity:"error",title:"Error loading certifications"})):c||!n?a.createElement(O,{title:e},a.createElement(lr,null)):n.length===0?a.createElement(O,{title:e},a.createElement($e,{className:r.emptyState})):a.createElement(O,{title:e},n.map((g,y)=>{var k,$;return a.createElement(Be,{key:g.program.name},a.createElement("div",{className:r.certificationWrapper,"data-testid":"soundcheck-track-row"},a.createElement(ye,{key:g.program.id,name:g.program.name,badge:(k=g.highestLevel)==null?void 0:k.badge,level:($=g.highestLevel)==null?void 0:$.name}),a.createElement(Z,{to:s({trackId:g.program.id})},"View Details")),y<n.length-1?a.createElement(je,null):null)}))};export{F as A,ne as B,sr as C,Lt as E,x as F,W as L,ue as M,ke as N,Ut as P,de as Q,h as R,Tt as S,Ee as a,le as b,ce as c,$e as d,se as e,dr as f,Ce as g,mr as h,Bt as i,Mt as j,R as k,At as l,Ft as m,xt as n,D as s,me as u,Wt as w};
284
- //# sourceMappingURL=index-40aa00c1.esm.js.map
@@ -1,2 +0,0 @@
1
- import t,{useState as P,useEffect as v,useMemo as I,useCallback as G,memo as k,Fragment as de}from"react";import{useSearchParams as pe,Routes as me,Route as S}from"react-router-dom";import{HeaderTabs as M,Link as O,EmptyState as ue,Page as ge,Header as he,Content as fe}from"@backstage/core-components";import{useApi as b,identityApiRef as ye,useRouteRef as F,configApiRef as j}from"@backstage/core-plugin-api";import{SpotifyLicenseBanner as Ee}from"@spotify/backstage-plugin-core";import{makeStyles as h,alpha as D,TextField as ve,CircularProgress as ke,Tooltip as K,LinearProgress as be,withStyles as Ce,Grid as C,Typography as E,Button as _}from"@material-ui/core";import we from"@material-ui/lab/Autocomplete";import{stringifyEntityRef as Q,parseEntityRef as $}from"@backstage/catalog-model";import{useQuery as A}from"@tanstack/react-query";import{s as U,R as w,g as Ne,B as Re,L as q,N as J,A as $e,h as xe,S as Te,P as Pe,i as Le}from"./index-40aa00c1.esm.js";import{catalogApiRef as X,humanizeEntityRef as L,entityRouteRef as B}from"@backstage/plugin-catalog-react";import{R as Ie}from"./RefetchingIndicator-0caa936c.esm.js";import{countBy as Y}from"lodash";import{Skeleton as H}from"@material-ui/lab";import{VariableSizeGrid as Se}from"react-window";import{C as Oe,P as Fe}from"./CheckFormContext-6f85a3bf.esm.js";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/Close";import"@material-ui/icons/RemoveCircleOutline";import"@material-ui/icons/HelpOutline";import"react-use/lib/useDebounce";function Ae(){const e=b(X);return A(["soundcheck/all-groups"],async()=>{const{items:r}=await e.getEntities({filter:{kind:"Group"}});return r.filter(a=>(a==null?void 0:a.kind)==="Group").map(a=>{var n,l,o,i;return{name:(i=(o=(l=(n=a.spec)==null?void 0:n.profile)==null?void 0:l.displayName)!=null?o:a.metadata.title)!=null?i:a.metadata.name,ref:Q(a)}})})}function Be(e){const r=b(U);return A(["soundcheck/facets-for-owner",e],async()=>r.getFacetsForOwner(e),{enabled:!!e})}function Z(e,r){const a=b(U);return A(["soundcheck/track-overview-for-owner",e,r],async()=>a.getProgramOverviewForOwner(e,r),{enabled:!!e&&!!(r!=null&&r.kind)})}function He(){const e=b(ye),r=b(X);return A(["soundcheck/user-groups-claims"],async()=>{const{ownershipEntityRefs:a}=await e.getBackstageIdentity();return(await r.getEntitiesByRefs({entityRefs:a})).items.filter(n=>(n==null?void 0:n.kind)==="Group").map(n=>{var l,o,i,c;return{name:(c=(i=(o=(l=n.spec)==null?void 0:l.profile)==null?void 0:o.displayName)!=null?i:n.metadata.title)!=null?c:n.metadata.name,ref:Q(n)}})})}const ze=()=>{const[e,r]=pe(),a=Object.fromEntries(e.entries()),[n,l]=P(a);return v(()=>{r(n,{replace:!0})},[n]),[n,l]},We=()=>{const{data:e,isLoading:r,isError:a}=He(),{data:n,isLoading:l,isError:o}=Ae();return{options:I(()=>{const i=[];return e&&i.push(...e.map(({name:c,ref:s})=>({name:c,ref:s,key:"My Groups"}))),n&&i.push(...n.map(({name:c,ref:s})=>({name:c,ref:s,key:"All Groups"}))),i},[e,n]),isLoading:r||l,isError:a||o}},Ve=h(e=>({root:{width:"100%",minWidth:250},textField:{"& $notchedOutline":{borderColor:D(e.page.fontColor,.25)},"&:hover $notchedOutline":{borderColor:e.page.fontColor}},input:{backgroundColor:"transparent",color:e.page.fontColor},clearIndicator:{color:e.page.fontColor},popupIndicator:{color:e.page.fontColor},notchedOutline:{}})),Ge=e=>{const{onChange:r,initialValue:a,setError:n}=e,{options:l,isLoading:o,isError:i}=We(),c=Ve(),[s,d]=P(null);v(()=>{if(!o&&l!=null&&l.length&&!s){const m=a?l.find(p=>p.ref===a):l[0];m&&(d(m),r==null||r(m.ref))}},[o,l,s,r,a]);const u=G((m,p)=>{d(p),r==null||r(p==null?void 0:p.ref)},[r,d]);return v(()=>{n==null||n(i?new Error("Error loading groups"):void 0)},[i,n]),i?null:t.createElement(we,{"aria-label":"Current group",className:c.root,classes:{clearIndicator:c.clearIndicator,popupIndicator:c.popupIndicator},disableClearable:!0,options:l!=null?l:[],loading:o,groupBy:m=>m.key,value:s,freeSolo:!1,onChange:u,getOptionLabel:m=>m.name,renderInput:m=>t.createElement(ve,{...m,variant:"outlined",placeholder:o?"Loading":"Select a group",className:c.textField,InputProps:{...m.InputProps,className:c.input,classes:{notchedOutline:c.notchedOutline},endAdornment:t.createElement(t.Fragment,null,o?t.createElement(ke,{color:"inherit",size:20}):null,m.InputProps.endAdornment)}})})},Me=()=>t.createElement(t.Fragment,null,"Fact Collectors Page"),je=e=>({key:`skeleton${e}`,label:"",id:`skeleton${e}`}),De=()=>{const e=Array.from({length:4},(r,a)=>je(a));return t.createElement(M,{tabs:e})},Ke=h(e=>({root:{borderTop:`1px solid ${e.palette.divider}`,borderBottom:`1px solid ${e.palette.divider}`},tab:{textTransform:"uppercase",paddingTop:e.spacing(2),paddingBottom:e.spacing(2)}})),_e=({unfilteredFacets:e,onChange:r,kind:a,type:n})=>{var l,o,i;const c=Ke(),s={types:(l=e==null?void 0:e.types.filter(({count:p})=>p>0))!=null?l:[]},d=G(p=>{var g;r((g=s==null?void 0:s.types[p].kind)!=null?g:"",s==null?void 0:s.types[p].type)},[s==null?void 0:s.types,r]);v(()=>{var p,g,y;const f=(s==null?void 0:s.types)&&s.types.length>=0,x=!a&&f,R=a&&f&&!(s!=null&&s.types.find(({kind:T,type:V})=>a===T&&(!n&&!V||n===V)));(x||R)&&r((g=(p=s==null?void 0:s.types[0])==null?void 0:p.kind)!=null?g:"",(y=s==null?void 0:s.types[0])==null?void 0:y.type)},[a,n,s==null?void 0:s.types,r]);const u=(o=s==null?void 0:s.types.map(({kind:p,type:g,count:y})=>{const f=`${p}|${g!=null?g:""}`;return{key:f,label:`${g!=null?g:p} (${y>50?"50+":y})`,id:f,tabProps:{className:c.tab}}}))!=null?o:[];if(!u.length)return null;const m=(i=s==null?void 0:s.types.findIndex(p=>p.kind===a&&(!p.type&&!n||p.type===n)))!=null?i:-1;return t.createElement(t.Fragment,null,t.createElement(Ie,null),t.createElement(M,{onChange:d,tabs:u,selectedIndex:m>-1?m:void 0}))},Qe=h(e=>({root:{height:"8px",minWidth:"64px",marginLeft:e.spacing(2),borderRadius:"100vh",backgroundColor:e.palette.background.default},bar:{backgroundColor:e.palette.success.main,transition:"none"}})),ee=e=>{var r,a;const n=Qe(e),l=I(()=>Object.entries(e.progress).reduce((i,[,c])=>i+c,0),[e.progress]);if(l===0)return null;const o=(r=e.progress[w.Passed])!=null?r:0;return t.createElement(K,{arrow:!0,title:`Check passing for ${o} of ${l} ${l===1?"entity":"entities"}`,enterDelay:0,placement:"top"},t.createElement(be,{variant:"determinate",value:((a=e.progress[w.Passed])!=null?a:0)/l*100,classes:{root:n.root,bar:n.bar}}))},Ue=h(e=>({headerWrapper:{marginTop:e.spacing(.5)},entityRefName:{fontWeight:"bold"},iconWrapper:{padding:e.spacing(1.5,.5),display:"flex",alignItems:"center",justifyContent:"center"}})),qe=({check:{name:e,description:r},icon:a,entityRef:n})=>{const l=Ue(),o=$(n);return t.createElement(C,{spacing:1},t.createElement(C,{container:!0,direction:"row",spacing:1,wrap:"nowrap"},t.createElement("div",{className:l.iconWrapper},a),t.createElement(E,{variant:"h6",className:l.headerWrapper,noWrap:!0},e)),t.createElement(C,{item:!0,wrap:"nowrap"},t.createElement(E,{variant:"subtitle2",className:l.entityRefName},L(o,{defaultKind:o.kind}))),t.createElement(E,{variant:"caption"},r))},Je=Ce(e=>{const r=e.palette.type==="dark"?e.palette.common.black:e.palette.grey[300];return{tooltip:{backgroundColor:r,color:e.palette.type==="dark"?e.palette.common.white:e.palette.grey[700]},arrow:{color:r}}})(K),Xe=({children:e,check:r,icon:a,entityRef:n})=>t.createElement(Je,{arrow:!0,title:t.createElement(qe,{check:r,icon:a,entityRef:n}),enterDelay:150,placement:"top"},e),Ye=h(e=>({root:{padding:0},iconWrapper:{padding:e.spacing(1.5),display:"flex",alignItems:"center",justifyContent:"center"},link:{"&:hover $iconWrapper, &:active $iconWrapper, &:focus $iconWrapper":{backgroundColor:e.palette.infoBackground}},icon:{width:"17px",height:"17px"},virtualized:{borderBottom:`1px solid ${e.palette.divider}`,borderRight:`1px solid ${e.palette.divider}`}})),te=k(({programId:e,check:r,entityRef:a,result:n,entityRoute:l,isVirtualized:o})=>{const i=Ye();if(typeof a!="string"){const u=t.createElement("div",{className:i.iconWrapper},t.createElement("div",{className:i.icon}));return o?t.createElement("div",{className:`${i.root} ${i.virtualized}`,"aria-hidden":!0},u):t.createElement("td",{className:i.root,"aria-hidden":!0},u)}const c=t.createElement(Ne,{className:i.icon,result:n!=null?n:w.NotReported}),s=t.createElement("div",{className:i.iconWrapper},c),d=n&&n===w.NotApplicable?s:t.createElement(O,{className:i.link,to:`${l($(a))}/soundcheck/${e}/${r.id}`},s);return o?t.createElement("div",{className:`${i.root} ${i.virtualized}`},t.createElement(Xe,{check:r,icon:c,entityRef:a},d)):t.createElement("td",{className:`${i.root}`},d)}),re=8,Ze=16,N={programTitle:70,levelTitle:30,check:42,entityRefFooter:100},z={programTitle:350+Ze*2,checkResult:42},et=e=>e.reduce((r,a)=>r+a.height,0),tt=e=>e*z.checkResult+z.programTitle,rt=e=>e.filter(r=>r!==void 0).map(r=>{const a=$(r);return L(a,{defaultKind:a.kind})}).reduce((r,a)=>r.length>a.length?r:a,""),at=e=>re*e+re,ae="NoLevel",nt=e=>({name:ae,badge:{options:{level:0,color:""},variant:Re.Medal},entityRef:e,ordinal:0}),ne=h(e=>({checkNameCell:{padding:0,backgroundColor:e.palette.background.paper},checkNameContent:{padding:`0 ${e.spacing(2)}px`,display:"flex",justifyContent:"space-between",alignItems:"center"},checkNameTypography:{overflow:"hidden",textOverflow:"ellipsis"},checkIndicator:{flexBasis:e.spacing(8)},checkNameCellVirtualized:{height:`${N.check}px`,lineHeight:`${N.check}px`,borderBottom:`1px solid ${e.palette.divider}`,borderRight:`1px solid ${e.palette.divider}`}})),lt=k(({programId:e,programName:r,check:a,entityRefs:n,results:l,entityRoute:o})=>{const i=ne(),c=I(()=>Y(l.filter(({result:d})=>d!==w.NotApplicable),"result"),[l]),s=new Map(l.map(d=>[d.entityRef,d.result]));return t.createElement("tr",{"data-testid":"track-check-row"},t.createElement("th",{scope:"row",className:i.checkNameCell,"aria-label":`${a.name} check for ${r} track`},t.createElement("div",{className:i.checkNameContent},t.createElement(E,{className:i.checkNameTypography,variant:"subtitle2",component:"p"},a.name),t.createElement(ee,{className:i.checkIndicator,progress:c}))),n.map((d,u)=>t.createElement(te,{key:u,programId:e,check:a,entityRef:d,result:typeof d=="string"?s.get(d):void 0,entityRoute:o})))}),ot=({name:e,progress:r})=>{const a=ne();return t.createElement("div",{className:a.checkNameCell,"aria-label":`${e} check`},t.createElement("div",{className:`${a.checkNameContent} ${a.checkNameCellVirtualized}`},t.createElement(E,{variant:"subtitle2",component:"p",className:a.checkNameTypography},e),t.createElement(ee,{className:a.checkIndicator,progress:r})))},it=h(e=>({virtualized:{borderRight:`1px solid ${e.palette.divider}`,height:`${N.programTitle}px`,display:"flex",justifyContent:"center",alignItems:"center"}})),ct=k(({entityRef:e,highestLevels:r})=>{const a=r.find(n=>n.entityRef===e);return t.createElement(t.Fragment,null,a!=null&&a.badge?t.createElement(q,{badge:a.badge}):t.createElement(J,null))}),st=({highestLevel:e})=>{const r=it();if(!(e!=null&&e.badge))return t.createElement("div",{className:r.virtualized},"\xA0");const a=e.name!==ae;return t.createElement("div",{className:r.virtualized},a?t.createElement(q,{badge:e.badge}):t.createElement(J,null))},le=h(e=>({programNameCell:{padding:0,position:"sticky",backgroundColor:e.palette.background.paper},programNameContent:{padding:e.spacing(2)},programNameTypography:{overflow:"hidden",textOverflow:"ellipsis"},badgeCellContent:{display:"flex",justifyContent:"center",alignItems:"center"},programNameCellVirtualized:{borderRight:`1px solid ${e.palette.divider}`}})),dt=k(({program:e,entityRefs:r,highestLevels:a})=>{const n=le();return t.createElement("tr",{"data-testid":"track-title-row"},t.createElement("th",{scope:"row",className:n.programNameCell},t.createElement("div",{className:n.programNameContent},t.createElement(E,{className:n.programNameTypography,variant:"h5",component:"p"},e.name))),r.map((l,o)=>typeof l!="string"?t.createElement("td",{key:o,"aria-hidden":!0}):t.createElement("td",{key:o,"data-testid":"track-certification-cell"},t.createElement("div",{className:n.badgeCellContent},t.createElement(ct,{entityRef:l,highestLevels:a})))))}),pt=k(({name:e})=>{const r=le();return t.createElement("div",{className:`${r.programNameCell} ${r.programNameCellVirtualized}`},t.createElement("div",{className:r.programNameContent},t.createElement(E,{className:r.programNameTypography,variant:"h5",component:"p"},e)))}),W=h(e=>{const r=e.palette.type==="dark"?e.palette.grey[700]:e.palette.grey[100];return{root:{color:D(e.palette.getContrastText(r),.8),backgroundColor:r},levelContent:{padding:`${e.spacing(.5)}px ${e.spacing(2)}px`,backgroundColor:r},levelTypography:{overflow:"hidden",textOverflow:"ellipsis"},levelHeaderCell:{padding:`${e.spacing(.5)}px ${e.spacing(2)}px`,borderRight:`1px solid ${e.palette.divider}`,height:`${N.levelTitle}px`}}}),mt=k(({level:e,entityRefs:r,programName:a})=>{const n=W();return t.createElement("tr",{className:n.root,"data-testid":"track-level-row"},t.createElement("th",{scope:"row",className:n.root},t.createElement("div",{className:n.levelContent},t.createElement(E,{className:n.levelTypography,variant:"subtitle2",component:"p","aria-label":`${e.name} for ${a} track`},e.name))),r.map((l,o)=>t.createElement("td",{key:o,className:n.root,"aria-hidden":!0})))}),ut=({name:e})=>{const r=W();return t.createElement("div",{className:`${r.levelHeaderCell} ${r.root}`,"aria-label":`${e}`},t.createElement(E,{variant:"subtitle2",component:"p",className:r.levelTypography},e))},gt=()=>{const e=W();return t.createElement("div",{className:`${e.levelHeaderCell} ${e.root}`},"\xA0")},ht=({program:e,highestLevels:r,levels:a,entityRefs:n,entityRoute:l})=>t.createElement("tbody",null,t.createElement(dt,{program:e,entityRefs:n,highestLevels:r}),a.map((o,i)=>t.createElement(de,{key:i},t.createElement(mt,{entityRefs:n,level:o,programName:e.name}),o.checks.map(({check:c,results:s},d)=>t.createElement(lt,{key:d,check:c,programId:e.id,programName:e.name,entityRefs:n,results:s,entityRoute:l}))))),oe=h(e=>({root:{position:"sticky",bottom:"-1px",backgroundColor:e.palette.background.default,boxShadow:`0 -1px ${e.palette.divider}`,"& td$cell, & th$cell":{border:0,padding:e.spacing(1)},"& td$cell":{backgroundColor:e.palette.background.default}},row:{boxShadow:`1px 0 ${e.palette.background.default}, -1px 0 ${e.palette.background.default}`},cell:{verticalAlign:"top"},cellInner:{textOrientation:"mixed",writingMode:"vertical-lr",transform:"rotate(-20deg)",transformOrigin:`100% ${e.spacing(1)}px`,wordBreak:"keep-all",fontWeight:"bold",overflow:"hidden",textOverflow:"ellipsis",maxHeight:"max(15vh, 175px)"}})),ft=({entityRefs:e})=>{const r=F(B),a=oe();return t.createElement("tfoot",{className:a.root,"data-testid":"results-table-footer"},t.createElement("tr",{className:a.row},t.createElement("td",{className:a.cell}),e.map((n,l)=>{if(typeof n!="string")return t.createElement("th",{key:l,className:a.cell,"aria-hidden":!0});const o=$(n);return t.createElement("th",{scope:"col",key:l,className:a.cell},t.createElement("div",{className:a.cellInner},t.createElement(O,{to:r(o)},L(o,{defaultKind:o.kind}))))})))},yt=({entityRef:e})=>{const r=F(B),a=oe(),n=e?$(e):void 0,l=n?t.createElement(O,{to:r(n)},L(n,{defaultKind:n.kind})):t.createElement(t.Fragment,null);return t.createElement("div",{className:a.cell},t.createElement("div",{className:a.cellInner},l))},Et=h(e=>({table:{backgroundColor:e.palette.background.paper,borderCollapse:"collapse",whiteSpace:"nowrap","& th, & td":{border:`1px solid ${e.palette.divider}`,borderCollapse:"collapse"},paddingBottom:e.spacing(2)},programTitle:{padding:e.spacing(2)},checkResult:{padding:e.spacing(1.5)},title:{padding:`${e.spacing(1)}px ${e.spacing(2)}px`},header:{backgroundColor:e.palette.type==="dark"?e.palette.grey[700]:e.palette.grey[100]}})),ie=()=>{const e=Et(),r=new Array(25).fill(void 0),a=new Array(5).fill(void 0),n=new Array(3).fill(void 0);return t.createElement("table",{className:e.table},t.createElement("tbody",null,t.createElement("tr",null,t.createElement("td",{className:e.programTitle},t.createElement(H,{width:180,height:40})),r.map((l,o)=>t.createElement("td",{key:o}))),n.map((l,o)=>t.createElement(t.Fragment,{key:o},t.createElement("tr",{className:e.header},t.createElement("td",{className:e.title},t.createElement(H,{width:180})),r.map((i,c)=>t.createElement("td",{key:c}))),a.map((i,c)=>t.createElement("tr",{key:c},t.createElement("td",{className:e.title},t.createElement(H,{width:240})),r.map((s,d)=>t.createElement("td",{key:d,className:e.checkResult},t.createElement(H,{width:18,height:18,variant:"rect"})))))))))},vt=h(e=>({root:{width:"100%"},table:{overflow:"auto",backgroundColor:e.palette.background.paper,borderCollapse:"collapse",whiteSpace:"nowrap",textAlign:"left","& th, & td":{border:`1px solid ${e.palette.divider}`,borderCollapse:"collapse"},"& th:first-of-type":{position:"sticky",left:0,zIndex:1,maxWidth:"60ch"},"& tfoot":{bottom:0,zIndex:1e3},"& tbody td:first-of-type":{border:`1px solid ${e.palette.divider}`,boxShadow:`1px 0 ${e.palette.background.default}, -1px 0 ${e.palette.background.default}`}}})),kt=k(e=>{const{setError:r,kind:a,type:n,ownerEntityRef:l}=e,o=vt(),i=F(B),{data:c,isLoading:s,isError:d}=Z(l,{kind:a,type:n});if(v(()=>{r==null||r(d?new Error("Error loading track overview"):void 0)},[d,r]),s)return t.createElement(ie,null);if(!c||!l)return null;const{programs:u,entityRefs:m}=c;if(!s&&!u.length)return t.createElement(ue,{missing:"data",title:"Missing tracks",description:t.createElement(t.Fragment,null,"Looks like the group"," ",L($(l),{defaultKind:"Group"})," ","doesn't own any ",n!=null?n:a," components that have Soundcheck tracks set up.",t.createElement("br",null),t.createElement("br",null),"If you're an administrator, you can learn more about configuring and filtering tracks in the"," ",t.createElement(O,{to:"https://www.npmjs.com/package/@spotify/backstage-plugin-soundcheck-backend#entity-filter"},"docs"),".")});if(d)return null;const p=m.length>=25?m:[...m,...Array.from({length:25-m.length},()=>{})];return t.createElement("div",{className:o.root},t.createElement("table",{className:o.table,"aria-label":"Check results"},u.map(({program:g,levels:y,highestLevels:f},x)=>t.createElement(ht,{key:x,program:g,entityRefs:p,levels:y,highestLevels:f,entityRoute:i})),t.createElement(ft,{entityRefs:p})))}),bt=e=>t.createElement(pt,{name:e}),Ct=e=>({type:"ProgramHeader",render:()=>bt(e)}),wt=e=>e?t.createElement(ut,{name:e}):t.createElement(gt,null),ce=e=>({type:"LevelHeader",render:()=>wt(e)}),Nt=(e,r)=>t.createElement(ot,{name:e,progress:r}),Rt=(e,r)=>({type:"CheckTitle",render:()=>Nt(e,r)}),$t=(e,r,a,n,l)=>t.createElement(te,{check:r,entityRef:a,entityRoute:l,programId:e,result:n,isVirtualized:!0}),xt=(e,r,a,n,l)=>({type:"CheckResult",render:()=>$t(e,r,a,n,l)}),Tt=e=>t.createElement(yt,{entityRef:e}),se=e=>({type:"EntityHeader",render:()=>Tt(e)}),Pt=e=>t.createElement(st,{highestLevel:e}),Lt=e=>({type:"LevelBadge",render:()=>Pt(e)}),It=e=>r=>{const a=e[r.rowIndex].cells[r.columnIndex];return a?t.createElement("div",{style:r.style},a.render()):t.createElement("div",{style:r.style})},St=(e,r,a)=>{var n;const l=[];for(const{program:i,levels:c,highestLevels:s}of e){l.push({height:N.programTitle,cells:[Ct(i.name),...r.map(d=>{const u=d?s.find(m=>m.entityRef===d)||nt(d):void 0;return Lt(u)})]});for(const d of c){l.push({height:N.levelTitle,cells:[ce(d.name),...r.map(u=>ce(""))]});for(const{check:u,results:m}of d.checks)l.push({height:N.check,cells:[Rt(u.name,Y(m.filter(({result:p})=>p!==w.NotApplicable),"result")),...r.map(p=>{var g,y;return xt(i.id,u,p,(y=(g=m.find(f=>f.entityRef===p))==null?void 0:g.result)!=null?y:w.NotApplicable,a)})]})}}const o=rt(r!=null?r:[]);return l.push({height:at((n=o.length)!=null?n:1),cells:[se(""),...r.map(i=>se(i||""))]}),l},Ot=h(e=>({table:{backgroundColor:e.palette.background.paper,borderCollapse:"collapse",whiteSpace:"nowrap",textAlign:"left",overflow:"auto"}})),Ft=e=>{const{setError:r,kind:a,type:n,ownerEntityRef:l}=e,o=Ot(),i=F(B),{data:c,isLoading:s,isError:d}=Z(l,{kind:a,type:n});if(v(()=>{r==null||r(d?new Error("Error loading program overview"):void 0)},[d,r]),s)return t.createElement(ie,null);if(!c||!l)return null;const{programs:u,entityRefs:m}=c,p=m.length>=25?m:[...m,...Array.from({length:25-m.length},()=>{})],g=St(u,p,i),y=It(g);return t.createElement(C,{"aria-label":`Check results for ${n!=null?n:a}`,key:`${a}|${n!=null?n:""}`,item:!0,xs:12},t.createElement(Se,{className:o.table,columnCount:p.length+1,columnWidth:f=>f===0?z.programTitle:z.checkResult,rowCount:g.length,rowHeight:f=>g[f].height,height:et(g),width:tt(p.length)},y))},At=({facets:e,ownerEntityRef:r,kind:a,type:n,setError:l})=>{const o=I(()=>{const i=new Map;return e.types.forEach(({kind:c,type:s})=>{const d=`${c}|${s!=null?s:""}`;i.set(d,t.createElement(Ft,{key:d,ownerEntityRef:r,kind:c,type:s,setError:l}))}),i},[e,r,l]);return t.createElement("div",null,o.get(`${a}|${n!=null?n:""}`))},Bt=h(()=>({scrollContainer:{overflow:"auto"}})),Ht=({facets:e,ownerEntityRef:r,hasError:a,kind:n,type:l,setError:o,useVirtualizedResultsTable:i})=>{var c,s;const d=Bt();return a?t.createElement($e,{severity:"error",title:a.message}):e&&((s=(c=e.types)==null?void 0:c.length)!=null?s:0)>0?t.createElement("div",{className:d.scrollContainer},i?t.createElement(At,{facets:e,kind:n,type:l,setError:o,ownerEntityRef:r,hasError:a}):t.createElement(kt,{ownerEntityRef:r,kind:n,type:l,setError:o})):t.createElement(xe,{ownerEntityRef:r})},zt=h(e=>({tableContainer:{padding:e.spacing(3),backgroundColor:"transparent"}})),Wt=({groupSelectorError:e,searchParams:r,setSearchParams:a})=>{var n;const{group:l,kind:o,type:i}=r,[c,s]=P(void 0),[d,u]=P(void 0);v(()=>{((c==null?void 0:c.kind)!==o||(c==null?void 0:c.type)!==i)&&s({kind:o,type:i})},[o,i,c]);const{data:m,isLoading:p}=Be(l),g=(n=b(j).getOptionalBoolean("soundcheck.virtualizeOverviewPage"))!=null?n:!1,y=d||e,f=(R,T)=>{R&&(s({kind:R,type:T}),T?a({...r,kind:R,type:T}):(r!=null&&r.hasOwnProperty("type")&&delete r.type,a({...r,kind:R})))},x=zt();return t.createElement(C,{container:!0,spacing:0},t.createElement(C,{item:!0,xs:12},p?t.createElement(De,null):t.createElement(_e,{unfilteredFacets:m,kind:c==null?void 0:c.kind,type:c==null?void 0:c.type,onChange:f})),t.createElement(C,{item:!0,xs:12,className:x.tableContainer},!p&&t.createElement(Ht,{facets:m,kind:c==null?void 0:c.kind,type:c==null?void 0:c.type,setError:u,hasError:y,ownerEntityRef:l,useVirtualizedResultsTable:g})))},Vt=h(e=>({checkersPageContainer:{padding:e.spacing(3)}})),Gt=({})=>{const e=Vt(),r=()=>{window.open("/soundcheck/checks","_self")};return t.createElement(t.Fragment,null,t.createElement("div",{className:e.checkersPageContainer},"Hello"),t.createElement(_,{variant:"contained",color:"primary",onClick:r},"Checker List"))},Mt=h(e=>({programsPageContainer:{padding:e.spacing(3)}})),jt=({})=>{const e=Mt(),r=()=>{window.open("/soundcheck/tracks","_self")};return t.createElement(t.Fragment,null,t.createElement("div",{className:e.programsPageContainer},"Hello"),";",t.createElement(_,{variant:"contained",color:"primary",onClick:r},"Track List"))},Dt=e=>{var r;const{title:a="Soundcheck"}=e,[n,l]=ze(),{group:o}=n,[i,c]=P(void 0),s=(r=b(j).getOptionalBoolean("soundcheck.noCodeUI"))!=null?r:!1;return t.createElement(Te,null,t.createElement(Pe,null,t.createElement(ge,{themeId:"website"},t.createElement(Ee,{backend:"soundcheck",invalidLicenseMessage:"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."}),t.createElement(he,{title:a},t.createElement(Ge,{onChange:d=>{d&&l({...n,group:d})},initialValue:o,setError:c})),t.createElement(fe,{noPadding:!0,stretch:!0},t.createElement(Le,null,t.createElement(me,null,t.createElement(S,{path:"/*",element:t.createElement(Wt,{groupSelectorError:i,searchParams:n,setSearchParams:l})}),s&&t.createElement(t.Fragment,null,t.createElement(S,{path:"/checks/:checkId",element:t.createElement(Oe,null,t.createElement(Gt,null))}),t.createElement(S,{path:"/tracks/:trackId",element:t.createElement(Fe,null,t.createElement(jt,null))}),t.createElement(S,{path:"/fact-collectors",element:t.createElement(Me,null)}))))))))};export{Dt as OverviewPage};
2
- //# sourceMappingURL=index-92271e48.esm.js.map