@redocly/realm 0.130.0-custom.2 → 0.130.0-custom.3
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/dist/server/plugins/scorecard-classic/template/Grid/Grid.d.ts +2 -1
- package/dist/server/plugins/scorecard-classic/template/Grid/Grid.js +3 -3
- package/dist/server/plugins/scorecard-classic/template/Grid/GridHeader.js +15 -9
- package/dist/server/plugins/scorecard-classic/template/Grid/GridRow.js +1 -1
- package/dist/server/plugins/scorecard-classic/template/index.styles.js +5 -6
- package/dist/server/plugins/scorecard-classic/template/views.js +1 -1
- package/package.json +6 -6
|
@@ -9,8 +9,9 @@ export type PossibleRowData = (Data | RuleProblem | TeamStats | Problem | Catalo
|
|
|
9
9
|
export type GridProps = {
|
|
10
10
|
data: PossibleRowData[];
|
|
11
11
|
columns: ColumnDef<PossibleRowData>[];
|
|
12
|
+
gridTemplateColumns?: string;
|
|
12
13
|
};
|
|
13
|
-
export declare const Grid: ({ data, columns, sortBy, empty, subRowKey, slug, groupHeaderTitle, virtualized, }: GridProps & {
|
|
14
|
+
export declare const Grid: ({ data, columns, gridTemplateColumns: gridTemplateColumnsOverride, sortBy, empty, subRowKey, slug, groupHeaderTitle, virtualized, }: GridProps & {
|
|
14
15
|
sortBy?: SortingState;
|
|
15
16
|
empty?: ReactElement | string;
|
|
16
17
|
subRowKey?: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import t,{useMemo as
|
|
1
|
+
import t,{useMemo as g,useState as T,useEffect as $}from"react";import{useReactTable as k,getCoreRowModel as A,getSortedRowModel as I,getExpandedRowModel as H}from"@tanstack/react-table";import w from"styled-components";import{useWindowVirtualizer as L}from"@tanstack/react-virtual";import{SpinnerLoader as V}from"@redocly/theme/components/Loaders/SpinnerLoader";import{GridRow as c}from"./GridRow";import{GridHeader as j}from"./GridHeader";const U=({data:i,columns:n,gridTemplateColumns:l,sortBy:s,empty:f,subRowKey:m="subrows",slug:E,groupHeaderTitle:R,virtualized:h=!0})=>{const y=g(()=>s||[],[s]),v=k({columns:n,data:i,getCoreRowModel:A(),getSortedRowModel:I(),getExpandedRowModel:H(),getSubRows:e=>{const o=e?.[m];return Array.isArray(o)?o:[]},...s?{initialState:{sorting:y}}:{},autoResetExpanded:!1}),{getHeaderGroups:x,getRowModel:C}=v,M=x(),{rows:S}=C(),r=S.filter(e=>e.depth===0),[d,b]=T(!1);$(()=>{b(!0)},[]);const u=L({count:r.length,estimateSize:()=>54,overscan:h?15:9999,getItemKey(e){return`vi-row-${r[e].id}-${r.length}`}}),z=d?u.getVirtualItems():[],G=r.slice(0,50),a=g(()=>l||(i.some(o=>{const p=o[m];return Array.isArray(p)&&p.length>0})?`50px repeat(${n.length-1}, 1fr)`:`25% repeat(${n.length-1}, 1fr)`),[n.length,i,m,l]);return t.createElement("div",{role:"table"},t.createElement(j,{headerGroups:M,gridTemplateColumns:a,groupHeaderTitle:R}),t.createElement(D,{style:{height:d?u.getTotalSize():"auto"},role:"rowgroup"},r.length>0?d?z.map(e=>{const o=r[e.index];return t.createElement(c,{key:e.key,variant:"virtualized",row:o,slug:E,virtualRow:e,virtualizer:u,gridTemplateColumns:a})}):t.createElement(t.Fragment,null,G.map(e=>t.createElement(c,{key:`ssr-row-${e.id}`,variant:"ssr",row:e,gridTemplateColumns:a})),t.createElement(F,null,t.createElement(V,{color:"var(--link-color-primary)",size:"20px"}))):t.createElement(c,{variant:"noData",empty:f,gridTemplateColumns:a})))},D=w.div`
|
|
2
2
|
position: relative;
|
|
3
|
-
`,
|
|
3
|
+
`,F=w.div`
|
|
4
4
|
display: flex;
|
|
5
5
|
justify-content: center;
|
|
6
6
|
align-items: center;
|
|
7
7
|
margin: 10px;
|
|
8
|
-
`;export{
|
|
8
|
+
`;export{U as Grid};
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from"react";import l from"styled-components";import{flexRender as m}from"@tanstack/react-table";const y=({headerGroups:o,gridTemplateColumns:t,groupHeaderTitle:n})=>e.createElement(s,null,n&&e.createElement(g,{gridTemplateColumns:t,role:"row"},e.createElement(i,{gridColumn:"1",role:"cell"}),e.createElement(i,{gridColumn:"2 / -1",role:"cell"},e.createElement("span",null,n))),o.map((d,c)=>e.createElement(p,{key:`header-group-${c}`,gridTemplateColumns:t,role:"row"},d.headers.map((r,a)=>e.createElement(u,{key:r.id,gridColumn:a+1,onClick:r.column.getToggleSortingHandler(),role:"cell"},m(r.column.columnDef.header,r.getContext()),r.column.getCanSort()?e.createElement(x,null,r.column.getIsSorted()?r.column.getIsSorted()==="desc"?"\u25BE":"\u25B4":"\u21D5"):null))))),s=l.div`
|
|
2
2
|
border: 1px solid var(--border-color-primary);
|
|
3
3
|
min-width: 775px;
|
|
4
|
+
position: sticky;
|
|
5
|
+
top: var(--navbar-height);
|
|
6
|
+
z-index: 1;
|
|
7
|
+
background-color: var(--color-white);
|
|
4
8
|
`,g=l.div`
|
|
5
9
|
display: grid;
|
|
6
|
-
grid-template-columns: ${
|
|
10
|
+
grid-template-columns: ${o=>o.gridTemplateColumns};
|
|
7
11
|
width: 100%;
|
|
8
12
|
min-width: 775px;
|
|
9
|
-
`,
|
|
10
|
-
padding: 5px
|
|
13
|
+
`,i=l.div`
|
|
14
|
+
padding: 5px;
|
|
11
15
|
background-color: var(--bg-color-raised);
|
|
12
16
|
font-weight: bold;
|
|
13
17
|
color: var(--text-color-secondary);
|
|
14
|
-
grid-column: ${
|
|
18
|
+
grid-column: ${o=>o.gridColumn};
|
|
15
19
|
display: flex;
|
|
16
20
|
justify-content: center;
|
|
17
21
|
align-items: center;
|
|
@@ -23,20 +27,22 @@ import o from"react";import l from"styled-components";import{flexRender as a}fro
|
|
|
23
27
|
}
|
|
24
28
|
`,p=l.div`
|
|
25
29
|
display: grid;
|
|
26
|
-
grid-template-columns: ${
|
|
30
|
+
grid-template-columns: ${o=>o.gridTemplateColumns};
|
|
27
31
|
width: 100%;
|
|
28
32
|
`,u=l.div`
|
|
29
|
-
padding: 5px
|
|
33
|
+
padding: 5px;
|
|
30
34
|
background-color: var(--bg-color-raised);
|
|
31
35
|
font-weight: bold;
|
|
32
36
|
color: var(--text-color-secondary);
|
|
33
37
|
cursor: pointer;
|
|
34
|
-
grid-column: ${
|
|
38
|
+
grid-column: ${o=>o.gridColumn};
|
|
35
39
|
box-sizing: border-box;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
text-overflow: ellipsis;
|
|
36
42
|
|
|
37
43
|
&:first-child {
|
|
38
44
|
justify-content: flex-start;
|
|
39
45
|
}
|
|
40
46
|
`,x=l.span`
|
|
41
47
|
font-family: monospace;
|
|
42
|
-
`;export{
|
|
48
|
+
`;export{y as GridHeader};
|
|
@@ -22,7 +22,7 @@ import i from"react";import{flexRender as m}from"@tanstack/react-table";import l
|
|
|
22
22
|
grid-template-columns: ${e=>e.gridTemplateColumns};
|
|
23
23
|
align-items: center;
|
|
24
24
|
`,p=l.div`
|
|
25
|
-
padding: 5px
|
|
25
|
+
padding: 5px;
|
|
26
26
|
text-align: left;
|
|
27
27
|
grid-column: ${e=>e.gridColumn};
|
|
28
28
|
|
|
@@ -38,11 +38,11 @@ import r from"styled-components";import{Popup as e}from"reactjs-popup";import{Bu
|
|
|
38
38
|
`,a=r.span`
|
|
39
39
|
vertical-align: middle;
|
|
40
40
|
display: inline-block;
|
|
41
|
-
`,
|
|
41
|
+
`,g=r(a)`
|
|
42
42
|
margin-right: 0;
|
|
43
43
|
text-align: right;
|
|
44
44
|
width: 65px;
|
|
45
|
-
`,
|
|
45
|
+
`,f=r.div`
|
|
46
46
|
display: flex;
|
|
47
47
|
flex-wrap: wrap;
|
|
48
48
|
gap: 20px;
|
|
@@ -78,7 +78,7 @@ import r from"styled-components";import{Popup as e}from"reactjs-popup";import{Bu
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
thead th {
|
|
81
|
-
padding: 5px
|
|
81
|
+
padding: 5px;
|
|
82
82
|
background-color: var(--bg-color-raised);
|
|
83
83
|
|
|
84
84
|
&:first-child {
|
|
@@ -96,7 +96,7 @@ import r from"styled-components";import{Popup as e}from"reactjs-popup";import{Bu
|
|
|
96
96
|
|
|
97
97
|
th,
|
|
98
98
|
td {
|
|
99
|
-
padding: 5px
|
|
99
|
+
padding: 5px;
|
|
100
100
|
text-align: left;
|
|
101
101
|
flex: 1;
|
|
102
102
|
}
|
|
@@ -208,7 +208,6 @@ import r from"styled-components";import{Popup as e}from"reactjs-popup";import{Bu
|
|
|
208
208
|
border-bottom: ${({isActive:o})=>o?"1px solid var(--text-color-secondary);":"1px solid transparent"};
|
|
209
209
|
`,C=r.div`
|
|
210
210
|
max-width: 100%;
|
|
211
|
-
overflow: auto;
|
|
212
211
|
visibility: ${({isActive:o})=>o?"visible":"hidden"};
|
|
213
212
|
height: ${({isActive:o})=>o?"auto":"0"};
|
|
214
213
|
opacity: ${({isActive:o})=>o?"1":"0"};
|
|
@@ -291,4 +290,4 @@ import r from"styled-components";import{Popup as e}from"reactjs-popup";import{Bu
|
|
|
291
290
|
'Noto Color Emoji',
|
|
292
291
|
'EmojiOne Color';
|
|
293
292
|
vertical-align: middle;
|
|
294
|
-
`;export{k as AppPageWrapper,b as CardRow,a as CardValue,
|
|
293
|
+
`;export{k as AppPageWrapper,b as CardRow,a as CardValue,f as CardsWrapper,v as CatalogDescription,n as CatalogPageWrapper,T as Code,M as ContentWithDotWrap,m as Dot,D as EmojiWrap,I as FilePreview,g as GaugeNumber,E as GroupTh,P as InstanceControlsWrap,z as InstanceMessage,W as InstanceReference,j as InstanceWrap,B as LevelComplianceCardTitle,w as ModeSwitcherTab,y as ModeSwitcherTabs,x as ProblemsByStatusCardBody,s as ScoreCardStatusCardBody,c as ScorecardCard,i as ScorecardCardTitle,$ as SortIcon,u as StyledInput,S as StyledPopup,h as StyledTable,C as TableWrap};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{useCallback as _,useMemo as b,useState as U,useEffect as Z}from"react";import{useLocation as K}from"react-router-dom";import{Flex as J}from"@redocly/portal-legacy-ui";import{Button as w}from"@redocly/theme/components/Button/Button";import{AddIcon as V}from"@redocly/theme/icons/AddIcon/AddIcon";import{SubtractIcon as O}from"@redocly/theme/icons/SubtractIcon/SubtractIcon";import{ArrowLeftIcon as R}from"@redocly/theme/icons/ArrowLeftIcon/ArrowLeftIcon";import{useProcessScorecard as N}from"@redocly/theme/ext/process-scorecard";import{getScorecardColorVariable as z,withoutPathPrefix as I}from"@redocly/theme/core/utils";import{Link as T}from"../../../../client/app/Link";import Q from"../../../../client/app/CircularProgress";import{isDefined as W}from"../../../../utils/guards/is-defined.js";import{removeLeadingSlash as X}from"../../../../utils/url/remove-leading-slash.js";import{StatusByLevelWidget as Y}from"./StatusByLevelWidget";import{OTHER_TEAMS_LABEL as ee,NON_CONFORMANT as te}from"./utils";import{LevelIndicator as re}from"./LevelIndicator";import{AppPageWrapper as j,CardValue as S,CardsWrapper as B,CatalogDescription as ne,ModeSwitcherTab as ae,ModeSwitcherTabs as le,CardRow as F,ProblemsByStatusCardBody as q,ScoreCardStatusCardBody as M,TableWrap as se,LevelComplianceCardTitle as ce,ContentWithDotWrap as A,ScorecardCard as x,ScorecardCardTitle as L}from"./index.styles";import{ApiLevel as $,InstanceStatus as D,LevelStatus as H,RuleStatus as G}from"./components";import{Grid as P}from"./Grid/Grid";import{useDetailedScorecard as oe}from"./useDetailedScorecard";import{Gauge as ie,GaugeValue as ue}from"./Gauge";function Oe(g){const u=K(),{data:m,levelNames:i,hasPublishedAt:r,hasTeam:s,teamLabel:p}=g,y=_((t,a,d)=>{const o=t.getValue(d)?new Date(t.getValue(d)).getTime():0,f=a.getValue(d)?new Date(a.getValue(d)).getTime():0;return o>f?1:-1},[]),E=b(()=>[{id:"title",header:"API",accessorKey:"api.title",size:200,cell:({getValue:t,row:a})=>e.createElement(T,{to:I(u.pathname)+"/apis/"+encodeURIComponent(X(a.original.api.link))},t()," ",a.original.api.version)},r?{header:"Published at",accessorKey:"api.publishedAt",sortingFn:y,cell:({getValue:t})=>{const a=t();return a?new Date(a).toLocaleDateString():"-"}}:void 0,s?{header:p,accessorKey:"api.team"}:void 0,{id:"level",header:"Level",accessorKey:"scorecard.scorecardLevel",cell:({getValue:t,row:a})=>e.createElement($,{level:t(),colorVariable:z(a.original?.scorecard.scorecardLevelIdx,i.length+1)})},...i.map(t=>({id:t,header:`${t}`,accessorKey:"scorecard.levels",sortingFn:(a,d,o)=>{const f=a.getValue(o)[o].uniqueErrors,v=d.getValue(o)[o].uniqueErrors,n=a.getValue(o)[o].uniqueWarnings,h=d.getValue(o)[o].uniqueWarnings;return f===v?n-h:f-v},cell:({getValue:a,row:{original:d}})=>{const o=a(),f=d.api.link;return o?.[t]?e.createElement(re,{key:f,uniqueErrors:o[t].uniqueErrors,uniqueWarnings:o[t].uniqueWarnings,customDisplay:o[t].customDisplay,id:f}):null}}))].filter(W),[y,i,u.pathname,r,s,p]);return e.createElement(P,{columns:E,data:m,sortBy:[{id:"title",desc:!1}]})}function Re(g){const u=K(),{data:m}=g,i=b(()=>[{header:"Rules",accessorKey:"ruleId",cell:({getValue:r})=>e.createElement(T,{to:I(u.pathname)+"/rules/"+encodeURIComponent(r())},r())},{id:"status",header:"Status",accessorKey:"status",size:200,cell:({row:r})=>e.createElement(G,{errors:r.original.errorApisCount,warnings:r.original.warningApisCount})},{header:"Problem APIs",width:200,accessorKey:"apisCount",cell:({getValue:r})=>r(),sortDescFirst:!0},{header:"Problem count",size:200,accessorKey:"count",sortDescFirst:!0}],[u.pathname]);return e.createElement(P,{columns:i,data:m,virtualized:!1,sortBy:[{id:"status",desc:!0}]})}function ze(g){const{data:u,levelNames:m,filters:i,setActiveTab:r,teamLabel:s,teamProperty:p}=g,y=b(()=>[{id:"team",header:`API ${s}`,accessorKey:"team",size:200,cell:({getValue:E})=>e.createElement("a",{href:"#",onClick:t=>{t.preventDefault(),r("apis"),i.find(a=>a.property===p)?.selectOption(E())}},E())},...[te,...m].map(E=>({id:E,header:`${E}`,accessorFn:t=>t.levels[E]?.apis}))],[i,m,r,s,p]);return e.createElement(P,{columns:y,data:u,sortBy:[{id:"team",desc:!1}],groupHeaderTitle:"APIs by level"})}function me(g){const{data:u,title:m}=g,i=b(()=>[{id:"expand",maxSize:40,size:40,header:()=>null,enableSorting:!1,cell:({row:r})=>r.getCanExpand()?e.createElement(w,{onClick:r.getToggleExpandedHandler(),variant:"text",size:"medium",icon:r.getIsExpanded()?e.createElement(O,null):e.createElement(V,null)}):null},{header:"Rules",accessorKey:"ruleId",cell:({getValue:r,row:s})=>s.getCanExpand()?e.createElement("span",{onClick:s.getToggleExpandedHandler()},r()):null},{header:"Status",accessorKey:"status",size:200,cell:({getValue:r})=>{const s=r();return e.createElement(G,{errors:s?.errorsCount,warnings:s?.warningsCount})},enableSorting:!1},{header:"Problem count",accessorKey:"problemsCount",size:200,sortDescFirst:!0}],[]);return e.createElement(P,{columns:i,data:u,sortBy:[{id:"ruleId",desc:!1}],empty:e.createElement(e.Fragment,null,"\u2705 This API is compliant with ",e.createElement("strong",null,m)," level rules"),subRowKey:"problems"})}function Ie(g){const{catalogSlug:u,slug:m,data:i,hasTeam:r,hasPublishedAt:s,teamLabel:p}=g,{apis:y,apisCount:E,warningApisCount:t,errorApisCount:a,levels:d,count:o}=i,f=b(()=>Object.values(y),[y]),v=f.length===0,n=v?void 0:{id:"expand",maxSize:40,size:40,header:()=>null,enableSorting:!1,cell:({row:l})=>l.getCanExpand()?e.createElement(w,{onClick:l.getToggleExpandedHandler(),variant:"text",size:"medium",icon:l.getIsExpanded()?e.createElement(O,null):e.createElement(V,null)}):null},h=b(()=>[n,{header:"API",accessorKey:"title"},s?{header:"Published at",accessorKey:"publishedAt",cell:({getValue:l})=>{const c=l();return c?new Date(c).toLocaleDateString():"-"}}:void 0,r?{header:p,accessorKey:"team",cell:({getValue:l})=>l()||ee}:void 0,{header:"Problem count",size:200,accessorKey:"count",cell:({getValue:l})=>l()||0,sortDescFirst:!0}].filter(W),[r,s,p,v]),k=b(()=>Object.entries(i.teams).sort((l,c)=>c[1]-l[1]),[i.teams]);return e.createElement(j,null,e.createElement(w,{icon:e.createElement(R,null),iconPosition:"left",variant:"ghost",size:"large",to:`${u}scorecard`},"Back to dashboard"),e.createElement("h1",null,"Rule ",m),e.createElement(B,null,e.createElement(x,null,e.createElement(L,null,"Rule status"),e.createElement(M,null,e.createElement("div",null,e.createElement(S,null,E),e.createElement("br",null),"APIs"),e.createElement("div",null,e.createElement(A,null,e.createElement(S,{style:{textAlign:"right"}},E-t-a),e.createElement(D,{severity:"Pass"})),e.createElement(A,null,e.createElement(S,{style:{textAlign:"right"}},t),e.createElement(D,{severity:"Warn"})),e.createElement(A,null,e.createElement(S,{style:{textAlign:"right"}},a),e.createElement(D,{severity:"Error"}))))),e.createElement(x,null,e.createElement(L,null,"Problems by level"),e.createElement(q,null,Object.entries(d).map(([l,c])=>e.createElement(F,{key:l},e.createElement("span",null,l),e.createElement(ie,{chunks:[{share:c.errors/o*100,colorVariable:"--scorecard-color-error"},{share:c.warnings/o*100,colorVariable:"--scorecard-color-warning"}]}),e.createElement(ue,null,c.errors+c.warnings))))),e.createElement(x,null,e.createElement(L,null,`Problems by ${p}`),e.createElement(q,null,k.slice(0,4).map(([l,c])=>e.createElement(F,{key:l},e.createElement("span",{style:{flex:1,textAlign:"left"}},l),e.createElement(S,null,c)))))),e.createElement(P,{columns:h,data:f,sortBy:[{id:"title",desc:!1}],subRowKey:"problems",slug:m}))}function We(g){const{slug:u,api:m,teamLabel:i,catalogSlug:r}=g,{api:s}=m||{},{scorecard:p,isLoading:y}=oe(`/${u}`),{processScorecard:E}=N(),t=p&&E(p,m.api),a=t?.levels||{},[d,o]=U(Object.keys(a)[0]),f=b(()=>s?.publishedAt instanceof Date?s?.publishedAt.toLocaleDateString():s?.publishedAt,[s]);Z(()=>{if(t){const n=t.levels||{};o(Object.keys(n)[0])}},[p]);const v=b(()=>{if(!t?.levels)return{};const n={};for(const h of Object.keys(t.levels)){const k=t.levels[h].problems.reduce((l,c)=>(l[c.ruleId]||(l[c.ruleId]=[]),l[c.ruleId].push(c),l),{});n[h]=Object.entries(k).map(([l,c])=>({ruleId:l,problems:[...c.filter(C=>C.severity==="error"),...c.filter(C=>C.severity==="warn")],problemsCount:c.length,status:{errorsCount:c.filter(C=>C.severity==="error").length,warningsCount:c.filter(C=>C.severity==="warn").length}}))}return n},[t?.levels]);return y?e.createElement(J,{justifyContent:"center",mt:"2em"},e.createElement(Q,null)):t?e.createElement(j,null,e.createElement(w,{icon:e.createElement(R,null),iconPosition:"left",variant:"ghost",size:"large",to:`${r}scorecard`},"Back to dashboard"),e.createElement("h1",null,s?.title||u),e.createElement(ne,null,f&&e.createElement(e.Fragment,null,"Published at: ",new Date().toLocaleString(void 0,{timeZoneName:"short"}),e.createElement("br",null)),e.createElement(T,{to:s?.link,external:!0},"Documentation")),e.createElement(B,null,e.createElement(x,null,e.createElement(ce,null,e.createElement("span",null,"Scorecard level"),e.createElement($,{level:t.scorecardLevel,colorVariable:z(t.scorecardLevelIdx,Object.keys(a).length)})),e.createElement(M,null,e.createElement("div",null,"Compliance by level"),e.createElement("div",null,Object.entries(t.levels).map(([n,h])=>e.createElement(A,{key:n},e.createElement(S,{style:{width:"100px",textAlign:"right"}},n),e.createElement(H,{errors:h.errors,warnings:h.warnings})))))),e.createElement(Y,{title:"Rules compliance",levels:Object.entries(t.levels).map(([n,h])=>({errors:h.uniqueErrors,warnings:h.uniqueWarnings,total:g.rulesPerLevel[n].length,name:n}))}),e.createElement(x,null,e.createElement(L,null,i),e.createElement(S,{style:{fontWeight:"normal"}},s?.team))),e.createElement(le,{style:{justifyContent:"flex-start"},"data-component-name":"Scorecard/ModeSwitcherTabs"},Object.keys(t.levels).map(n=>e.createElement(ae,{"data-component-name":"Scorecard/ModeSwitcherTab",key:n,isActive:d===n,onClick:()=>o(n)},e.createElement(A,null,e.createElement("span",null,n)," ",e.createElement(H,{errors:t.levels[n].errors,warnings:t.levels[n].warnings}))))),Object.keys(a).map(n=>e.createElement(se,{key:n,isActive:d===n},e.createElement(me,{title:n,data:v[n]})))):e.createElement("div",null,"Scorecard not found")}export{Oe as ApiListView,We as ApiPage,me as ApiView,Ie as RuleView,Re as RulesView,ze as TeamsView};
|
|
1
|
+
import*as e from"react";import{useCallback as le,useMemo as E,useState as se,useEffect as ie}from"react";import{useLocation as H}from"react-router-dom";import{Flex as oe}from"@redocly/portal-legacy-ui";import{Button as R}from"@redocly/theme/components/Button/Button";import{AddIcon as G}from"@redocly/theme/icons/AddIcon/AddIcon";import{SubtractIcon as _}from"@redocly/theme/icons/SubtractIcon/SubtractIcon";import{ArrowLeftIcon as U}from"@redocly/theme/icons/ArrowLeftIcon/ArrowLeftIcon";import{useProcessScorecard as Z}from"@redocly/theme/ext/process-scorecard";import{getScorecardColorVariable as J,withoutPathPrefix as Q}from"@redocly/theme/core/utils";import{Link as W}from"../../../../client/app/Link";import ce from"../../../../client/app/CircularProgress";import{isDefined as B}from"../../../../utils/guards/is-defined.js";import{removeLeadingSlash as ue}from"../../../../utils/url/remove-leading-slash.js";import{StatusByLevelWidget as me}from"./StatusByLevelWidget";import{OTHER_TEAMS_LABEL as de,NON_CONFORMANT as pe}from"./utils";import{LevelIndicator as ge}from"./LevelIndicator";import{AppPageWrapper as X,CardValue as P,CardsWrapper as Y,CatalogDescription as fe,ModeSwitcherTab as O,ModeSwitcherTabs as Ee,CardRow as ee,ProblemsByStatusCardBody as te,ScoreCardStatusCardBody as re,TableWrap as j,LevelComplianceCardTitle as he,ContentWithDotWrap as k,ScorecardCard as V,ScorecardCardTitle as F}from"./index.styles";import{ApiLevel as ne,InstanceStatus as q,LevelStatus as N,RuleStatus as ae}from"./components";import{Grid as z}from"./Grid/Grid";import{useDetailedScorecard as ye}from"./useDetailedScorecard";import{Gauge as ve,GaugeValue as be}from"./Gauge";function Se(d,c,p){if(d===c)return 0;if(d==null||d==="")return 1;if(c==null||c==="")return-1;if(p==="number"){const u=Number(d),a=Number(c),l=Number.isNaN(u),g=Number.isNaN(a);return l&&g?0:l?1:g?-1:u-a}if(p==="date"){const u=new Date(String(d)).getTime(),a=new Date(String(c)).getTime(),l=Number.isNaN(u),g=Number.isNaN(a);return l&&g?0:l?1:g?-1:u-a}return String(d).localeCompare(String(c))}function $e(d){const c=H(),{data:p,levelNames:u,hasPublishedAt:a,hasTeam:l,teamLabel:g}=d,{getApiTableColumns:L}=Z(),h=le((y,S,x)=>{const w=y.getValue(x)?new Date(y.getValue(x)).getTime():0,r=S.getValue(x)?new Date(S.getValue(x)).getTime():0;return w>r?1:-1},[]),b=E(()=>{const y=L?.()??[],S=y.filter(r=>r.placement==="beforeLevels"),x=y.filter(r=>r.placement!=="beforeLevels"),w=r=>({id:r.id,header:String(r.header),accessorFn:s=>r.getValue?.(s),enableSorting:!!(r.sortingFn||r.sortRule),...r.sortingFn||r.sortRule?{sortingFn:(s,f,n)=>r.sortingFn?r.sortingFn({rowA:s.original,rowB:f.original,valueA:s.getValue(n),valueB:f.getValue(n)}):Se(r.getSortValue?.(s.original)??s.getValue(n),r.getSortValue?.(f.original)??f.getValue(n),r.sortRule||"string")}:{},...r.sortDescFirst!==void 0?{sortDescFirst:r.sortDescFirst}:{},cell:({getValue:s,row:f})=>{const n=s(),i=f.original;return r.render?r.render({row:i,value:n}):n==null||n===""?"-":String(n)},...r.size!==void 0?{size:r.size}:{},...r.minSize!==void 0?{minSize:r.minSize}:{},...r.maxSize!==void 0?{maxSize:r.maxSize}:{}});return[{id:"title",header:"API",accessorKey:"api.title",size:200,cell:({getValue:r,row:s})=>e.createElement(W,{to:Q(c.pathname)+"/apis/"+encodeURIComponent(ue(s.original.api.link))},r()," ",s.original.api.version)},a?{header:"Published at",accessorKey:"api.publishedAt",sortingFn:h,cell:({getValue:r})=>{const s=r();return s?new Date(s).toLocaleDateString():"-"}}:void 0,l?{header:g,accessorKey:"api.team"}:void 0,{id:"level",header:"Level",accessorKey:"scorecard.scorecardLevel",cell:({getValue:r,row:s})=>e.createElement(ne,{level:r(),colorVariable:J(s.original?.scorecard.scorecardLevelIdx,u.length+1)})},...S.map(w),...u.map(r=>({id:r,header:`${r}`,accessorKey:"scorecard.levels",sortingFn:(s,f,n)=>{const i=s.getValue(n)[n].uniqueErrors,D=f.getValue(n)[n].uniqueErrors,t=s.getValue(n)[n].uniqueWarnings,o=f.getValue(n)[n].uniqueWarnings;return i===D?t-o:i-D},cell:({getValue:s,row:{original:f}})=>{const n=s(),i=f.api.link;return n?.[r]?e.createElement(ge,{key:i,uniqueErrors:n[r].uniqueErrors,uniqueWarnings:n[r].uniqueWarnings,customDisplay:n[r].customDisplay,id:i}):null}})),...x.map(w)].filter(B)},[h,u,c.pathname,a,l,g,L]),m=E(()=>{const y=Math.max(b.length-3,0);return`25% max(140px, 15%) max(140px, 10%)${y>0?` repeat(${y}, 1fr)`:""}`},[b.length]);return e.createElement(z,{columns:b,data:p,sortBy:[{id:"title",desc:!1}],gridTemplateColumns:m})}function He(d){const c=H(),{data:p}=d,u=E(()=>[{header:"Rules",accessorKey:"ruleId",cell:({getValue:a})=>e.createElement(W,{to:Q(c.pathname)+"/rules/"+encodeURIComponent(a())},a())},{id:"status",header:"Status",accessorKey:"status",size:200,cell:({row:a})=>e.createElement(ae,{errors:a.original.errorApisCount,warnings:a.original.warningApisCount})},{header:"Problem APIs",width:200,accessorKey:"apisCount",cell:({getValue:a})=>a(),sortDescFirst:!0},{header:"Problem count",size:200,accessorKey:"count",sortDescFirst:!0}],[c.pathname]);return e.createElement(z,{columns:u,data:p,virtualized:!1,sortBy:[{id:"status",desc:!0}]})}function Ge(d){const{data:c,levelNames:p,filters:u,setActiveTab:a,teamLabel:l,teamProperty:g}=d,L=E(()=>[{id:"team",header:`API ${l}`,accessorKey:"team",size:200,cell:({getValue:h})=>e.createElement("a",{href:"#",onClick:b=>{b.preventDefault(),a("apis"),u.find(m=>m.property===g)?.selectOption(h())}},h())},...[pe,...p].map(h=>({id:h,header:`${h}`,accessorFn:b=>b.levels[h]?.apis}))],[u,p,a,l,g]);return e.createElement(z,{columns:L,data:c,sortBy:[{id:"team",desc:!1}],groupHeaderTitle:"APIs by level"})}function Ce(d){const{data:c,title:p}=d,u=E(()=>[{id:"expand",maxSize:40,size:40,header:()=>null,enableSorting:!1,cell:({row:a})=>a.getCanExpand()?e.createElement(R,{onClick:a.getToggleExpandedHandler(),variant:"text",size:"medium",icon:a.getIsExpanded()?e.createElement(_,null):e.createElement(G,null)}):null},{header:"Rules",accessorKey:"ruleId",cell:({getValue:a,row:l})=>l.getCanExpand()?e.createElement("span",{onClick:l.getToggleExpandedHandler()},a()):null},{header:"Status",accessorKey:"status",size:200,cell:({getValue:a})=>{const l=a();return e.createElement(ae,{errors:l?.errorsCount,warnings:l?.warningsCount})},enableSorting:!1},{header:"Problem count",accessorKey:"problemsCount",size:200,sortDescFirst:!0}],[]);return e.createElement(z,{columns:u,data:c,sortBy:[{id:"ruleId",desc:!1}],empty:e.createElement(e.Fragment,null,"\u2705 This API is compliant with ",e.createElement("strong",null,p)," level rules"),subRowKey:"problems"})}function _e(d){const{catalogSlug:c,slug:p,data:u,hasTeam:a,hasPublishedAt:l,teamLabel:g}=d,{apis:L,apisCount:h,warningApisCount:b,errorApisCount:m,levels:y,count:S}=u,x=E(()=>Object.values(L),[L]),w=x.length===0,r=w?void 0:{id:"expand",maxSize:40,size:40,header:()=>null,enableSorting:!1,cell:({row:n})=>n.getCanExpand()?e.createElement(R,{onClick:n.getToggleExpandedHandler(),variant:"text",size:"medium",icon:n.getIsExpanded()?e.createElement(_,null):e.createElement(G,null)}):null},s=E(()=>[r,{header:"API",accessorKey:"title"},l?{header:"Published at",accessorKey:"publishedAt",cell:({getValue:n})=>{const i=n();return i?new Date(i).toLocaleDateString():"-"}}:void 0,a?{header:g,accessorKey:"team",cell:({getValue:n})=>n()||de}:void 0,{header:"Problem count",size:200,accessorKey:"count",cell:({getValue:n})=>n()||0,sortDescFirst:!0}].filter(B),[a,l,g,w]),f=E(()=>Object.entries(u.teams).sort((n,i)=>i[1]-n[1]),[u.teams]);return e.createElement(X,null,e.createElement(R,{icon:e.createElement(U,null),iconPosition:"left",variant:"ghost",size:"large",to:`${c}scorecard`},"Back to dashboard"),e.createElement("h1",null,"Rule ",p),e.createElement(Y,null,e.createElement(V,null,e.createElement(F,null,"Rule status"),e.createElement(re,null,e.createElement("div",null,e.createElement(P,null,h),e.createElement("br",null),"APIs"),e.createElement("div",null,e.createElement(k,null,e.createElement(P,{style:{textAlign:"right"}},h-b-m),e.createElement(q,{severity:"Pass"})),e.createElement(k,null,e.createElement(P,{style:{textAlign:"right"}},b),e.createElement(q,{severity:"Warn"})),e.createElement(k,null,e.createElement(P,{style:{textAlign:"right"}},m),e.createElement(q,{severity:"Error"}))))),e.createElement(V,null,e.createElement(F,null,"Problems by level"),e.createElement(te,null,Object.entries(y).map(([n,i])=>e.createElement(ee,{key:n},e.createElement("span",null,n),e.createElement(ve,{chunks:[{share:i.errors/S*100,colorVariable:"--scorecard-color-error"},{share:i.warnings/S*100,colorVariable:"--scorecard-color-warning"}]}),e.createElement(be,null,i.errors+i.warnings))))),e.createElement(V,null,e.createElement(F,null,`Problems by ${g}`),e.createElement(te,null,f.slice(0,4).map(([n,i])=>e.createElement(ee,{key:n},e.createElement("span",{style:{flex:1,textAlign:"left"}},n),e.createElement(P,null,i)))))),e.createElement(z,{columns:s,data:x,sortBy:[{id:"title",desc:!1}],subRowKey:"problems",slug:p}))}function Ue(d){const{slug:c,api:p,teamLabel:u,catalogSlug:a}=d,{api:l}=p||{},{scorecard:g,isLoading:L}=ye(`/${c}`),{processScorecard:h,getApiTableColumns:b}=Z(),m=g&&h(g,p.api),y=m?.levels||{},S=E(()=>Object.keys(y),[y]),x=E(()=>l?.publishedAt instanceof Date?l?.publishedAt.toLocaleDateString():l?.publishedAt,[l]),w=E(()=>{if(!m?.levels)return{};const t={};for(const o of Object.keys(m.levels)){const A=m.levels[o].problems.reduce((T,C)=>(T[C.ruleId]||(T[C.ruleId]=[]),T[C.ruleId].push(C),T),{});t[o]=Object.entries(A).map(([T,C])=>({ruleId:T,problems:[...C.filter(v=>v.severity==="error"),...C.filter(v=>v.severity==="warn")],problemsCount:C.length,status:{errorsCount:C.filter(v=>v.severity==="error").length,warningsCount:C.filter(v=>v.severity==="warn").length}}))}return t},[m?.levels]),r=E(()=>{if(!m)return[];const t={api:p.api,scorecard:m};return(b?.()??[]).filter(o=>!o.details?.hidden).map(o=>{const A=o.getValue?.(t),T=o.details?.description,C=typeof T=="function"?T(t):T;let v;if(o.details?.render){if(v=o.details.render({row:t,value:A}),v===null)return}else if(o.render){if(v=o.render({row:t,value:A}),v===null)return}else v=A==null||A===""?"-":String(A);const K=o.details?.status,I=typeof K=="function"?K({row:t,value:A}):K,M=o.details?.statusRule,$={errors:I?.errors??(M==="problem-if-truthy"&&A?1:0),warnings:I?.warnings??0};return!I&&M==="problem-if-falsy"&&!A&&($.errors=1),{id:`custom-${o.id}`,label:o.details?.tabLabel||o.header,description:C,content:v,placement:o.placement==="beforeLevels"?"beforeLevels":"afterLevels",status:$}}).filter(B)},[p.api,b,m]),s=E(()=>r.filter(t=>t.placement==="beforeLevels"),[r]),f=E(()=>r.filter(t=>t.placement==="afterLevels"),[r]),n=E(()=>[...s.map(t=>t.id),...S,...f.map(t=>t.id)],[f,s,S]),[i,D]=se(n[0]||"");return ie(()=>{n.length&&D(t=>n.includes(t)?t:n[0])},[n]),L?e.createElement(oe,{justifyContent:"center",mt:"2em"},e.createElement(ce,null)):m?e.createElement(X,null,e.createElement(R,{icon:e.createElement(U,null),iconPosition:"left",variant:"ghost",size:"large",to:`${a}scorecard`},"Back to dashboard"),e.createElement("h1",null,l?.title||c),e.createElement(fe,null,x&&e.createElement(e.Fragment,null,"Published at: ",new Date().toLocaleString(void 0,{timeZoneName:"short"}),e.createElement("br",null)),e.createElement(W,{to:l?.link,external:!0},"Documentation")),e.createElement(Y,null,e.createElement(V,null,e.createElement(he,null,e.createElement("span",null,"Scorecard level"),e.createElement(ne,{level:m.scorecardLevel,colorVariable:J(m.scorecardLevelIdx,Object.keys(y).length)})),e.createElement(re,null,e.createElement("div",null,"Compliance by level"),e.createElement("div",null,Object.entries(m.levels).map(([t,o])=>e.createElement(k,{key:t},e.createElement(P,{style:{width:"100px",textAlign:"right"}},t),e.createElement(N,{errors:o.errors,warnings:o.warnings})))))),e.createElement(me,{title:"Rules compliance",levels:Object.entries(m.levels).map(([t,o])=>({errors:o.uniqueErrors,warnings:o.uniqueWarnings,total:d.rulesPerLevel[t].length,name:t}))}),e.createElement(V,null,e.createElement(F,null,u),e.createElement(P,{style:{fontWeight:"normal"}},l?.team))),e.createElement(Ee,{style:{justifyContent:"flex-start"},"data-component-name":"Scorecard/ModeSwitcherTabs"},s.map(t=>e.createElement(O,{"data-component-name":"Scorecard/ModeSwitcherTab",key:t.id,isActive:i===t.id,onClick:()=>D(t.id)},e.createElement(k,null,e.createElement("span",null,t.label),e.createElement(N,{errors:t.status.errors,warnings:t.status.warnings})))),S.map(t=>e.createElement(O,{"data-component-name":"Scorecard/ModeSwitcherTab",key:t,isActive:i===t,onClick:()=>D(t)},e.createElement(k,null,e.createElement("span",null,t)," ",e.createElement(N,{errors:m.levels[t].errors,warnings:m.levels[t].warnings})))),f.map(t=>e.createElement(O,{"data-component-name":"Scorecard/ModeSwitcherTab",key:t.id,isActive:i===t.id,onClick:()=>D(t.id)},e.createElement(k,null,e.createElement("span",null,t.label),e.createElement(N,{errors:t.status.errors,warnings:t.status.warnings}))))),s.map(t=>e.createElement(j,{key:t.id,isActive:i===t.id},e.createElement(V,null,t.description?e.createElement("p",{style:{marginTop:0,marginBottom:12,color:"var(--text-color-secondary)"}},t.description):null,e.createElement("div",null,t.content)))),S.map(t=>e.createElement(j,{key:t,isActive:i===t},e.createElement(Ce,{title:t,data:w[t]}))),f.map(t=>e.createElement(j,{key:t.id,isActive:i===t.id},e.createElement(V,null,t.description?e.createElement("p",{style:{marginTop:0,marginBottom:12,color:"var(--text-color-secondary)"}},t.description):null,e.createElement("div",null,t.content))))):e.createElement("div",null,"Scorecard not found")}export{$e as ApiListView,Ue as ApiPage,Ce as ApiView,_e as RuleView,He as RulesView,Ge as TeamsView};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/realm",
|
|
3
|
-
"version": "0.130.0-custom.
|
|
3
|
+
"version": "0.130.0-custom.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -91,14 +91,14 @@
|
|
|
91
91
|
"xpath": "0.0.34",
|
|
92
92
|
"yaml-ast-parser": "0.0.43",
|
|
93
93
|
"zod": "^3.25.76",
|
|
94
|
-
"@redocly/config": "0.43.0-custom.0",
|
|
95
94
|
"@redocly/graphql-docs": "1.7.0-custom.0",
|
|
96
|
-
"@redocly/
|
|
97
|
-
"@redocly/portal-legacy-ui": "0.14.0-next.0",
|
|
95
|
+
"@redocly/asyncapi-docs": "1.7.0-custom.0",
|
|
98
96
|
"@redocly/openapi-docs": "3.18.0-custom.0",
|
|
97
|
+
"@redocly/theme": "0.62.0-custom.0",
|
|
98
|
+
"@redocly/config": "0.43.0-custom.0",
|
|
99
|
+
"@redocly/portal-plugin-mock-server": "0.16.0-next.0",
|
|
99
100
|
"@redocly/realm-asyncapi-sdk": "0.9.0-next.0",
|
|
100
|
-
"@redocly/
|
|
101
|
-
"@redocly/theme": "0.62.0-custom.0"
|
|
101
|
+
"@redocly/portal-legacy-ui": "0.14.0-next.0"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
104
|
"react": "^19.2.4",
|