@redocly/realm 0.130.0-custom.2 → 0.130.0-custom.4
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 +5 -5
|
@@ -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 se,useMemo as E,useState as ie,useEffect as oe}from"react";import{useLocation as G}from"react-router-dom";import{Flex as ce}from"@redocly/portal-legacy-ui";import{Button as I}from"@redocly/theme/components/Button/Button";import{AddIcon as _}from"@redocly/theme/icons/AddIcon/AddIcon";import{SubtractIcon as U}from"@redocly/theme/icons/SubtractIcon/SubtractIcon";import{ArrowLeftIcon as Z}from"@redocly/theme/icons/ArrowLeftIcon/ArrowLeftIcon";import{useProcessScorecard as J}from"@redocly/theme/ext/process-scorecard";import{getScorecardColorVariable as Q,withoutPathPrefix as X}from"@redocly/theme/core/utils";import{Link as O}from"../../../../client/app/Link";import ue from"../../../../client/app/CircularProgress";import{isDefined as j}from"../../../../utils/guards/is-defined.js";import{removeLeadingSlash as me}from"../../../../utils/url/remove-leading-slash.js";import{StatusByLevelWidget as de}from"./StatusByLevelWidget";import{OTHER_TEAMS_LABEL as pe,NON_CONFORMANT as ge}from"./utils";import{LevelIndicator as fe}from"./LevelIndicator";import{AppPageWrapper as Y,CardValue as P,CardsWrapper as ee,CatalogDescription as Ee,ModeSwitcherTab as q,ModeSwitcherTabs as he,CardRow as te,ProblemsByStatusCardBody as re,ScoreCardStatusCardBody as ne,TableWrap as M,LevelComplianceCardTitle as ye,ContentWithDotWrap as k,ScorecardCard as V,ScorecardCardTitle as N}from"./index.styles";import{ApiLevel as ae,InstanceStatus as $,LevelStatus as R,RuleStatus as le}from"./components";import{Grid as z}from"./Grid/Grid";import{useDetailedScorecard as ve}from"./useDetailedScorecard";import{Gauge as be,GaugeValue as Se}from"./Gauge";function Ce(c,u,p){if(c===u)return 0;if(c==null||c==="")return 1;if(u==null||u==="")return-1;if(p==="number"){const m=Number(c),a=Number(u),s=Number.isNaN(m),g=Number.isNaN(a);return s&&g?0:s?1:g?-1:m-a}if(p==="date"){const m=new Date(String(c)).getTime(),a=new Date(String(u)).getTime(),s=Number.isNaN(m),g=Number.isNaN(a);return s&&g?0:s?1:g?-1:m-a}return String(c).localeCompare(String(u))}function F(c){return c==="error"?{errors:1,warnings:0}:c==="warning"?{errors:0,warnings:1}:{errors:0,warnings:0}}function He(c){const u=G(),{data:p,levelNames:m,hasPublishedAt:a,hasTeam:s,teamLabel:g}=c,{getApiTableColumns:L}=J(),h=se((y,S,A)=>{const D=y.getValue(A)?new Date(y.getValue(A)).getTime():0,r=S.getValue(A)?new Date(S.getValue(A)).getTime():0;return D>r?1:-1},[]),b=E(()=>{const y=L?.()??[],S=y.filter(r=>r.placement==="beforeLevels"),A=y.filter(r=>r.placement!=="beforeLevels"),D=r=>({id:r.id,header:String(r.header),accessorFn:o=>r.getValue?.(o)??r.getSortValue?.(o),enableSorting:!!(r.sortingFn||r.sortRule||r.getSortValue||r.getValue),sortingFn:(o,f,n)=>{const l=o.original,x=f.original,t=r.getSortValue?.(l)??o.getValue(n),i=r.getSortValue?.(x)??f.getValue(n);return r.sortingFn?r.sortingFn({rowA:l,rowB:x,valueA:t,valueB:i}):Ce(t,i,r.sortRule||"string")},...r.sortDescFirst!==void 0?{sortDescFirst:r.sortDescFirst}:{},cell:({getValue:o,row:f})=>{const n=o(),l=f.original;return r.render?r.render({row:l,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:o})=>e.createElement(O,{to:X(u.pathname)+"/apis/"+encodeURIComponent(me(o.original.api.link))},r()," ",o.original.api.version)},a?{header:"Published at",accessorKey:"api.publishedAt",sortingFn:h,cell:({getValue:r})=>{const o=r();return o?new Date(o).toLocaleDateString():"-"}}:void 0,s?{header:g,accessorKey:"api.team"}:void 0,{id:"level",header:"Level",accessorKey:"scorecard.scorecardLevel",cell:({getValue:r,row:o})=>e.createElement(ae,{level:r(),colorVariable:Q(o.original?.scorecard.scorecardLevelIdx,m.length+1)})},...S.map(D),...m.map(r=>({id:r,header:`${r}`,accessorKey:"scorecard.levels",sortingFn:(o,f,n)=>{const l=o.getValue(n)[n].uniqueErrors,x=f.getValue(n)[n].uniqueErrors,t=o.getValue(n)[n].uniqueWarnings,i=f.getValue(n)[n].uniqueWarnings;return l===x?t-i:l-x},cell:({getValue:o,row:{original:f}})=>{const n=o(),l=f.api.link;return n?.[r]?e.createElement(fe,{key:l,uniqueErrors:n[r].uniqueErrors,uniqueWarnings:n[r].uniqueWarnings,customDisplay:n[r].customDisplay,id:l}):null}})),...A.map(D)].filter(j)},[h,m,u.pathname,a,s,g,L]),d=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:d})}function Ge(c){const u=G(),{data:p}=c,m=E(()=>[{header:"Rules",accessorKey:"ruleId",cell:({getValue:a})=>e.createElement(O,{to:X(u.pathname)+"/rules/"+encodeURIComponent(a())},a())},{id:"status",header:"Status",accessorKey:"status",size:200,cell:({row:a})=>e.createElement(le,{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}],[u.pathname]);return e.createElement(z,{columns:m,data:p,virtualized:!1,sortBy:[{id:"status",desc:!0}]})}function _e(c){const{data:u,levelNames:p,filters:m,setActiveTab:a,teamLabel:s,teamProperty:g}=c,L=E(()=>[{id:"team",header:`API ${s}`,accessorKey:"team",size:200,cell:({getValue:h})=>e.createElement("a",{href:"#",onClick:b=>{b.preventDefault(),a("apis"),m.find(d=>d.property===g)?.selectOption(h())}},h())},...[ge,...p].map(h=>({id:h,header:`${h}`,accessorFn:b=>b.levels[h]?.apis}))],[m,p,a,s,g]);return e.createElement(z,{columns:L,data:u,sortBy:[{id:"team",desc:!1}],groupHeaderTitle:"APIs by level"})}function Ae(c){const{data:u,title:p}=c,m=E(()=>[{id:"expand",maxSize:40,size:40,header:()=>null,enableSorting:!1,cell:({row:a})=>a.getCanExpand()?e.createElement(I,{onClick:a.getToggleExpandedHandler(),variant:"text",size:"medium",icon:a.getIsExpanded()?e.createElement(U,null):e.createElement(_,null)}):null},{header:"Rules",accessorKey:"ruleId",cell:({getValue:a,row:s})=>s.getCanExpand()?e.createElement("span",{onClick:s.getToggleExpandedHandler()},a()):null},{header:"Status",accessorKey:"status",size:200,cell:({getValue:a})=>{const s=a();return e.createElement(le,{errors:s?.errorsCount,warnings:s?.warningsCount})},enableSorting:!1},{header:"Problem count",accessorKey:"problemsCount",size:200,sortDescFirst:!0}],[]);return e.createElement(z,{columns:m,data:u,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 Ue(c){const{catalogSlug:u,slug:p,data:m,hasTeam:a,hasPublishedAt:s,teamLabel:g}=c,{apis:L,apisCount:h,warningApisCount:b,errorApisCount:d,levels:y,count:S}=m,A=E(()=>Object.values(L),[L]),D=A.length===0,r=D?void 0:{id:"expand",maxSize:40,size:40,header:()=>null,enableSorting:!1,cell:({row:n})=>n.getCanExpand()?e.createElement(I,{onClick:n.getToggleExpandedHandler(),variant:"text",size:"medium",icon:n.getIsExpanded()?e.createElement(U,null):e.createElement(_,null)}):null},o=E(()=>[r,{header:"API",accessorKey:"title"},s?{header:"Published at",accessorKey:"publishedAt",cell:({getValue:n})=>{const l=n();return l?new Date(l).toLocaleDateString():"-"}}:void 0,a?{header:g,accessorKey:"team",cell:({getValue:n})=>n()||pe}:void 0,{header:"Problem count",size:200,accessorKey:"count",cell:({getValue:n})=>n()||0,sortDescFirst:!0}].filter(j),[a,s,g,D]),f=E(()=>Object.entries(m.teams).sort((n,l)=>l[1]-n[1]),[m.teams]);return e.createElement(Y,null,e.createElement(I,{icon:e.createElement(Z,null),iconPosition:"left",variant:"ghost",size:"large",to:`${u}scorecard`},"Back to dashboard"),e.createElement("h1",null,"Rule ",p),e.createElement(ee,null,e.createElement(V,null,e.createElement(N,null,"Rule status"),e.createElement(ne,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-d),e.createElement($,{severity:"Pass"})),e.createElement(k,null,e.createElement(P,{style:{textAlign:"right"}},b),e.createElement($,{severity:"Warn"})),e.createElement(k,null,e.createElement(P,{style:{textAlign:"right"}},d),e.createElement($,{severity:"Error"}))))),e.createElement(V,null,e.createElement(N,null,"Problems by level"),e.createElement(re,null,Object.entries(y).map(([n,l])=>e.createElement(te,{key:n},e.createElement("span",null,n),e.createElement(be,{chunks:[{share:l.errors/S*100,colorVariable:"--scorecard-color-error"},{share:l.warnings/S*100,colorVariable:"--scorecard-color-warning"}]}),e.createElement(Se,null,l.errors+l.warnings))))),e.createElement(V,null,e.createElement(N,null,`Problems by ${g}`),e.createElement(re,null,f.slice(0,4).map(([n,l])=>e.createElement(te,{key:n},e.createElement("span",{style:{flex:1,textAlign:"left"}},n),e.createElement(P,null,l)))))),e.createElement(z,{columns:o,data:A,sortBy:[{id:"title",desc:!1}],subRowKey:"problems",slug:p}))}function Ze(c){const{slug:u,api:p,teamLabel:m,catalogSlug:a}=c,{api:s}=p||{},{scorecard:g,isLoading:L}=ve(`/${u}`),{processScorecard:h,getApiTableColumns:b}=J(),d=g&&h(g,p.api),y=d?.levels||{},S=E(()=>Object.keys(y),[y]),A=E(()=>s?.publishedAt instanceof Date?s?.publishedAt.toLocaleDateString():s?.publishedAt,[s]),D=E(()=>{if(!d?.levels)return{};const t={};for(const i of Object.keys(d.levels)){const w=d.levels[i].problems.reduce((T,C)=>(T[C.ruleId]||(T[C.ruleId]=[]),T[C.ruleId].push(C),T),{});t[i]=Object.entries(w).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},[d?.levels]),r=E(()=>{if(!d)return[];const t={api:p.api,scorecard:d};return(b?.()??[]).filter(i=>!i.details?.hidden).map(i=>{const w=i.getValue?.(t),T=i.details?.description,C=typeof T=="function"?T(t):T;let v;if(i.details?.render){if(v=i.details.render({row:t,value:w}),v===null)return}else if(i.render){if(v=i.render({row:t,value:w}),v===null)return}else v=w==null||w===""?"-":String(w);const K=i.details?.status,B=typeof K=="function"?K({row:t,value:w}):K,H=i.details?.statusRule;let W=B||"success";return!B&&H==="problem-if-truthy"&&(W=w?"error":"success"),!B&&H==="problem-if-falsy"&&(W=w?"success":"error"),{id:`custom-${i.id}`,label:i.details?.tabLabel||i.header,description:C,content:v,placement:i.placement==="beforeLevels"?"beforeLevels":"afterLevels",status:W}}).filter(j)},[p.api,b,d]),o=E(()=>r.filter(t=>t.placement==="beforeLevels"),[r]),f=E(()=>r.filter(t=>t.placement==="afterLevels"),[r]),n=E(()=>[...o.map(t=>t.id),...S,...f.map(t=>t.id)],[f,o,S]),[l,x]=ie(n[0]||"");return oe(()=>{n.length&&x(t=>n.includes(t)?t:n[0])},[n]),L?e.createElement(ce,{justifyContent:"center",mt:"2em"},e.createElement(ue,null)):d?e.createElement(Y,null,e.createElement(I,{icon:e.createElement(Z,null),iconPosition:"left",variant:"ghost",size:"large",to:`${a}scorecard`},"Back to dashboard"),e.createElement("h1",null,s?.title||u),e.createElement(Ee,null,A&&e.createElement(e.Fragment,null,"Published at: ",new Date().toLocaleString(void 0,{timeZoneName:"short"}),e.createElement("br",null)),e.createElement(O,{to:s?.link,external:!0},"Documentation")),e.createElement(ee,null,e.createElement(V,null,e.createElement(ye,null,e.createElement("span",null,"Scorecard level"),e.createElement(ae,{level:d.scorecardLevel,colorVariable:Q(d.scorecardLevelIdx,Object.keys(y).length)})),e.createElement(ne,null,e.createElement("div",null,"Compliance by level"),e.createElement("div",null,Object.entries(d.levels).map(([t,i])=>e.createElement(k,{key:t},e.createElement(P,{style:{width:"100px",textAlign:"right"}},t),e.createElement(R,{errors:i.errors,warnings:i.warnings})))))),e.createElement(de,{title:"Rules compliance",levels:Object.entries(d.levels).map(([t,i])=>({errors:i.uniqueErrors,warnings:i.uniqueWarnings,total:c.rulesPerLevel[t].length,name:t}))}),e.createElement(V,null,e.createElement(N,null,m),e.createElement(P,{style:{fontWeight:"normal"}},s?.team))),e.createElement(he,{style:{justifyContent:"flex-start"},"data-component-name":"Scorecard/ModeSwitcherTabs"},o.map(t=>e.createElement(q,{"data-component-name":"Scorecard/ModeSwitcherTab",key:t.id,isActive:l===t.id,onClick:()=>x(t.id)},e.createElement(k,null,e.createElement("span",null,t.label),e.createElement(R,{errors:F(t.status).errors,warnings:F(t.status).warnings})))),S.map(t=>e.createElement(q,{"data-component-name":"Scorecard/ModeSwitcherTab",key:t,isActive:l===t,onClick:()=>x(t)},e.createElement(k,null,e.createElement("span",null,t)," ",e.createElement(R,{errors:d.levels[t].errors,warnings:d.levels[t].warnings})))),f.map(t=>e.createElement(q,{"data-component-name":"Scorecard/ModeSwitcherTab",key:t.id,isActive:l===t.id,onClick:()=>x(t.id)},e.createElement(k,null,e.createElement("span",null,t.label),e.createElement(R,{errors:F(t.status).errors,warnings:F(t.status).warnings}))))),o.map(t=>e.createElement(M,{key:t.id,isActive:l===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(M,{key:t,isActive:l===t},e.createElement(Ae,{title:t,data:D[t]}))),f.map(t=>e.createElement(M,{key:t.id,isActive:l===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{He as ApiListView,Ze as ApiPage,Ae as ApiView,Ue as RuleView,Ge as RulesView,_e 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.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -92,13 +92,13 @@
|
|
|
92
92
|
"yaml-ast-parser": "0.0.43",
|
|
93
93
|
"zod": "^3.25.76",
|
|
94
94
|
"@redocly/config": "0.43.0-custom.0",
|
|
95
|
-
"@redocly/graphql-docs": "1.7.0-custom.0",
|
|
96
|
-
"@redocly/portal-plugin-mock-server": "0.16.0-next.0",
|
|
97
|
-
"@redocly/portal-legacy-ui": "0.14.0-next.0",
|
|
98
95
|
"@redocly/openapi-docs": "3.18.0-custom.0",
|
|
99
96
|
"@redocly/realm-asyncapi-sdk": "0.9.0-next.0",
|
|
97
|
+
"@redocly/graphql-docs": "1.7.0-custom.0",
|
|
100
98
|
"@redocly/asyncapi-docs": "1.7.0-custom.0",
|
|
101
|
-
"@redocly/
|
|
99
|
+
"@redocly/portal-legacy-ui": "0.14.0-next.0",
|
|
100
|
+
"@redocly/theme": "0.62.0-custom.0",
|
|
101
|
+
"@redocly/portal-plugin-mock-server": "0.16.0-next.0"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
104
|
"react": "^19.2.4",
|