@redocly/framework-plugin-apigee 0.1.0-next.0 → 0.1.0-next.10

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.
@@ -0,0 +1,28 @@
1
+ import { QueryClient } from '@tanstack/react-query';
2
+ import type { App, AppOwner, Team, TeamRole } from '../contract.js';
3
+ /** The plugin's cache: module scoped, so it outlives the template while the portal stays open. */
4
+ export declare const queryClient: QueryClient;
5
+ export declare const queryKeys: {
6
+ readonly meta: readonly ['apigee', 'meta'];
7
+ readonly apps: readonly ['apigee', 'apps'];
8
+ readonly teams: readonly ['apigee', 'teams'];
9
+ readonly admin: readonly ['apigee', 'admin'];
10
+ readonly adminRequests: readonly ['apigee', 'admin', 'requests'];
11
+ readonly adminApps: readonly ['apigee', 'admin', 'apps'];
12
+ readonly adminAudit: readonly ['apigee', 'admin', 'audit'];
13
+ };
14
+ export declare const useMeta: (enabled: boolean) => import("@tanstack/react-query").UseQueryResult<import("../contract.js").ApigeeMeta, Error>;
15
+ export declare const useApps: (enabled?: boolean) => import("@tanstack/react-query").UseQueryResult<App[], Error>;
16
+ export declare const useTeams: (enabled?: boolean) => import("@tanstack/react-query").UseQueryResult<Team[], Error>;
17
+ export declare const useAdminRequests: (enabled?: boolean) => import("@tanstack/react-query").UseQueryResult<import("../contract.js").AccessRequest[], Error>;
18
+ export declare const useAdminApps: () => import("@tanstack/react-query").UseQueryResult<import("../contract.js").AdminApp[], Error>;
19
+ export declare const useAdminAudit: () => import("@tanstack/react-query").UseQueryResult<import("../contract.js").AuditEntry[], Error>;
20
+ /** The viewer's own apps share one owner; a team's apps share another. */
21
+ export declare function ownerKey(owner: AppOwner): string;
22
+ export declare function putApp(app: App): void;
23
+ export declare function dropApp(app: App): void;
24
+ export declare function putTeam(team: Team): void;
25
+ /** After the viewer leaves or deletes a team, its apps leave their list too. */
26
+ export declare function dropTeam(teamId: string): void;
27
+ /** Shows the new role at once; when the API rejects it, restores the team and throws. */
28
+ export declare function changeMemberRole(team: Team, email: string, role: TeamRole): Promise<void>;
@@ -0,0 +1 @@
1
+ var w=function(e,t,n,i){function q(a){return a instanceof n?a:new n(function(d){d(a)})}return new(n||(n=Promise))(function(a,d){function A(s){try{c(i.next(s))}catch(m){d(m)}}function x(s){try{c(i.throw(s))}catch(m){d(m)}}function c(s){s.done?a(s.value):q(s.value).then(A,x)}c((i=i.apply(e,t||[])).next())})};import{QueryClient as h,useQuery as u}from"@tanstack/react-query";import{ApiRequestError as g,apigeeApi as o}from"./api.js";const p=new h({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1,retry:(e,t)=>e<1&&!(t instanceof g&&t.status<500)}}}),r={meta:["apigee","meta"],apps:["apigee","apps"],teams:["apigee","teams"],admin:["apigee","admin"],adminRequests:["apigee","admin","requests"],adminApps:["apigee","admin","apps"],adminAudit:["apigee","admin","audit"]},F=e=>u({queryKey:r.meta,queryFn:o.meta,enabled:e}),Q=(e=!0)=>u({queryKey:r.apps,queryFn:o.listApps,enabled:e}),R=(e=!0)=>u({queryKey:r.teams,queryFn:o.listTeams,enabled:e}),O=(e=!0)=>u({queryKey:r.adminRequests,queryFn:o.adminRequests,enabled:e}),b=()=>u({queryKey:r.adminApps,queryFn:o.adminApps}),D=()=>u({queryKey:r.adminAudit,queryFn:o.adminAudit});function l(e){return e.kind==="team"?`team:${e.teamId}`:"developer"}const y=(e,t)=>e.id===t.id&&l(e.owner)===l(t.owner);function T(e){p.setQueryData(r.apps,(t=[])=>t.some(n=>y(n,e))?t.map(n=>y(n,e)?e:n):[...t,e])}function j(e){p.setQueryData(r.apps,t=>t?.filter(n=>!y(n,e)))}function f(e){p.setQueryData(r.teams,(t=[])=>t.some(n=>n.id===e.id)?t.map(n=>n.id===e.id?e:n):[...t,e].sort((n,i)=>n.name.localeCompare(i.name)))}function _(e){p.setQueryData(r.teams,t=>t?.filter(n=>n.id!==e)),p.setQueryData(r.apps,t=>t?.filter(n=>!(n.owner.kind==="team"&&n.owner.teamId===e)))}function C(e,t,n){return w(this,void 0,void 0,function*(){f(Object.assign(Object.assign({},e),{members:e.members.map(i=>i.email===t?Object.assign(Object.assign({},i),{role:n}):i)}));try{f(yield o.setMemberRole(e.id,t,n))}catch(i){throw f(e),i}})}export{C as changeMemberRole,j as dropApp,_ as dropTeam,l as ownerKey,T as putApp,f as putTeam,p as queryClient,r as queryKeys,b as useAdminApps,D as useAdminAudit,O as useAdminRequests,Q as useApps,F as useMeta,R as useTeams};
@@ -1,2 +1,5 @@
1
1
  import type { ReactElement } from 'react';
2
+ export declare function ApprovalsDescription({ organization }: {
3
+ organization: string;
4
+ }): ReactElement;
2
5
  export declare function AdminView(): ReactElement;
@@ -1,21 +1,16 @@
1
- var W=function(n,v,h,p){function k(a){return a instanceof h?a:new h(function(u){u(a)})}return new(h||(h=Promise))(function(a,u){function l(i){try{o(p.next(i))}catch(g){u(g)}}function d(i){try{o(p.throw(i))}catch(g){u(g)}}function o(i){i.done?a(i.value):k(i.value).then(l,d)}o((p=p.apply(n,v||[])).next())})};import{Fragment as E,jsx as e,jsxs as r}from"react/jsx-runtime";import{useState as $}from"react";import z from"styled-components";import{Button as L}from"@redocly/theme/components/Button/Button";import{Dropdown as F}from"@redocly/theme/components/Dropdown/Dropdown";import{DropdownMenu as H}from"@redocly/theme/components/Dropdown/DropdownMenu";import{Tag as w}from"@redocly/theme/components/Tag/Tag";import{CDNIcon as I}from"@redocly/theme/icons/CDNIcon/CDNIcon";import{apigeeApi as A}from"../api.js";import{useApigee as O}from"../context.js";import{formatDateTime as N,useAsync as D}from"../hooks.js";import{EmptyState as R,Loading as j,Mono as V,Muted as s,Notice as C,PageHeader as G,Row as J,Stat as y,Stats as Q,StatusTag as U,Table as _,TableWrap as q}from"../Primitives.js";import{ConfirmDialog as X}from"./Dialogs.js";const Y=z.div`
2
- display: flex;
3
- gap: var(--spacing-xxs);
1
+ var te=function(l,p,m,v){function N(f){return f instanceof m?f:new m(function(h){h(f)})}return new(m||(m=Promise))(function(f,h){function y(d){try{c(v.next(d))}catch(u){h(u)}}function w(d){try{c(v.throw(d))}catch(u){h(u)}}function c(d){d.done?f(d.value):N(d.value).then(y,w)}c((v=v.apply(l,p||[])).next())})};import{Fragment as ae,jsx as t,jsxs as n}from"react/jsx-runtime";import{useState as W}from"react";import S from"styled-components";import{Button as C}from"@redocly/theme/components/Button/Button";import{Segmented as ie}from"@redocly/theme/components/Segmented/Segmented";import{Select as ne}from"@redocly/theme/components/Select/Select";import{Tag as Q}from"@redocly/theme/components/Tag/Tag";import{useToast as re}from"@redocly/theme/core/hooks/use-toast";import{breakpoints as oe}from"@redocly/theme/core/utils/media-css";import{CDNIcon as de}from"@redocly/theme/icons/CDNIcon/CDNIcon";import{apigeeApi as le}from"../api.js";import{useApigee as ce}from"../context.js";import{errorMessage as j,formatDateTime as q,matches as I,useSearchParam as se,useSearchText as pe}from"../hooks.js";import{EmptyState as D,FilterSlot as he,ListSkeleton as z,Mono as ue,Muted as s,NoMatches as me,Notice as B,PageHeader as ve,ProductTag as H,Row as V,SearchField as ge,Stat as P,Stats as fe,Table as M,TableWrap as K,Toolbar as we}from"../Primitives.js";import{queryClient as G,queryKeys as J,useAdminApps as be,useAdminAudit as Ae,useAdminRequests as Ne}from"../queries.js";import{ConfirmDialog as Pe}from"./Dialogs.js";function ye({organization:l}){return n(ae,{children:["Access requests for API products that require manual approval in Apigee organization"," ",t("strong",{children:l}),"."]})}const ke=S.div`
4
2
  margin-bottom: var(--spacing-base);
5
- `,P=z.button`
6
- border: none;
7
- background: ${({$active:n})=>n?"var(--layer-color-active)":"transparent"};
8
- color: ${({$active:n})=>n?"var(--text-color-primary)":"var(--text-color-secondary)"};
9
- font: inherit;
10
- padding: var(--spacing-xxs) var(--spacing-sm);
11
- border-radius: var(--border-radius-md);
12
- cursor: pointer;
13
- display: inline-flex;
14
- align-items: center;
15
- gap: var(--spacing-xs);
3
+ `,xe=S(s)`
4
+ display: inline-block;
5
+ max-width: 200px;
6
+ white-space: normal;
7
+ text-align: left;
8
+ `,Te=S(V)`
9
+ flex-wrap: nowrap;
16
10
 
17
- &:hover {
18
- background: var(--layer-color-hover);
19
- color: var(--text-color-primary);
11
+ @media (max-width: ${oe.small}) {
12
+ > button {
13
+ flex: 1;
14
+ }
20
15
  }
21
- `;function x(n){return n.kind==="developer"?{title:n.email,subtitle:"Personal"}:{title:n.teamId,subtitle:"Team"}}function pe(){var n,v,h,p;const{meta:k}=O(),[a,u]=$("pending"),l=D(()=>A.adminRequests(),"admin-requests"),d=D(()=>A.adminApps(),"admin-apps"),o=D(()=>A.adminAudit(),"admin-audit"),[i,g]=$(null),S=()=>{l.reload(),d.reload(),o.reload()},b=(n=l.data)!==null&&n!==void 0?n:[],f=(v=d.data)!==null&&v!==void 0?v:[],B=f.reduce((t,c)=>t+c.credentials.filter(T=>T.status==="approved").length,0),M=new Set(f.filter(t=>t.owner.kind==="developer").map(t=>t.owner.kind==="developer"&&t.owner.email)).size,K=new Set(f.filter(t=>t.owner.kind==="team").map(t=>t.owner.kind==="team"&&t.owner.teamId)).size;return r("div",{"data-testid":"apigee-admin",children:[e(G,{title:"Approvals",description:r(E,{children:["Access requests for API products that require manual approval in Apigee organization"," ",e("strong",{children:k.organizationName}),"."]}),actions:e(L,{variant:"outlined",onClick:S,icon:e(I,{name:"arrows-rotate",size:"16px"}),children:"Refresh"})}),r(Q,{children:[r(y,{children:[e("strong",{"data-testid":"apigee-stat-pending",children:l.data?b.length:"\u2026"}),e(s,{children:"Pending requests"})]}),r(y,{children:[e("strong",{children:d.data?B:"\u2026"}),e(s,{children:"Approved keys"})]}),r(y,{children:[e("strong",{children:d.data?M:"\u2026"}),e(s,{children:"Developers with apps"})]}),r(y,{children:[e("strong",{children:d.data?K:"\u2026"}),e(s,{children:"Teams with apps"})]})]}),r(Y,{role:"tablist",children:[r(P,{$active:a==="pending",onClick:()=>u("pending"),role:"tab","data-testid":"apigee-admin-tab-pending",children:["Pending ",b.length>0?e(w,{color:"orange",children:b.length}):null]}),e(P,{$active:a==="apps",onClick:()=>u("apps"),role:"tab","data-testid":"apigee-admin-tab-apps",children:"All apps"}),e(P,{$active:a==="audit",onClick:()=>u("audit"),role:"tab","data-testid":"apigee-admin-tab-audit",children:"Audit log"})]}),a==="pending"?l.loading&&!l.data?e(j,{children:"Loading requests\u2026"}):l.error?e(C,{tone:"danger",children:l.error}):b.length===0?e(R,{icon:"circle-check",title:"Nothing to review",text:"Every request for a manually approved product has been handled."}):e(q,{children:r(_,{"data-testid":"apigee-requests-table",children:[e("thead",{children:r("tr",{children:[e("th",{children:"Requested by"}),e("th",{children:"App"}),e("th",{children:"API product"}),e("th",{children:"Reason"}),e("th",{children:"Requested"}),e("th",{className:"actions"})]})}),e("tbody",{children:b.map(t=>{const c=x(t.owner);return r("tr",{"data-testid":"apigee-request-row",children:[r("td",{children:[c.title,e("br",{}),r(s,{children:[c.subtitle,t.requestedBy&&t.requestedBy!==c.title?` \xB7 requested by ${t.requestedBy}`:""]})]}),r("td",{children:[t.appName,e("br",{}),e(V,{children:e(s,{children:t.consumerKey})})]}),e("td",{children:e(w,{color:"orange",children:t.apiProduct})}),e("td",{children:t.note?t.note:e(s,{children:"No reason given"})}),e("td",{children:N(t.requestedAt)}),e("td",{className:"actions",children:e(F,{trigger:e(L,{variant:"text",size:"small","aria-label":"Decide",icon:e(I,{name:"ellipsis-vertical",size:"14px"}),"data-testid":"apigee-request-menu"}),alignment:"end",portalled:!0,children:e(H,{items:[{content:"Approve",disabled:!t.canDecide,onAction:()=>g({request:t,action:"approve"}),dataAttributes:{"data-testid":"apigee-approve"}},{content:"Reject",dangerous:!0,separatorLine:!0,disabled:!t.canDecide,onAction:()=>g({request:t,action:"revoke"}),dataAttributes:{"data-testid":"apigee-reject"}}]})})})]},t.id)})})]})}):null,a==="apps"?d.loading&&!d.data?e(j,{children:"Loading apps\u2026"}):d.error?e(C,{tone:"danger",children:d.error}):f.length===0?e(R,{icon:"key",title:"No apps yet",text:"Apps developers register appear here."}):e(q,{children:r(_,{"data-testid":"apigee-admin-apps-table",children:[e("thead",{children:r("tr",{children:[e("th",{children:"App"}),e("th",{children:"Owner"}),e("th",{children:"Keys"}),e("th",{children:"API products"}),e("th",{children:"Created"})]})}),e("tbody",{children:f.map(t=>{const c=x(t.owner),T=[...new Map(t.credentials.flatMap(m=>m.apiProducts).map(m=>[m.id,m])).values()];return r("tr",{children:[r("td",{children:[t.name,t.status==="revoked"?e(w,{color:"red",children:"Revoked"}):null]}),r("td",{children:[c.title,e("br",{}),e(s,{children:c.subtitle})]}),e("td",{children:t.credentials.length}),e("td",{children:e(J,{children:T.map(m=>e(U,{status:m.status,label:m.id},m.id))})}),e("td",{children:N(t.createdAt)})]},`${c.title}:${t.id}`)})})]})}):null,a==="audit"?o.loading&&!o.data?e(j,{children:"Loading the audit log\u2026"}):o.error?e(C,{tone:"danger",children:o.error}):((h=o.data)!==null&&h!==void 0?h:[]).length===0?e(R,{icon:"file-lines",title:"No decisions yet",text:"Approvals and rejections made here are recorded with who made them."}):e(q,{children:r(_,{"data-testid":"apigee-audit-table",children:[e("thead",{children:r("tr",{children:[e("th",{children:"When"}),e("th",{children:"Reviewer"}),e("th",{children:"Action"}),e("th",{children:"Target"})]})}),e("tbody",{children:((p=o.data)!==null&&p!==void 0?p:[]).map(t=>r("tr",{children:[e("td",{children:N(t.at)}),e("td",{children:t.actor}),e("td",{children:e(w,{color:t.action==="approve"?"green":"red",children:t.action==="approve"?"Approved":"Rejected"})}),r("td",{children:[t.apiProduct," \xB7 ",t.appName," (",x(t.owner).title,")",t.note?r(s,{children:[" \u2014 \u201C",t.note,"\u201D"]}):null]})]},t.id))})]})}):null,e(X,{open:i!==null,onClose:()=>g(null),title:i?.action==="approve"?"Approve access?":"Reject request?",confirmLabel:i?.action==="approve"?"Approve":"Reject",danger:i?.action==="revoke",withNote:!0,noteLabel:"Comment for the developer",notePlaceholder:i?.action==="approve"?"Anything the developer should know before they start":"Why the request is rejected and what would change the decision",onConfirm:t=>W(this,void 0,void 0,function*(){return i&&(yield A.adminDecide(i.request.id,i.action,t),S()),!0}),children:i?r("p",{children:[e("strong",{children:i.request.apiProduct})," for"," ",e("strong",{children:i.request.appName})," (",x(i.request.owner).title,").",i.action==="approve"?" The key starts working for this product right away.":" The product stays revoked on this key until it is approved later."]}):null})]})}export{pe as AdminView};
16
+ `;function b(l,p){return l.kind==="developer"?{title:l.email,subtitle:"Personal"}:{title:p??l.teamId,subtitle:"Team"}}const U=()=>G.invalidateQueries({queryKey:J.admin});function Oe(){var l,p,m,v;const{meta:N}=ce(),f=re(),[h,y]=W("pending"),w=Ne(),c=be(),d=Ae(),[u,$]=pe(),[g,L]=se("product"),[a,k]=W(null),x=(l=w.data)!==null&&l!==void 0?l:[],A=(p=c.data)!==null&&p!==void 0?p:[],X=[{value:"",element:"All API products"},...N.apiProducts.map(e=>({value:e.id,element:e.name}))],E=x.filter(e=>{var i;return(!g||e.apiProduct===g)&&I(u,b(e.owner,e.teamName).title,e.requestedBy,e.appName,(i=e.apiProductName)!==null&&i!==void 0?i:e.apiProduct,e.note)}),F=A.filter(e=>{const i=e.credentials.flatMap(o=>o.apiProducts);return(!g||i.some(o=>o.id===g))&&I(u,e.name,b(e.owner,e.teamName).title,...i.map(o=>{var r;return(r=o.name)!==null&&r!==void 0?r:o.id}))}),O=((m=d.data)!==null&&m!==void 0?m:[]).filter(e=>{var i;return(!g||e.apiProduct===g)&&I(u,e.actor,e.appName,b(e.owner,e.teamName).title,(i=e.apiProductName)!==null&&i!==void 0?i:e.apiProduct,e.note)}),T=!!(u||g),_=t(me,{onClear:()=>{$(""),L("")}}),Y=A.reduce((e,i)=>e+i.credentials.filter(o=>o.status==="approved").length,0),Z=new Set(A.filter(e=>e.owner.kind==="developer").map(e=>e.owner.kind==="developer"&&e.owner.email)).size,ee=new Set(A.filter(e=>e.owner.kind==="team").map(e=>e.owner.kind==="team"&&e.owner.teamId)).size;return n("div",{"data-testid":"apigee-admin",children:[t(ve,{title:"Approvals",description:t(ye,{organization:N.organizationName}),actions:t(C,{variant:"outlined",onClick:U,icon:t(de,{name:"arrows-rotate",size:"16px"}),children:"Refresh"})}),n(fe,{children:[n(P,{children:[t("strong",{"data-testid":"apigee-stat-pending",children:w.data?x.length:"\u2026"}),t(s,{children:"Pending requests"})]}),n(P,{children:[t("strong",{children:c.data?Y:"\u2026"}),t(s,{children:"Approved keys"})]}),n(P,{children:[t("strong",{children:c.data?Z:"\u2026"}),t(s,{children:"Developers with apps"})]}),n(P,{children:[t("strong",{children:c.data?ee:"\u2026"}),t(s,{children:"Teams with apps"})]})]}),t(ke,{children:t(ie,{value:h,onChange:e=>y(e.value),options:[{value:"pending",label:"Pending"},{value:"apps",label:"All apps"},{value:"audit",label:"Audit log"}]})}),n(we,{children:[t(ge,{value:u,onChange:$,placeholder:"Search apps, developers or teams",testId:"apigee-admin-search"}),t(he,{children:t(ne,{value:g,options:X,onChange:e=>L(String(e)),dataTestId:"apigee-product-filter"})})]}),h==="pending"?w.data?T&&E.length===0?_:x.length===0?t(D,{icon:"circle-check",title:"Nothing to review",text:"Every request for a manually approved product has been handled."}):t(K,{children:n(M,{"data-testid":"apigee-requests-table",children:[t("thead",{children:n("tr",{children:[t("th",{children:"Requested by"}),t("th",{children:"App"}),t("th",{children:"API product"}),t("th",{children:"Reason"}),t("th",{children:"Requested"}),t("th",{className:"actions"})]})}),t("tbody",{children:E.map(e=>{var i;const o=b(e.owner,e.teamName),r=(i=e.apiProductName)!==null&&i!==void 0?i:e.apiProduct;return n("tr",{"data-testid":"apigee-request-row",children:[n("td",{children:[o.title,t("br",{}),n(s,{children:[o.subtitle,e.requestedBy&&e.requestedBy!==o.title?` \xB7 requested by ${e.requestedBy}`:""]})]}),n("td",{"data-label":"App",children:[e.appName,t("br",{}),t(ue,{children:t(s,{children:e.consumerKey})})]}),t("td",{"data-label":"API product",children:t(H,{name:r,status:"pending"})}),t("td",{"data-label":"Reason",children:e.note?e.note:t(s,{children:"No reason given"})}),t("td",{"data-label":"Requested",children:q(e.requestedAt)}),t("td",{className:"actions",children:e.canDecide?n(Te,{children:[t(C,{variant:"primary",size:"small",onClick:()=>k({request:e,action:"approve"}),"data-testid":"apigee-approve",children:"Approve"}),t(C,{variant:"outlined",tone:"danger",size:"small",onClick:()=>k({request:e,action:"revoke"}),"data-testid":"apigee-reject",children:"Reject"})]}):n(xe,{"data-testid":"apigee-cannot-decide",children:["Only maintainers of ",r," can decide"]})})]},e.id)})})]})}):w.isError?t(B,{tone:"danger",children:j(w.error)}):t(z,{label:"Loading requests\u2026"}):null,h==="apps"?c.data?T&&F.length===0?_:A.length===0?t(D,{icon:"key",title:"No apps yet",text:"Apps developers register appear here."}):t(K,{children:n(M,{"data-testid":"apigee-admin-apps-table",children:[t("thead",{children:n("tr",{children:[t("th",{children:"App"}),t("th",{children:"Owner"}),t("th",{children:"Keys"}),t("th",{children:"API products"}),t("th",{children:"Created"})]})}),t("tbody",{children:F.map(e=>{const i=b(e.owner,e.teamName),o=[...new Map(e.credentials.flatMap(r=>r.apiProducts).map(r=>[r.id,r])).values()];return n("tr",{children:[n("td",{children:[e.name,e.status==="revoked"?t(Q,{color:"red",children:"Revoked"}):null]}),n("td",{"data-label":"Owner",children:[i.title,t("br",{}),t(s,{children:i.subtitle})]}),t("td",{"data-label":"Keys",children:e.credentials.length}),t("td",{"data-label":"API products",children:t(V,{children:o.map(r=>{var R;return t(H,{name:(R=r.name)!==null&&R!==void 0?R:r.id,status:r.status},r.id)})})}),t("td",{"data-label":"Created",children:q(e.createdAt)})]},`${e.owner.kind==="team"?e.owner.teamId:e.owner.email}:${e.id}`)})})]})}):c.isError?t(B,{tone:"danger",children:j(c.error)}):t(z,{label:"Loading apps\u2026"}):null,h==="audit"?d.data?T&&O.length===0?_:d.data.length===0?t(D,{icon:"file-lines",title:"No decisions yet",text:"Approvals and rejections made here are recorded with who made them."}):t(K,{children:n(M,{"data-testid":"apigee-audit-table",children:[t("thead",{children:n("tr",{children:[t("th",{children:"When"}),t("th",{children:"Reviewer"}),t("th",{children:"Action"}),t("th",{children:"Target"})]})}),t("tbody",{children:O.map(e=>{var i;return n("tr",{children:[t("td",{children:q(e.at)}),t("td",{"data-label":"Reviewer",children:e.actor}),t("td",{"data-label":"Action",children:t(Q,{color:e.action==="approve"?"green":"red",children:e.action==="approve"?"Approved":"Rejected"})}),n("td",{"data-label":"Target",children:[(i=e.apiProductName)!==null&&i!==void 0?i:e.apiProduct," \xB7 ",e.appName," (",b(e.owner,e.teamName).title,")",e.note?n(s,{children:[" \u2014 \u201C",e.note,"\u201D"]}):null]})]},e.id)})})]})}):d.isError?t(B,{tone:"danger",children:j(d.error)}):t(z,{label:"Loading the audit log\u2026"}):null,t(Pe,{open:a!==null,onClose:()=>k(null),title:a?.action==="approve"?"Approve access?":"Reject request?",confirmLabel:a?.action==="approve"?"Approve":"Reject",danger:a?.action==="revoke",withNote:!0,noteLabel:"Comment for the developer",notePlaceholder:a?.action==="approve"?"Anything the developer should know before they start":"Why the request is rejected and what would change the decision",onConfirm:e=>te(this,void 0,void 0,function*(){var i;return a&&(yield le.adminDecide(a.request.id,a.action,e),yield U(),G.invalidateQueries({queryKey:J.apps}),f.success(`${a.action==="approve"?"Approved":"Rejected"} ${(i=a.request.apiProductName)!==null&&i!==void 0?i:a.request.apiProduct} for ${a.request.appName}`)),!0}),children:a?n("p",{children:[t("strong",{children:(v=a.request.apiProductName)!==null&&v!==void 0?v:a.request.apiProduct})," for"," ",t("strong",{children:a.request.appName})," (",b(a.request.owner,a.request.teamName).title,").",a.action==="approve"?" The key starts working for this product right away.":" The product stays revoked on this key until it is approved later."]}):null})]})}export{Oe as AdminView,ye as ApprovalsDescription};
@@ -1,11 +1,14 @@
1
1
  import type { ReactElement } from 'react';
2
- import type { ApiProduct, Team } from '../../contract.js';
2
+ import type { App } from '../../contract.js';
3
3
  export type AppSelection = {
4
4
  appId: string;
5
5
  teamId?: string;
6
6
  } | null;
7
- export declare function AppsView({ selection, teams, products, }: {
7
+ export declare const APPS_DESCRIPTION = "Register apps and manage the API keys that call the APIs through Apigee.";
8
+ export declare function AppsView({ selection }: {
8
9
  selection: AppSelection;
9
- teams: Team[];
10
- products: ApiProduct[];
10
+ }): ReactElement;
11
+ export declare function AppsTable({ apps, showOwner }: {
12
+ apps: App[];
13
+ showOwner: boolean;
11
14
  }): ReactElement;
@@ -1 +1 @@
1
- var D=function(t,l,a,s){function w(m){return m instanceof a?m:new a(function(y){y(m)})}return new(a||(a=Promise))(function(m,y){function c(d){try{g(s.next(d))}catch(k){y(k)}}function f(d){try{g(s.throw(d))}catch(k){y(k)}}function g(d){d.done?m(d.value):w(d.value).then(c,f)}g((s=s.apply(t,l||[])).next())})};import{Fragment as T,jsx as e,jsxs as n}from"react/jsx-runtime";import{useEffect as J,useMemo as E,useState as K}from"react";import{useNavigate as Q}from"react-router";import{Button as b}from"@redocly/theme/components/Button/Button";import{Dropdown as M}from"@redocly/theme/components/Dropdown/Dropdown";import{DropdownMenu as B}from"@redocly/theme/components/Dropdown/DropdownMenu";import{Tag as X}from"@redocly/theme/components/Tag/Tag";import{CDNIcon as A}from"@redocly/theme/icons/CDNIcon/CDNIcon";import{apigeeApi as P}from"../api.js";import{useApigee as Y}from"../context.js";import{maskKey as Z}from"../../contract.js";import{copyText as ee,formatDate as $,useAsync as te}from"../hooks.js";import{Dot as ie,EmptyState as L,ListItem as ne,ListTitle as U,Loading as re,Mono as H,Muted as C,Notice as O,Overview as ae,PageHeader as R,Row as j,Section as oe,SectionHeader as de,SectionTitle as le,SplitLayout as se,StatusTag as F,Table as ce,TableWrap as ue}from"../Primitives.js";import{AppDialog as q,ConfirmDialog as V,KeyDialog as pe}from"./Dialogs.js";function me(t,l){var a,s;return t.kind==="developer"?"Personal":`Team \xB7 ${(s=(a=l.find(w=>w.id===t.teamId))===null||a===void 0?void 0:a.name)!==null&&s!==void 0?s:t.teamId}`}function he(t){if(t.status==="revoked")return"red";const l=t.credentials.flatMap(a=>a.apiProducts);return l.some(a=>a.status==="pending")?"orange":l.some(a=>a.status==="approved")?"green":"grey"}function W(t){if(t.status!=="approved")return t.status;const{apiProducts:l}=t;return l.some(a=>a.status==="pending")?"pending":l.length>0&&l.every(a=>a.status==="revoked")?"revoked":"approved"}function _e({selection:t,teams:l,products:a}){var s;const{link:w,title:m}=Y(),y=Q(),c=te(()=>P.listApps(),"apps"),[f,g]=K(null);J(()=>{var r,u;const v=new URLSearchParams(window.location.search);v.has("createApp")&&(g({product:(r=v.get("apiProduct"))!==null&&r!==void 0?r:void 0,teamId:(u=v.get("team"))!==null&&u!==void 0?u:void 0}),y(w(),{replace:!0}))},[w,y]);const d=E(()=>{var r;return!t||!c.data?null:(r=c.data.find(u=>u.id===t.appId&&(t.teamId?u.owner.kind==="team"&&u.owner.teamId===t.teamId:u.owner.kind==="developer")))!==null&&r!==void 0?r:null},[c.data,t]),k=E(()=>{var r;const u=((r=c.data)!==null&&r!==void 0?r:[]).filter(x=>x.owner.kind==="developer"),v=l.map(x=>{var i;return{team:x,apps:((i=c.data)!==null&&i!==void 0?i:[]).filter(p=>p.owner.kind==="team"&&p.owner.teamId===x.id)}});return{personal:u,byTeam:v}},[c.data,l]),I=r=>w(`/${encodeURIComponent(r.id)}`,r.owner.kind==="team"?{team:r.owner.teamId}:void 0),S=r=>D(this,void 0,void 0,function*(){const u=yield P.createApp(r);return c.reload(),y(I(u)),u});if(c.loading&&!c.data)return e(re,{children:"Loading your apps\u2026"});if(c.error)return e(O,{tone:"danger",children:c.error});const z=(s=c.data)!==null&&s!==void 0?s:[],_=e(q,{open:f!==null,onClose:()=>g(null),onSubmit:S,products:a,teams:l,initialProduct:f?.product,initialTeamId:f?.teamId});return z.length===0?n(T,{children:[e(R,{title:m,description:"Register applications and manage the API keys that call the APIs through Apigee."}),e(L,{icon:"key",title:"Create your first app",text:"An app holds the API keys your software sends. Pick the API products it needs; the keys for approved products work right away.",action:e(b,{variant:"primary",onClick:()=>g({}),icon:e(A,{name:"plus",size:"16px"}),"data-testid":"apigee-new-app",children:"New application"})}),_]}):n(T,{children:[e(R,{title:m,description:"Register applications and manage the API keys that call the APIs through Apigee.",actions:e(b,{variant:"primary",onClick:()=>g({}),icon:e(A,{name:"plus",size:"16px"}),"data-testid":"apigee-new-app",children:"New application"})}),n(se,{children:[n("aside",{"data-testid":"apigee-app-list",children:[k.personal.length>0?e(U,{children:"Personal"}):null,k.personal.map(r=>e(G,{app:r,to:I(r),active:d===r},`dev:${r.id}`)),k.byTeam.map(({team:r,apps:u})=>u.length>0?n("div",{style:{marginTop:"var(--spacing-base)"},children:[n(U,{children:["Team \xB7 ",r.name]}),u.map(v=>e(G,{app:v,to:I(v),active:d===v},`team:${r.id}:${v.id}`))]},r.id):null)]}),e("div",{children:d?e(ve,{app:d,teams:l,products:a,onChanged:()=>c.reload(),onDeleted:()=>{c.reload(),y(w())}}):e(L,{icon:"arrow-left",title:"Select an app",text:"Choose an app on the left to see its keys, or create a new one."})})]}),_]})}function G({app:t,to:l,active:a}){const s=t.credentials.length;return n(ne,{to:l,$active:a,"data-testid":"apigee-app-row",children:[n("span",{children:[t.name,e("br",{}),n(C,{children:[s," ",s===1?"key":"keys"]})]}),e(ie,{$color:he(t)})]})}function ve({app:t,teams:l,products:a,onChanged:s,onDeleted:w}){const m=t.owner.kind==="team"?t.owner.teamId:void 0,[y,c]=K(!1),[f,g]=K(!1),[d,k]=K(null),[I,S]=K(null),[z,_]=K(new Set),[r,u]=K(null),v=(i,p)=>D(this,void 0,void 0,function*(){(yield ee(i))&&(u(p),setTimeout(()=>u(null),1500))}),x=i=>{var p,o;return(o=(p=a.find(h=>h.id===i))===null||p===void 0?void 0:p.name)!==null&&o!==void 0?o:i};return n("div",{"data-testid":"apigee-app-detail",children:[e(R,{title:n(T,{children:[t.name,t.status==="revoked"?e(X,{color:"red",children:"Revoked"}):null]}),description:t.description||void 0,actions:n(T,{children:[e(b,{variant:"outlined",onClick:()=>c(!0),icon:e(A,{name:"pen",size:"16px"}),"data-testid":"apigee-edit-app",children:"Edit"}),e(M,{trigger:e(b,{variant:"text","aria-label":"More",icon:e(A,{name:"ellipsis-vertical",size:"16px"}),"data-testid":"apigee-app-menu"}),alignment:"end",children:e(B,{items:[{content:"Delete application",dangerous:!0,onAction:()=>g(!0),dataAttributes:{"data-testid":"apigee-delete-app"}}]})})]})}),n(ae,{children:[n("div",{children:[e("dt",{children:"Owner"}),n("dd",{children:[e(A,{name:t.owner.kind==="team"?"user-group":"user",size:"16px"}),me(t.owner,l)]})]}),n("div",{children:[e("dt",{children:"Created"}),e("dd",{children:$(t.createdAt)})]}),n("div",{className:"wide",children:[e("dt",{children:"Callback URL"}),e("dd",{children:t.callbackUrl||e(C,{children:"Not set"})})]})]}),n(oe,{children:[n(de,{children:[e(le,{children:"API keys"}),e(b,{variant:"outlined",size:"small",onClick:()=>k({}),icon:e(A,{name:"plus",size:"14px"}),"data-testid":"apigee-create-key",children:"Create key"})]}),t.credentials.length===0?e(L,{icon:"key",title:"No keys yet",text:"Create a key and pick the API products it may call."}):e(ue,{children:n(ce,{"data-testid":"apigee-keys-table",children:[e("thead",{children:n("tr",{children:[e("th",{children:"Key"}),e("th",{children:"API products"}),e("th",{children:"Status"}),e("th",{className:"actions"})]})}),e("tbody",{children:t.credentials.map(i=>{const p=z.has(i.consumerKey);return n("tr",{"data-testid":"apigee-key-row",children:[n("td",{className:"key",children:[n(j,{children:[e(H,{"data-testid":"apigee-key-value",children:p?i.consumerKey:Z(i.consumerKey)}),e(b,{variant:"text",size:"small","aria-label":p?"Hide key":"Reveal key",icon:e(A,{name:p?"eye-slash":"eye",size:"14px"}),onClick:()=>_(o=>{const h=new Set(o);return h.has(i.consumerKey)?h.delete(i.consumerKey):h.add(i.consumerKey),h})}),e(b,{variant:"text",size:"small","aria-label":"Copy key",icon:e(A,{name:"copy",size:"14px"}),onClick:()=>v(i.consumerKey,`key:${i.consumerKey}`)}),r===`key:${i.consumerKey}`?e(C,{children:"Copied"}):null]}),i.consumerSecret?n(j,{children:[e(C,{children:"Secret"}),e(H,{children:p?i.consumerSecret:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}),e(b,{variant:"text",size:"small","aria-label":"Copy secret",icon:e(A,{name:"copy",size:"14px"}),onClick:()=>{var o;return v((o=i.consumerSecret)!==null&&o!==void 0?o:"",`secret:${i.consumerKey}`)}}),r===`secret:${i.consumerKey}`?e(C,{children:"Copied"}):null]}):null,n(C,{children:["Issued ",$(i.issuedAt)," \xB7 Expires"," ",i.expiresAt?$(i.expiresAt):"never"]})]}),n("td",{children:[n(j,{children:[i.apiProducts.length===0?e(C,{children:"None"}):null,i.apiProducts.map(o=>e(F,{status:o.status,label:o.status==="approved"?x(o.id):`${x(o.id)} \xB7 ${o.status}`},o.id))]}),i.apiProducts.filter(o=>{var h;return(h=o.decision)===null||h===void 0?void 0:h.note}).map(o=>{var h,N;return n(C,{as:"div","data-testid":"apigee-decision-note",children:[((h=o.decision)===null||h===void 0?void 0:h.action)==="approve"?"Approved":"Rejected"," \xB7"," ",x(o.id),": \u201C",(N=o.decision)===null||N===void 0?void 0:N.note,"\u201D"]},o.id)})]}),e("td",{children:e(F,{status:W(i)})}),e("td",{className:"actions",children:e(M,{trigger:e(b,{variant:"text",size:"small","aria-label":"Key actions",icon:e(A,{name:"ellipsis-vertical",size:"14px"}),"data-testid":"apigee-key-menu"}),alignment:"end",portalled:!0,children:e(B,{items:[{content:"Edit API products",onAction:()=>k({consumerKey:i.consumerKey,products:i.apiProducts.map(o=>o.id)}),dataAttributes:{"data-testid":"apigee-edit-key"}},{content:"Delete key",dangerous:!0,separatorLine:!0,onAction:()=>S(i.consumerKey),dataAttributes:{"data-testid":"apigee-delete-key"}}]})})})]},i.consumerKey)})})]})}),t.credentials.some(i=>W(i)==="approved")?e("div",{style:{marginTop:"var(--spacing-base)"},children:n(O,{tone:"info",children:[e("strong",{children:"Keys are picked up by Try it."})," Open an operation of an approved API product in the API reference and the key is already filled in."]})}):null]}),e(q,{open:y,onClose:()=>c(!1),onSubmit:i=>D(this,void 0,void 0,function*(){const p=yield P.updateApp(t.id,i,m);return s(),p}),products:a,teams:l,initial:t}),e(pe,{open:d!==null,onClose:()=>k(null),onSubmit:i=>D(this,void 0,void 0,function*(){const p=d?.consumerKey?yield P.updateKey(t.id,d.consumerKey,i,m):yield P.createKey(t.id,i,m);return s(),p}),products:a,initial:d?.products}),e(V,{open:f,onClose:()=>g(!1),title:"Delete application?",confirmLabel:"Delete application",danger:!0,onConfirm:()=>D(this,void 0,void 0,function*(){return yield P.deleteApp(t.id,m),w(),!0}),children:n("p",{children:[e("strong",{children:t.name})," and all of its keys stop working immediately. This cannot be undone."]})}),e(V,{open:I!==null,onClose:()=>S(null),title:"Delete key?",confirmLabel:"Delete key",danger:!0,onConfirm:()=>D(this,void 0,void 0,function*(){return I&&(yield P.deleteKey(t.id,I,m)),s(),!0}),children:e("p",{children:"Requests that send this key are rejected from now on. This cannot be undone."})})]})}export{_e as AppsView};
1
+ var T=function(t,l,r,a){function c(g){return g instanceof r?g:new r(function(d){d(g)})}return new(r||(r=Promise))(function(g,d){function h(v){try{p(a.next(v))}catch(f){d(f)}}function y(v){try{p(a.throw(v))}catch(f){d(f)}}function p(v){v.done?g(v.value):c(v.value).then(h,y)}p((a=a.apply(t,l||[])).next())})};import{Fragment as z,jsx as e,jsxs as o}from"react/jsx-runtime";import{useEffect as ce,useState as K}from"react";import{useNavigate as V}from"react-router";import{Button as b}from"@redocly/theme/components/Button/Button";import{Dropdown as ue}from"@redocly/theme/components/Dropdown/Dropdown";import{DropdownMenu as pe}from"@redocly/theme/components/Dropdown/DropdownMenu";import{Link as me}from"@redocly/theme/components/Link/Link";import{Select as G}from"@redocly/theme/components/Select/Select";import{Tag as E}from"@redocly/theme/components/Tag/Tag";import{Tooltip as he}from"@redocly/theme/components/Tooltip/Tooltip";import{useToast as ve}from"@redocly/theme/core/hooks/use-toast";import{CDNIcon as w}from"@redocly/theme/icons/CDNIcon/CDNIcon";import{maskKey as fe}from"../../contract.js";import{apigeeApi as _}from"../api.js";import{useApigee as M}from"../context.js";import{copyText as ge,errorMessage as J,formatDate as B,matches as ye,useSearchParam as Q,useSearchText as ke}from"../hooks.js";import{EmptyState as X,FilterSlot as Y,ListSkeleton as Z,LinkTableRow as we,ListTable as be,Mono as ee,Muted as P,NoMatches as Ae,Notice as j,Overview as Pe,PageBreadcrumbs as Se,PageHeader as te,ProductTag as ne,Row as L,SearchField as Ie,Section as Ce,SectionHeader as xe,SectionTitle as Te,StatusTag as Ke,Table as _e,TableWrap as ie,Toolbar as Ne}from"../Primitives.js";import{dropApp as De,ownerKey as U,putApp as F,useApps as ze,useTeams as H}from"../queries.js";import{AppDialog as re,ConfirmDialog as oe,KeyDialog as Le}from"./Dialogs.js";const Re="Register apps and manage the API keys that call the APIs through Apigee.",Oe=[{value:"",element:"All statuses"},{value:"approved",element:"Approved"},{value:"partial",element:"Partly approved"},{value:"pending",element:"Pending approval"},{value:"rejected",element:"Rejected"},{value:"revoked",element:"Revoked"},{value:"none",element:"No API products"}],W=3;function q(t,l){var r,a;return t.kind==="developer"?"Personal":(a=(r=l.find(c=>c.id===t.teamId))===null||r===void 0?void 0:r.name)!==null&&a!==void 0?a:t.teamId}function R(t,l){var r,a;return(a=(r=t.find(c=>c.id===l))===null||r===void 0?void 0:r.name)!==null&&a!==void 0?a:l}function ae(t){if(t.status==="revoked")return{color:"red",label:"Revoked",filter:"revoked"};const l=t.credentials.flatMap(c=>c.apiProducts);if(l.length===0)return{color:"grey",label:"No API products",filter:"none"};if(l.some(c=>c.status==="pending"))return{color:"orange",label:"Pending approval",filter:"pending"};const r=new Set(l.map(c=>c.id)).size,a=new Set(l.filter(c=>c.status==="approved").map(c=>c.id)).size;return a===r?{color:"green",label:"Approved",filter:"approved"}:a===0?{color:"red",label:"Rejected",filter:"rejected"}:{color:"blue",label:`${a} of ${r} approved`,filter:"partial"}}function de(t){if(t.status!=="approved")return t.status;const{apiProducts:l}=t;return l.some(r=>r.status==="pending")?"pending":l.length>0&&l.every(r=>r.status==="revoked")?"revoked":"approved"}const le={approved:0,pending:1,revoked:2};function se(t){const l=new Map;for(const r of t.credentials.flatMap(a=>a.apiProducts)){const a=l.get(r.id);(!a||le[r.status]<le[a])&&l.set(r.id,r.status)}return[...l].map(([r,a])=>({id:r,status:a}))}function rt({selection:t}){var l,r,a;const{link:c,appLink:g,title:d,meta:h}=M(),y=V(),p=ze(),{data:v=[]}=H(),[f,k]=K(null),[S,A]=ke(),[I,$]=Q("owner"),[N,O]=Q("status");ce(()=>{var n,u;const x=new URLSearchParams(window.location.search);x.has("createApp")&&(k({product:(n=x.get("apiProduct"))!==null&&n!==void 0?n:void 0,teamId:(u=x.get("team"))!==null&&u!==void 0?u:void 0}),y(c(),{replace:!0}))},[c,y]);const C=e(re,{open:f!==null,onClose:()=>k(null),onSubmit:n=>T(this,void 0,void 0,function*(){const u=yield _.createApp(n);return F(u),y(g(u)),u}),products:h.apiProducts,teams:v,initialProduct:f?.product,initialTeamId:f?.teamId});if(t){const n=t.teamId?`team:${t.teamId}`:"developer",u=(l=p.data)===null||l===void 0?void 0:l.find(x=>x.id===t.appId&&U(x.owner)===n);return o(z,{children:[e(Se,{additionalBreadcrumbs:[{label:d,link:c()},{label:(r=u?.name)!==null&&r!==void 0?r:t.appId}]}),u?e($e,{app:u}):p.data?e(j,{tone:"danger",children:"App not found"}):p.isError?e(j,{tone:"danger",children:J(p.error)}):e(Z,{label:"Loading the app\u2026",rows:2}),C]})}const D=(a=p.data)!==null&&a!==void 0?a:[],i=e(b,{variant:"primary",onClick:()=>k({}),icon:e(w,{name:"plus",size:"16px"}),"data-testid":"apigee-new-app",children:"New app"}),m=D.filter(n=>(!I||U(n.owner)===I)&&(!N||ae(n).filter===N)&&ye(S,n.name,n.description,...se(n).map(u=>R(h.apiProducts,u.id)))),s=[{value:"",element:"All owners"},{value:"developer",element:"Personal"},...v.map(n=>({value:`team:${n.id}`,element:n.name}))];return o(z,{children:[e(te,{title:d,description:Re,actions:p.data&&D.length===0?void 0:i}),p.data?D.length===0?e(X,{icon:"key",title:"Create your first app",text:"An app holds the API keys your software sends. Pick the API products it needs; the keys for approved products work right away.",action:i}):o(z,{children:[o(Ne,{children:[e(Ie,{value:S,onChange:A,placeholder:"Search apps or API products",testId:"apigee-app-search"}),v.length>0?e(Y,{children:e(G,{value:I,options:s,onChange:n=>$(String(n)),dataTestId:"apigee-owner-filter"})}):null,e(Y,{children:e(G,{value:N,options:Oe,onChange:n=>O(String(n)),dataTestId:"apigee-status-filter"})})]}),m.length===0?e(Ae,{onClear:()=>{A(""),y(c(),{replace:!0})}}):e(je,{apps:m,showOwner:v.length>0})]}):p.isError?e(j,{tone:"danger",children:J(p.error)}):e(Z,{label:"Loading your apps\u2026"}),C]})}function je({apps:t,showOwner:l}){const{appLink:r,meta:a}=M(),{data:c=[]}=H(),g=[...t].sort((d,h)=>d.name.localeCompare(h.name));return e(ie,{children:o(be,{"data-testid":"apigee-app-list",children:[e("thead",{children:o("tr",{children:[e("th",{children:"App"}),l?e("th",{children:"Owner"}):null,e("th",{children:"API products"}),e("th",{children:"Keys"}),e("th",{children:"Status"}),e("th",{className:"chevron","aria-hidden":"true"})]})}),e("tbody",{children:g.map(d=>{const h=ae(d),y=se(d);return o(we,{to:r(d),testId:"apigee-app-row",children:[o("td",{children:[e(me,{to:r(d),children:d.name}),d.description?e(P,{as:"div",style:{maxWidth:360},children:d.description}):null]}),l?e("td",{className:"meta",children:o(L,{children:[e(w,{name:d.owner.kind==="team"?"user-group":"user",size:"14px"}),q(d.owner,c)]})}):null,e("td",{children:o(L,{children:[y.length===0?e(P,{children:"None"}):null,y.slice(0,W).map(p=>e(ne,{name:R(a.apiProducts,p.id),status:p.status},p.id)),y.length>W?o(E,{color:"grey",variant:"outline",children:["+",y.length-W]}):null]})}),e("td",{className:"optional",children:d.credentials.length}),e("td",{className:"trail",children:e(E,{color:h.color,textTransform:"none",children:h.label})}),e("td",{className:"chevron",children:e(w,{name:"chevron-right",size:"14px"})})]},`${U(d.owner)}:${d.id}`)})})]})})}function $e({app:t}){const{link:l,meta:r}=M(),a=V(),c=ve(),{data:g=[]}=H(),d=r.apiProducts,h=t.owner.kind==="team"?t.owner.teamId:void 0,[y,p]=K(!1),[v,f]=K(!1),[k,S]=K(null),[A,I]=K(null),[$,N]=K(new Set),O=(i,m)=>T(this,void 0,void 0,function*(){(yield ge(i))?c.success(`${m} copied`,{duration:2e3}):c.error(`Could not copy the ${m.toLowerCase()}`)}),C=i=>F(Object.assign(Object.assign({},t),{credentials:i})),D=i=>d.find(m=>m.id===i);return o("div",{"data-testid":"apigee-app-detail",children:[e(te,{title:o(z,{children:[t.name,t.status==="revoked"?e(E,{color:"red",children:"Revoked"}):null]}),description:t.description||void 0,actions:o(z,{children:[e(b,{variant:"outlined",onClick:()=>p(!0),icon:e(w,{name:"pen",size:"16px"}),"data-testid":"apigee-edit-app",children:"Edit"}),e(he,{tip:"Delete app",placement:"bottom",children:e(b,{variant:"outlined",tone:"danger","aria-label":"Delete app",icon:e(w,{name:"trash-can",size:"16px"}),onClick:()=>f(!0),"data-testid":"apigee-delete-app"})})]})}),o(Pe,{children:[o("div",{children:[e("dt",{children:"Owner"}),o("dd",{children:[e(w,{name:t.owner.kind==="team"?"user-group":"user",size:"16px"}),t.owner.kind==="team"?`Team \xB7 ${q(t.owner,g)}`:q(t.owner,g)]})]}),o("div",{children:[e("dt",{children:"Created"}),e("dd",{children:B(t.createdAt)})]}),o("div",{className:"wide",children:[e("dt",{children:"Callback URL"}),e("dd",{children:t.callbackUrl||e(P,{children:"Not set"})})]})]}),o(Ce,{children:[o(xe,{children:[e(Te,{children:"API keys"}),e(b,{variant:"outlined",size:"small",onClick:()=>S({}),icon:e(w,{name:"plus",size:"14px"}),"data-testid":"apigee-create-key",children:"Create key"})]}),t.credentials.length===0?e(X,{icon:"key",title:"No keys yet",text:"Create a key and pick the API products it may call."}):e(ie,{children:o(_e,{"data-testid":"apigee-keys-table",children:[e("thead",{children:o("tr",{children:[e("th",{children:"Key"}),e("th",{children:"API products"}),e("th",{children:"Status"}),e("th",{className:"actions"})]})}),e("tbody",{children:t.credentials.map(i=>{const m=$.has(i.consumerKey);return o("tr",{"data-testid":"apigee-key-row",children:[o("td",{className:"key",children:[o(L,{children:[e(ee,{"data-testid":"apigee-key-value",children:m?i.consumerKey:fe(i.consumerKey)}),e(b,{variant:"text",size:"small","aria-label":m?"Hide key":"Reveal key",icon:e(w,{name:m?"eye-slash":"eye",size:"14px"}),onClick:()=>N(s=>{const n=new Set(s);return n.has(i.consumerKey)?n.delete(i.consumerKey):n.add(i.consumerKey),n})}),e(b,{variant:"text",size:"small","aria-label":"Copy key",icon:e(w,{name:"copy",size:"14px"}),onClick:()=>O(i.consumerKey,"Key")})]}),i.consumerSecret?o(L,{children:[e(P,{children:"Secret"}),e(ee,{children:m?i.consumerSecret:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}),e(b,{variant:"text",size:"small","aria-label":"Copy secret",icon:e(w,{name:"copy",size:"14px"}),onClick:()=>{var s;return O((s=i.consumerSecret)!==null&&s!==void 0?s:"","Secret")}})]}):null,o(P,{children:["Issued ",B(i.issuedAt)," \xB7 Expires"," ",i.expiresAt?B(i.expiresAt):"never"]})]}),o("td",{"data-label":"API products",children:[o(L,{children:[i.apiProducts.length===0?e(P,{children:"None"}):null,i.apiProducts.map(s=>{var n,u;return e(ne,{name:s.status==="approved"?R(d,s.id):`${R(d,s.id)} \xB7 ${s.status}`,status:s.status,to:(u=(n=D(s.id))===null||n===void 0?void 0:n.api)===null||u===void 0?void 0:u.slug},s.id)})]}),i.apiProducts.filter(s=>{var n;return(n=s.decision)===null||n===void 0?void 0:n.note}).map(s=>{var n,u;return o(P,{as:"div","data-testid":"apigee-decision-note",children:[((n=s.decision)===null||n===void 0?void 0:n.action)==="approve"?"Approved":"Rejected"," \xB7"," ",R(d,s.id),": \u201C",(u=s.decision)===null||u===void 0?void 0:u.note,"\u201D"]},s.id)})]}),e("td",{"data-label":"Status",children:e(Ke,{status:de(i)})}),e("td",{className:"actions menu",children:e(ue,{trigger:e(b,{variant:"text",size:"small","aria-label":"Key actions",icon:e(w,{name:"ellipsis-vertical",size:"14px"}),"data-testid":"apigee-key-menu"}),alignment:"end",portalled:!0,children:e(pe,{items:[{content:"Edit API products",onAction:()=>S({consumerKey:i.consumerKey,products:i.apiProducts.map(s=>s.id)}),dataAttributes:{"data-testid":"apigee-edit-key"}},{content:"Delete key",dangerous:!0,separatorLine:!0,onAction:()=>I(i.consumerKey),dataAttributes:{"data-testid":"apigee-delete-key"}}]})})})]},i.consumerKey)})})]})}),t.credentials.some(i=>de(i)==="approved")?e("div",{style:{marginTop:"var(--spacing-base)"},children:o(j,{tone:"info",children:[e("strong",{children:"Keys are picked up by Try it."})," Open an operation of an approved API product in the API reference and the key is already filled in."]})}):null]}),e(re,{open:y,onClose:()=>p(!1),onSubmit:i=>T(this,void 0,void 0,function*(){const m=yield _.updateApp(t.id,i,h);return F(m),m}),products:d,teams:g,initial:t}),e(Le,{open:k!==null,onClose:()=>S(null),onSubmit:i=>T(this,void 0,void 0,function*(){const m=k?.consumerKey;if(m){const n=yield _.updateKey(t.id,m,i,h);return C(t.credentials.map(u=>u.consumerKey===m?n:u)),n}const s=yield _.createKey(t.id,i,h);return C([...t.credentials,s]),s}),products:d,initial:k?.products}),e(oe,{open:v,onClose:()=>f(!1),title:"Delete app?",confirmLabel:"Delete app",danger:!0,onConfirm:()=>T(this,void 0,void 0,function*(){return yield _.deleteApp(t.id,h),a(l()),De(t),c.success(`${t.name} deleted`),!0}),children:o("p",{children:[e("strong",{children:t.name})," and all of its keys stop working immediately. This cannot be undone."]})}),e(oe,{open:A!==null,onClose:()=>I(null),title:"Delete key?",confirmLabel:"Delete key",danger:!0,onConfirm:()=>T(this,void 0,void 0,function*(){return A&&(yield _.deleteKey(t.id,A,h),C(t.credentials.filter(i=>i.consumerKey!==A))),!0}),children:e("p",{children:"Requests that send this key are rejected from now on. This cannot be undone."})})]})}export{Re as APPS_DESCRIPTION,je as AppsTable,rt as AppsView};
@@ -1,5 +1,7 @@
1
1
  import { type ReactElement, type ReactNode } from 'react';
2
- import type { ApiProduct, App, AppInput, KeyInput, Team, TeamInput } from '../../contract.js';
2
+ import type { SelectOption } from '@redocly/theme/core/types';
3
+ import type { ApiProduct, App, AppInput, KeyInput, Team, TeamInput, TeamMemberInput, TeamRole } from '../../contract.js';
4
+ export declare const ROLE_OPTIONS: SelectOption<TeamRole>[];
3
5
  type AppDialogProps = {
4
6
  onClose: () => void;
5
7
  onSubmit: (input: AppInput) => Promise<unknown>;
@@ -31,6 +33,13 @@ type TeamDialogProps = {
31
33
  export declare function TeamDialog({ open, ...props }: TeamDialogProps & {
32
34
  open: boolean;
33
35
  }): ReactElement | null;
36
+ type MemberDialogProps = {
37
+ onClose: () => void;
38
+ onSubmit: (input: TeamMemberInput) => Promise<unknown>;
39
+ };
40
+ export declare function MemberDialog({ open, ...props }: MemberDialogProps & {
41
+ open: boolean;
42
+ }): ReactElement | null;
34
43
  type ConfirmDialogProps = {
35
44
  onClose: () => void;
36
45
  onConfirm: (note?: string) => Promise<unknown>;
@@ -1 +1,9 @@
1
- var j=function(n,a,r,t){function o(d){return d instanceof r?d:new r(function(c){c(d)})}return new(r||(r=Promise))(function(d,c){function h(i){try{s(t.next(i))}catch(u){c(u)}}function g(i){try{s(t.throw(i))}catch(u){c(u)}}function s(i){i.done?d(i.value):o(i.value).then(h,g)}s((t=t.apply(n,a||[])).next())})},x=function(n,a){var r={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&a.indexOf(t)<0&&(r[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,t=Object.getOwnPropertySymbols(n);o<t.length;o++)a.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(n,t[o])&&(r[t[o]]=n[t[o]]);return r};import{Fragment as N,jsx as e,jsxs as l}from"react/jsx-runtime";import{useState as v}from"react";import{Button as y}from"@redocly/theme/components/Button/Button";import{Tag as R}from"@redocly/theme/components/Tag/Tag";import{useMutation as D}from"../hooks.js";import{CheckItem as z,CheckItemTitle as $,CheckList as G,Dialog as I,Field as f,FieldLabel as b,Input as P,Muted as k,NativeSelect as H,Notice as S,Textarea as O}from"../Primitives.js";function U({products:n,selected:a,onChange:r}){return n.length===0?e(k,{children:"No API products are available to you yet."}):e(G,{"data-testid":"apigee-product-picker",children:n.map(t=>{const o=a.includes(t.id);return l(z,{$checked:o,children:[e("input",{type:"checkbox",checked:o,onChange:d=>r(d.target.checked?[...a,t.id]:a.filter(c=>c!==t.id))}),l("span",{children:[l($,{children:[t.name,e(R,{color:t.approvalType==="manual"?"orange":"grey",children:t.approvalType==="manual"?"requires approval":"auto-approved"})]}),t.description?e(k,{children:t.description}):null]})]},t.id)})})}function L(n,a){return n.some(r=>a.includes(r.id)&&r.approvalType==="manual")}function oe(n){var{open:a}=n,r=x(n,["open"]);return a?e(J,Object.assign({},r)):null}function J({onClose:n,onSubmit:a,products:r,teams:t,initial:o,initialProduct:d,initialTeamId:c}){var h,g,s;const i=!!o,[u,m]=v((h=o?.name)!==null&&h!==void 0?h:""),[C,W]=v((g=o?.description)!==null&&g!==void 0?g:""),[A,q]=v((s=o?.callbackUrl)!==null&&s!==void 0?s:""),[T,B]=v(o?.owner.kind==="team"?o.owner.teamId:c??""),[_,E]=v(d?[d]:[]),[F,K]=v(""),w=D(),M=()=>j(this,void 0,void 0,function*(){(yield w.run(()=>a(Object.assign(Object.assign({name:u.trim(),description:C.trim(),callbackUrl:A.trim(),apiProducts:_},F.trim()?{note:F.trim()}:{}),T?{teamId:T}:{}))))!==void 0&&n()});return l(I,{open:!0,onClose:n,wide:!0,title:i?"Edit application":"New application",testId:"apigee-app-dialog",footer:l(N,{children:[e(y,{variant:"outlined",onClick:n,disabled:w.pending,children:"Cancel"}),e(y,{variant:"primary",onClick:M,disabled:w.pending||!u.trim(),"data-testid":"apigee-app-submit",children:i?"Save":"Create application"})]}),children:[w.error?e(S,{tone:"danger",children:w.error}):null,l(f,{children:[e(b,{children:"Name"}),e(P,{value:u,onChange:p=>m(p.target.value),placeholder:"Ticketing kiosk",autoFocus:!0,"data-testid":"apigee-app-name"}),i?null:e(k,{children:"Letters, digits, spaces, dots, dashes and underscores. The name cannot change later."})]}),!i&&t.length>0?l(f,{children:[e(b,{children:"Owner"}),l(H,{value:T,onChange:p=>B(p.target.value),"data-testid":"apigee-app-owner",children:[e("option",{value:"",children:"Personal"}),t.map(p=>l("option",{value:p.id,children:["Team \xB7 ",p.name]},p.id))]}),e(k,{children:"Team apps are shared with every member of the team."})]}):null,i?null:l(f,{as:"div",children:[e(b,{children:"API products"}),e(U,{products:r,selected:_,onChange:E})]}),!i&&L(r,_)?l(f,{children:[e(b,{children:"Why do you need access?"}),e(O,{value:F,onChange:p=>K(p.target.value),placeholder:"Sent to the reviewers of the request","data-testid":"apigee-app-note"})]}):null,l(f,{children:[e(b,{children:"Description"}),e(O,{value:C,onChange:p=>W(p.target.value),placeholder:"What does this application do?"})]}),l(f,{children:[e(b,{children:"Callback URL"}),e(P,{value:A,onChange:p=>q(p.target.value),placeholder:"https://example.com/oauth/callback"}),e(k,{children:"Where OAuth 2.0 authorization codes are sent. Separate several URLs with commas."})]})]})}function ae(n){var{open:a}=n,r=x(n,["open"]);return a?e(Q,Object.assign({},r)):null}function Q({onClose:n,onSubmit:a,products:r,initial:t}){const o=t!==void 0,[d,c]=v(t??[]),[h,g]=v(""),s=D(),i=d.filter(m=>!(t??[]).includes(m)),u=()=>j(this,void 0,void 0,function*(){(yield s.run(()=>a(Object.assign({apiProducts:d},h.trim()?{note:h.trim()}:{}))))!==void 0&&n()});return l(I,{open:!0,onClose:n,wide:!0,title:o?"Edit API products":"Create key",testId:"apigee-key-dialog",footer:l(N,{children:[e(y,{variant:"outlined",onClick:n,disabled:s.pending,children:"Cancel"}),e(y,{variant:"primary",onClick:u,disabled:s.pending,"data-testid":"apigee-key-submit",children:o?"Save":"Create key"})]}),children:[s.error?e(S,{tone:"danger",children:s.error}):null,l(f,{as:"div",children:[e(b,{children:"API products"}),e(U,{products:r,selected:d,onChange:c})]}),L(r,i)?l(f,{children:[e(b,{children:"Why do you need access?"}),e(O,{value:h,onChange:m=>g(m.target.value),placeholder:"Sent to the reviewers of the request"})]}):null]})}function ie(n){var{open:a}=n,r=x(n,["open"]);return a?e(V,Object.assign({},r)):null}function V({onClose:n,onSubmit:a,initial:r}){var t,o;const d=!!r,[c,h]=v((t=r?.name)!==null&&t!==void 0?t:""),[g,s]=v((o=r?.description)!==null&&o!==void 0?o:""),i=D(),u=()=>j(this,void 0,void 0,function*(){(yield i.run(()=>a({name:c.trim(),description:g.trim()})))!==void 0&&n()});return l(I,{open:!0,onClose:n,title:d?"Edit team":"New team",testId:"apigee-team-dialog",footer:l(N,{children:[e(y,{variant:"outlined",onClick:n,disabled:i.pending,children:"Cancel"}),e(y,{variant:"primary",onClick:u,disabled:i.pending||!c.trim(),"data-testid":"apigee-team-submit",children:d?"Save":"Create team"})]}),children:[i.error?e(S,{tone:"danger",children:i.error}):null,l(f,{children:[e(b,{children:"Name"}),e(P,{value:c,onChange:m=>h(m.target.value),placeholder:"Platform squad",autoFocus:!0,"data-testid":"apigee-team-name"}),d?null:e(k,{children:"The identifier of the team in Apigee comes from the name and cannot change later."})]}),l(f,{children:[e(b,{children:"Description"}),e(O,{value:g,onChange:m=>s(m.target.value),placeholder:"What does this team build?"})]})]})}function le(n){var{open:a}=n,r=x(n,["open"]);return a?e(X,Object.assign({},r)):null}function X({onClose:n,onConfirm:a,title:r,children:t,confirmLabel:o,danger:d,withNote:c,noteLabel:h="Note",notePlaceholder:g="Optional"}){const[s,i]=v(""),u=D(),m=()=>j(this,void 0,void 0,function*(){(yield u.run(()=>a(s.trim()||void 0)))!==void 0&&n()});return l(I,{open:!0,onClose:n,title:r,testId:"apigee-confirm-dialog",footer:l(N,{children:[e(y,{variant:"outlined",onClick:n,disabled:u.pending,children:"Cancel"}),e(y,{variant:"primary",tone:d?"danger":"default",onClick:m,disabled:u.pending,"data-testid":"apigee-confirm",children:o})]}),children:[u.error?e(S,{tone:"danger",children:u.error}):null,t,c?l(f,{children:[e(b,{children:h}),e(O,{value:s,onChange:C=>i(C.target.value),placeholder:g,"data-testid":"apigee-confirm-note"})]}):null]})}export{oe as AppDialog,le as ConfirmDialog,ae as KeyDialog,ie as TeamDialog};
1
+ var O=function(t,o,n,r){function a(s){return s instanceof n?s:new n(function(d){d(s)})}return new(n||(n=Promise))(function(s,d){function i(c){try{p(r.next(c))}catch(h){d(h)}}function u(c){try{p(r.throw(c))}catch(h){d(h)}}function p(c){c.done?s(c.value):a(c.value).then(i,u)}p((r=r.apply(t,o||[])).next())})},x=function(t,o){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&o.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(t);a<r.length;a++)o.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(t,r[a])&&(n[r[a]]=t[r[a]]);return n};import{Fragment as I,jsx as e,jsxs as l}from"react/jsx-runtime";import{useState as m}from"react";import q from"styled-components";import{Button as b}from"@redocly/theme/components/Button/Button";import{Select as E}from"@redocly/theme/components/Select/Select";import{Tag as z}from"@redocly/theme/components/Tag/Tag";import{useMutation as D}from"../hooks.js";import{CheckItem as Q,CheckItemTitle as G,CheckList as J,Dialog as T,Field as f,FieldLabel as C,Input as j,Muted as y,Notice as P,RequiredLabel as F,Textarea as S}from"../Primitives.js";const V=[{value:"member",element:"Member"},{value:"owner",element:"Owner"}],X=8,Y=q.div`
2
+ display: flex;
3
+ align-items: baseline;
4
+ justify-content: space-between;
5
+ gap: var(--spacing-sm);
6
+ `,Z=q(J)`
7
+ max-height: 320px;
8
+ overflow-y: auto;
9
+ `;function R({products:t,selected:o,onChange:n}){const[r,a]=m(""),s=r.trim().toLowerCase(),d=t.filter(i=>`${i.name} ${i.description}`.toLowerCase().includes(s));return l(f,{as:"div",children:[l(Y,{children:[e(C,{children:"API products"}),t.length>0?l(y,{"data-testid":"apigee-product-count",children:[o.length," selected"]}):null]}),t.length===0?e(y,{children:"No API products are available to you yet."}):null,t.length>X?e(j,{type:"search",value:r,onChange:i=>a(i.target.value),placeholder:"Search API products","aria-label":"Search API products","data-testid":"apigee-product-search"}):null,t.length>0&&d.length===0?l(y,{children:["No API products match \u201C",r.trim(),"\u201D."]}):null,d.length>0?e(Z,{"data-testid":"apigee-product-picker",children:d.map(i=>{const u=o.includes(i.id);return l(Q,{$checked:u,children:[e("input",{type:"checkbox",checked:u,onChange:p=>n(p.target.checked?[...o,i.id]:o.filter(c=>c!==i.id))}),l("span",{children:[l(G,{children:[i.name,e(z,{color:i.approvalType==="manual"?"orange":"grey",children:i.approvalType==="manual"?"requires approval":"auto-approved"})]}),i.description?e(y,{children:i.description}):null]})]},i.id)})}):null]})}function U(t,o){return t.some(n=>o.includes(n.id)&&n.approvalType==="manual")}function he(t){var{open:o}=t,n=x(t,["open"]);return o?e(ee,Object.assign({},n)):null}function ee({onClose:t,onSubmit:o,products:n,teams:r,initial:a,initialProduct:s,initialTeamId:d}){var i,u,p;const c=!!a,[h,g]=m((i=a?.name)!==null&&i!==void 0?i:""),[k,M]=m((u=a?.description)!==null&&u!==void 0?u:""),[L,W]=m((p=a?.callbackUrl)!==null&&p!==void 0?p:""),[N,H]=m(a?.owner.kind==="team"?a.owner.teamId:d??""),[_,$]=m(s?[s]:[]),[A,B]=m(""),w=D(),K=()=>O(this,void 0,void 0,function*(){(yield w.run(()=>o(Object.assign(Object.assign({name:h.trim(),description:k.trim(),callbackUrl:L.trim(),apiProducts:_},A.trim()?{note:A.trim()}:{}),N?{teamId:N}:{}))))!==void 0&&t()});return l(T,{open:!0,onClose:t,wide:!0,title:c?"Edit app":"New app",testId:"apigee-app-dialog",footer:l(I,{children:[e(b,{variant:"outlined",onClick:t,disabled:w.pending,children:"Cancel"}),e(b,{variant:"primary",onClick:K,disabled:w.pending||!h.trim(),"data-testid":"apigee-app-submit",children:c?"Save":"Create app"})]}),children:[w.error?e(P,{tone:"danger",children:w.error}):null,l(f,{children:[e(F,{children:"Name"}),e(j,{value:h,onChange:v=>g(v.target.value),placeholder:"Ticketing kiosk",required:!0,autoFocus:!0,"data-testid":"apigee-app-name"}),c?null:e(y,{children:"Letters, digits, spaces, dots, dashes and underscores. The name cannot change later."})]}),!c&&r.length>0?l(f,{as:"div",children:[e(C,{children:"Owner"}),e(E,{value:N,options:[{value:"",element:"Personal"},...r.map(v=>({value:v.id,element:`Team \xB7 ${v.name}`}))],onChange:v=>H(v),dataTestId:"apigee-app-owner"}),e(y,{children:"Team apps are shared with every member of the team."})]}):null,c?null:e(R,{products:n,selected:_,onChange:$}),!c&&U(n,_)?l(f,{children:[e(C,{children:"Why do you need access?"}),e(S,{value:A,onChange:v=>B(v.target.value),placeholder:"Sent to the reviewers of the request","data-testid":"apigee-app-note"})]}):null,l(f,{children:[e(C,{children:"Description"}),e(S,{value:k,onChange:v=>M(v.target.value),placeholder:"What does this app do?"})]}),l(f,{children:[e(C,{children:"Callback URL"}),e(j,{value:L,onChange:v=>W(v.target.value),placeholder:"https://example.com/oauth/callback"}),e(y,{children:"Where OAuth 2.0 authorization codes are sent. Separate several URLs with commas."})]})]})}function me(t){var{open:o}=t,n=x(t,["open"]);return o?e(te,Object.assign({},n)):null}function te({onClose:t,onSubmit:o,products:n,initial:r}){const a=r!==void 0,[s,d]=m(r??[]),[i,u]=m(""),p=D(),c=s.filter(g=>!(r??[]).includes(g)),h=()=>O(this,void 0,void 0,function*(){(yield p.run(()=>o(Object.assign({apiProducts:s},i.trim()?{note:i.trim()}:{}))))!==void 0&&t()});return l(T,{open:!0,onClose:t,wide:!0,title:a?"Edit API products":"Create key",testId:"apigee-key-dialog",footer:l(I,{children:[e(b,{variant:"outlined",onClick:t,disabled:p.pending,children:"Cancel"}),e(b,{variant:"primary",onClick:h,disabled:p.pending,"data-testid":"apigee-key-submit",children:a?"Save":"Create key"})]}),children:[p.error?e(P,{tone:"danger",children:p.error}):null,e(R,{products:n,selected:s,onChange:d}),U(n,c)?l(f,{children:[e(C,{children:"Why do you need access?"}),e(S,{value:i,onChange:g=>u(g.target.value),placeholder:"Sent to the reviewers of the request"})]}):null]})}function ge(t){var{open:o}=t,n=x(t,["open"]);return o?e(ne,Object.assign({},n)):null}function ne({onClose:t,onSubmit:o,initial:n}){var r,a;const s=!!n,[d,i]=m((r=n?.name)!==null&&r!==void 0?r:""),[u,p]=m((a=n?.description)!==null&&a!==void 0?a:""),c=D(),h=()=>O(this,void 0,void 0,function*(){(yield c.run(()=>o({name:d.trim(),description:u.trim()})))!==void 0&&t()});return l(T,{open:!0,onClose:t,title:s?"Edit team":"New team",testId:"apigee-team-dialog",footer:l(I,{children:[e(b,{variant:"outlined",onClick:t,disabled:c.pending,children:"Cancel"}),e(b,{variant:"primary",onClick:h,disabled:c.pending||!d.trim(),"data-testid":"apigee-team-submit",children:s?"Save":"Create team"})]}),children:[c.error?e(P,{tone:"danger",children:c.error}):null,l(f,{children:[e(F,{children:"Name"}),e(j,{value:d,onChange:g=>i(g.target.value),placeholder:"Platform squad",required:!0,autoFocus:!0,"data-testid":"apigee-team-name"}),s?null:e(y,{children:"The identifier of the team in Apigee comes from the name and cannot change later."})]}),l(f,{children:[e(C,{children:"Description"}),e(S,{value:u,onChange:g=>p(g.target.value),placeholder:"What does this team build?"})]})]})}function ve(t){var{open:o}=t,n=x(t,["open"]);return o?e(re,Object.assign({},n)):null}function re({onClose:t,onSubmit:o}){const[n,r]=m(""),[a,s]=m("member"),d=D(),i=()=>O(this,void 0,void 0,function*(){(yield d.run(()=>o({email:n.trim(),role:a})))!==void 0&&t()});return l(T,{open:!0,onClose:t,title:"Add member",testId:"apigee-member-dialog",footer:l(I,{children:[e(b,{variant:"outlined",onClick:t,disabled:d.pending,children:"Cancel"}),e(b,{variant:"primary",onClick:i,disabled:d.pending||!n.trim(),"data-testid":"apigee-member-submit",children:"Add member"})]}),children:[d.error?e(P,{tone:"danger",children:d.error}):null,l(f,{children:[e(F,{children:"Email"}),e(j,{type:"email",value:n,onChange:u=>r(u.target.value),placeholder:"colleague@example.com",required:!0,autoFocus:!0,"data-testid":"apigee-member-email"}),e(y,{children:"The member signs in with the portal account that has this email."})]}),l(f,{as:"div",children:[e(C,{children:"Role"}),e(E,{value:a,options:V,onChange:u=>s(u),dataTestId:"apigee-member-role-select"}),e(y,{children:"Owners can add and remove members and delete the team."})]})]})}function fe(t){var{open:o}=t,n=x(t,["open"]);return o?e(ae,Object.assign({},n)):null}function ae({onClose:t,onConfirm:o,title:n,children:r,confirmLabel:a,danger:s,withNote:d,noteLabel:i="Note",notePlaceholder:u="Optional"}){const[p,c]=m(""),h=D(),g=()=>O(this,void 0,void 0,function*(){(yield h.run(()=>o(p.trim()||void 0)))!==void 0&&t()});return l(T,{open:!0,onClose:t,title:n,testId:"apigee-confirm-dialog",footer:l(I,{children:[e(b,{variant:"outlined",onClick:t,disabled:h.pending,children:"Cancel"}),e(b,{variant:"primary",tone:s?"danger":"default",onClick:g,disabled:h.pending,"data-testid":"apigee-confirm",children:a})]}),children:[h.error?e(P,{tone:"danger",children:h.error}):null,r,d?l(f,{children:[e(C,{children:i}),e(S,{value:p,onChange:k=>c(k.target.value),placeholder:u,"data-testid":"apigee-confirm-note"})]}):null]})}export{he as AppDialog,fe as ConfirmDialog,me as KeyDialog,ve as MemberDialog,V as ROLE_OPTIONS,ge as TeamDialog};
@@ -1,10 +1,8 @@
1
1
  import type { ReactElement } from 'react';
2
- import type { Team } from '../../contract.js';
3
- export declare function TeamsView({ teams, onTeamsChanged, }: {
4
- teams: Team[];
5
- onTeamsChanged: () => void;
6
- }): ReactElement;
7
- export declare function TeamDetailView({ teamId, onTeamsChanged, }: {
2
+ export type TeamTab = 'apps' | 'members';
3
+ export declare const TEAMS_DESCRIPTION = "Share apps and keys with colleagues. A team is an Apigee app group; its members manage the team's apps together.";
4
+ export declare function TeamsView(): ReactElement;
5
+ export declare function TeamDetailView({ teamId, tab }: {
8
6
  teamId: string;
9
- onTeamsChanged: () => void;
7
+ tab: TeamTab;
10
8
  }): ReactElement;
@@ -1 +1 @@
1
- var y=function(h,u,d,c){function p(r){return r instanceof d?r:new d(function(s){s(r)})}return new(d||(d=Promise))(function(r,s){function l(m){try{g(c.next(m))}catch(x){s(x)}}function n(m){try{g(c.throw(m))}catch(x){s(x)}}function g(m){m.done?r(m.value):p(m.value).then(l,n)}g((c=c.apply(h,u||[])).next())})};import{Fragment as R,jsx as e,jsxs as i}from"react/jsx-runtime";import{useState as w}from"react";import{useNavigate as U}from"react-router";import{Button as b}from"@redocly/theme/components/Button/Button";import{Dropdown as ne}from"@redocly/theme/components/Dropdown/Dropdown";import{DropdownMenu as ae}from"@redocly/theme/components/Dropdown/DropdownMenu";import{Link as L}from"@redocly/theme/components/Link/Link";import{Tag as S}from"@redocly/theme/components/Tag/Tag";import{CDNIcon as M}from"@redocly/theme/icons/CDNIcon/CDNIcon";import{apigeeApi as v}from"../api.js";import{useApigee as Y}from"../context.js";import{formatDate as B,useAsync as H,useMutation as re}from"../hooks.js";import{Breadcrumb as le,EmptyState as P,Field as V,FieldLabel as K,Input as oe,Loading as W,Muted as N,NativeSelect as q,Notice as _,PageHeader as G,Row as I,Section as J,SectionHeader as de,SectionTitle as Q,StatusTag as ce,Table as $,TableWrap as z}from"../Primitives.js";import{ConfirmDialog as X,TeamDialog as Z}from"./Dialogs.js";function Ae({teams:h,onTeamsChanged:u}){const{link:d}=Y(),c=U(),[p,r]=w(!1),s=e(Z,{open:p,onClose:()=>r(!1),onSubmit:n=>y(this,void 0,void 0,function*(){const g=yield v.createTeam(n);return u(),c(d(`/teams/${encodeURIComponent(g.id)}`)),g})}),l=e(b,{variant:"primary",onClick:()=>r(!0),icon:e(M,{name:"plus",size:"16px"}),"data-testid":"apigee-new-team",children:"New team"});return i(R,{children:[e(G,{title:"Teams",description:"Share apps and keys with colleagues. A team is an Apigee app group; its members manage the team's apps together.",actions:h.length>0?l:void 0}),h.length===0?e(P,{icon:"user-group",title:"You are not in a team yet",text:"Create a team to share API keys with your colleagues, or ask a team owner to add your email.",action:l}):e(z,{children:i($,{"data-testid":"apigee-teams-table",children:[e("thead",{children:i("tr",{children:[e("th",{children:"Team"}),e("th",{children:"Members"}),e("th",{children:"Your role"}),e("th",{children:"Created"})]})}),e("tbody",{children:h.map(n=>i("tr",{children:[i("td",{children:[e(L,{to:d(`/teams/${encodeURIComponent(n.id)}`),children:n.name}),n.description?i(R,{children:[e("br",{}),e(N,{children:n.description})]}):null]}),e("td",{children:n.members.length}),e("td",{children:n.myRole?e(S,{color:n.myRole==="owner"?"blue":"grey",children:n.myRole}):null}),e("td",{children:B(n.createdAt)})]},n.id))})]})}),s]})}function Re({teamId:h,onTeamsChanged:u}){var d,c;const{link:p,meta:r}=Y(),s=U(),l=H(()=>v.getTeam(h),`team:${h}`),n=H(()=>v.listApps(),`team-apps:${h}`),[g,m]=w(!1),[x,j]=w(!1),[f,T]=w(null),[D,E]=w(""),[F,ee]=w("member"),C=re();if(l.loading&&!l.data)return e(W,{children:"Loading the team\u2026"});if(l.error||!l.data)return e(_,{tone:"danger",children:(d=l.error)!==null&&d!==void 0?d:"Team not found"});const o=l.data,k=o.myRole==="owner",O=((c=n.data)!==null&&c!==void 0?c:[]).filter(t=>t.owner.kind==="team"&&t.owner.teamId===o.id),te=()=>y(this,void 0,void 0,function*(){const t=yield C.run(()=>v.addMember(o.id,{email:D.trim(),role:F}));t&&(l.setData(t),E(""),u())}),ie=(t,a)=>y(this,void 0,void 0,function*(){const A=yield C.run(()=>v.setMemberRole(o.id,t,a));A&&l.setData(A)});return i("div",{"data-testid":"apigee-team-detail",children:[i(le,{children:[e(L,{to:p("/teams"),children:"Teams"}),e("span",{children:"/"}),e("span",{children:o.name})]}),e(G,{title:o.name,description:o.description||"Shared apps and keys for the team.",actions:k?i(R,{children:[e(b,{variant:"outlined",onClick:()=>m(!0),icon:e(M,{name:"pen",size:"16px"}),children:"Edit team"}),e(b,{variant:"primary",onClick:()=>s(p("",{createApp:"",team:o.id})),icon:e(M,{name:"plus",size:"16px"}),"data-testid":"apigee-new-team-app",children:"New team app"}),e(ne,{trigger:e(b,{variant:"text","aria-label":"More",icon:e(M,{name:"ellipsis-vertical",size:"16px"})}),alignment:"end",children:e(ae,{items:[{content:"Delete team",dangerous:!0,onAction:()=>j(!0),dataAttributes:{"data-testid":"apigee-delete-team"}}]})})]}):e(b,{variant:"outlined",tone:"danger",onClick:()=>T(r.viewer.email),children:"Leave team"})}),C.error?e(_,{tone:"danger",children:C.error}):null,i(J,{children:[e(Q,{children:"Members"}),e(z,{children:i($,{"data-testid":"apigee-members-table",children:[e("thead",{children:i("tr",{children:[e("th",{children:"Member"}),e("th",{children:"Role"}),e("th",{children:"Added"}),e("th",{className:"actions"})]})}),e("tbody",{children:o.members.map(t=>{const a=t.email===r.viewer.email;return i("tr",{"data-testid":"apigee-member-row",children:[e("td",{children:i(I,{children:[t.email,a?e(S,{color:"grey",children:"you"}):null]})}),e("td",{children:k?i(q,{value:t.role,onChange:A=>ie(t.email,A.target.value),style:{width:"auto"},"aria-label":`Role of ${t.email}`,children:[e("option",{value:"member",children:"Member"}),e("option",{value:"owner",children:"Owner"})]}):e(S,{color:t.role==="owner"?"blue":"grey",children:t.role})}),e("td",{children:B(t.addedAt)}),e("td",{className:"actions",children:k||a?e(b,{variant:"text",size:"small",tone:"danger",onClick:()=>T(t.email),"data-testid":"apigee-remove-member",children:a?"Leave":"Remove"}):null})]},t.email)})})]})}),k?i(I,{style:{alignItems:"flex-end",marginTop:"var(--spacing-base)"},"data-testid":"apigee-add-member-form",children:[i(V,{style:{flex:"1 1 260px"},children:[e(K,{children:"Add a member"}),e(oe,{type:"email",value:D,onChange:t=>E(t.target.value),placeholder:"colleague@example.com","data-testid":"apigee-member-email"})]}),i(V,{style:{width:140},children:[e(K,{children:"Role"}),i(q,{value:F,onChange:t=>ee(t.target.value),children:[e("option",{value:"member",children:"Member"}),e("option",{value:"owner",children:"Owner"})]})]}),e(b,{variant:"outlined",onClick:te,disabled:C.pending||!D.trim(),"data-testid":"apigee-add-member",children:"Add"})]}):null,e(N,{as:"p",style:{marginTop:"var(--spacing-xs)"},children:"Members sign in with the portal account that matches their email. Owners can add and remove members and delete the team."})]}),i(J,{children:[e(de,{children:e(Q,{children:"Team apps"})}),n.loading&&!n.data?e(W,{children:"Loading apps\u2026"}):n.error?e(_,{tone:"danger",children:n.error}):O.length===0?e(P,{icon:"key",title:"No team apps yet",text:"Create an app for this team so every member can use its keys."}):e(z,{children:i($,{"data-testid":"apigee-team-apps-table",children:[e("thead",{children:i("tr",{children:[e("th",{children:"App"}),e("th",{children:"API products"}),e("th",{children:"Keys"})]})}),e("tbody",{children:O.map(t=>i("tr",{children:[i("td",{children:[e(L,{to:p(`/${encodeURIComponent(t.id)}`,{team:o.id}),children:t.name}),t.description?i(R,{children:[e("br",{}),e(N,{children:t.description})]}):null]}),e("td",{children:e(I,{children:[...new Map(t.credentials.flatMap(a=>a.apiProducts).map(a=>[a.id,a])).values()].map(a=>e(ce,{status:a.status,label:a.id},a.id))})}),e("td",{children:t.credentials.length})]},t.id))})]})})]}),e(Z,{open:g,onClose:()=>m(!1),initial:o,onSubmit:t=>y(this,void 0,void 0,function*(){const a=yield v.updateTeam(o.id,t);return l.setData(a),u(),a})}),e(X,{open:x,onClose:()=>j(!1),title:"Delete team?",confirmLabel:"Delete team",danger:!0,onConfirm:()=>y(this,void 0,void 0,function*(){return yield v.deleteTeam(o.id),u(),s(p("/teams")),!0}),children:i("p",{children:[e("strong",{children:o.name}),", its apps and all of their keys are removed from Apigee. This cannot be undone."]})}),e(X,{open:f!==null,onClose:()=>T(null),title:f===r.viewer.email?"Leave team?":"Remove member?",confirmLabel:f===r.viewer.email?"Leave team":"Remove member",danger:!0,onConfirm:()=>y(this,void 0,void 0,function*(){if(!f)return!0;const t=yield v.removeMember(o.id,f);return f===r.viewer.email?(u(),s(p("/teams"))):l.setData(t),!0}),children:e("p",{children:f===r.viewer.email?"You lose access to the team apps and their keys.":`${f} loses access to the team apps and their keys.`})})]})}export{Re as TeamDetailView,Ae as TeamsView};
1
+ var A=function(s,d,m,l){function f(r){return r instanceof m?r:new m(function(i){i(r)})}return new(m||(m=Promise))(function(r,i){function g(h){try{p(l.next(h))}catch(n){i(n)}}function c(h){try{p(l.throw(h))}catch(n){i(n)}}function p(h){h.done?r(h.value):f(h.value).then(g,c)}p((l=l.apply(s,d||[])).next())})};import{Fragment as C,jsx as e,jsxs as o}from"react/jsx-runtime";import{useState as R}from"react";import{useNavigate as _}from"react-router";import{Button as w}from"@redocly/theme/components/Button/Button";import{Dropdown as U}from"@redocly/theme/components/Dropdown/Dropdown";import{DropdownMenu as V}from"@redocly/theme/components/Dropdown/DropdownMenu";import{Link as oe}from"@redocly/theme/components/Link/Link";import{Select as le}from"@redocly/theme/components/Select/Select";import{Tag as W}from"@redocly/theme/components/Tag/Tag";import{Tooltip as se}from"@redocly/theme/components/Tooltip/Tooltip";import{useToast as de}from"@redocly/theme/core/hooks/use-toast";import{CDNIcon as y}from"@redocly/theme/icons/CDNIcon/CDNIcon";import{apigeeApi as x}from"../api.js";import{useApigee as M}from"../context.js";import{errorMessage as me,formatDate as ce,matches as I,useSearchParam as pe,useSearchText as D}from"../hooks.js";import{EmptyState as O,FilterSlot as he,LinkTableRow as ue,ListSkeleton as z,ListTable as H,Muted as q,NoMatches as E,PageBreadcrumbs as ge,PageHeader as G,Row as ve,SearchField as $,TableWrap as J,Tabs as fe,Toolbar as P}from"../Primitives.js";import{changeMemberRole as be,dropTeam as K,putTeam as L,useApps as Q,useTeams as X}from"../queries.js";import{AppsTable as we}from"./AppsView.js";import{ConfirmDialog as Z,MemberDialog as ye,ROLE_OPTIONS as ee,TeamDialog as te}from"./Dialogs.js";const Te="Share apps and keys with colleagues. A team is an Apigee app group; its members manage the team's apps together.",Ce=[{value:"",element:"All roles"},{value:"owner",element:"Owners"},{value:"member",element:"Members"}];function F({role:s}){return e(W,{color:s==="owner"?"blue":"grey",children:s})}function Ve(){var s;const{link:d}=M(),m=_(),l=X(),{data:f=[]}=Q(),[r,i]=R(!1),[g,c]=D(),p=t=>d(`/teams/${encodeURIComponent(t.id)}`),h=e(w,{variant:"primary",onClick:()=>i(!0),icon:e(y,{name:"plus",size:"16px"}),"data-testid":"apigee-new-team",children:"New team"}),n=(s=l.data)!==null&&s!==void 0?s:[],b=n.filter(t=>I(g,t.name,t.description)),k=t=>f.filter(u=>u.owner.kind==="team"&&u.owner.teamId===t).length;return o(C,{children:[e(G,{title:"Teams",description:Te,actions:l.data&&n.length===0?void 0:h}),l.data?n.length===0?e(O,{icon:"user-group",title:"You are not in a team yet",text:"Create a team to share API keys with your colleagues, or ask a team owner to add your email.",action:h}):o(C,{children:[e(P,{children:e($,{value:g,onChange:c,placeholder:"Search teams",testId:"apigee-team-search"})}),b.length===0?e(E,{onClear:()=>c("")}):e(J,{children:o(H,{"data-testid":"apigee-team-list",children:[e("thead",{children:o("tr",{children:[e("th",{children:"Team"}),e("th",{children:"Your role"}),e("th",{children:"Members"}),e("th",{children:"Apps"}),e("th",{className:"chevron","aria-hidden":"true"})]})}),e("tbody",{children:b.map(t=>o(ue,{to:p(t),testId:"apigee-team-row",children:[o("td",{children:[e(oe,{to:p(t),children:t.name}),t.description?e(q,{as:"div",style:{maxWidth:360},children:t.description}):null]}),e("td",{className:"trail",children:t.myRole?e(F,{role:t.myRole}):null}),e("td",{className:"meta","data-label":"Members",children:t.members.length}),e("td",{className:"meta","data-label":"Apps",children:k(t.id)}),e("td",{className:"chevron",children:e(y,{name:"chevron-right",size:"14px"})})]},t.id))})]})})]}):l.isError?null:e(z,{label:"Loading your teams\u2026"}),e(te,{open:r,onClose:()=>i(!1),onSubmit:t=>A(this,void 0,void 0,function*(){const u=yield x.createTeam(t);return L(u),m(d(`/teams/${encodeURIComponent(u.id)}/members`)),u})})]})}function We({teamId:s,tab:d}){var m,l,f;const{link:r,meta:i}=M(),g=_(),c=de(),p=X(),h=Q(),[n,b]=R(!1),[k,t]=R(!1),[u,S]=R(null),[ae,Y]=R(!1),a=(m=p.data)===null||m===void 0?void 0:m.find(v=>v.id===s),j=e(ge,{additionalBreadcrumbs:[{label:"Teams",link:r("/teams")},{label:(f=a?.name)!==null&&f!==void 0?f:s}]});if(!a)return o(C,{children:[j,p.data?e(O,{icon:"user-group",title:"Team not found",text:"The team was deleted, or you are no longer a member."}):p.isError?null:e(z,{label:"Loading the team\u2026",rows:3})]});const ne=a.myRole==="owner",B=`/teams/${encodeURIComponent(a.id)}`,N=(l=h.data)===null||l===void 0?void 0:l.filter(v=>v.owner.kind==="team"&&v.owner.teamId===a.id),ie=(v,T)=>be(a,v,T).then(()=>c.success("Role updated"),re=>c.error(me(re)));return o("div",{"data-testid":"apigee-team-detail",children:[j,e(G,{title:o(C,{children:[a.name,a.myRole?e(F,{role:a.myRole}):null]}),description:a.description||"Shared apps and keys for the team.",actions:ne?o(C,{children:[e(w,{variant:"outlined",onClick:()=>b(!0),icon:e(y,{name:"pen",size:"16px"}),children:"Edit team"}),e(U,{trigger:e(w,{variant:"outlined","aria-label":"More",icon:e(y,{name:"ellipsis-vertical",size:"16px"}),"data-testid":"apigee-team-menu"}),alignment:"end",children:e(V,{items:[{content:"Leave team",onAction:()=>S(i.viewer.email),dataAttributes:{"data-testid":"apigee-leave-team"}},{content:"Delete team",dangerous:!0,separatorLine:!0,onAction:()=>t(!0),dataAttributes:{"data-testid":"apigee-delete-team"}}]})})]}):e(w,{variant:"outlined",tone:"danger",onClick:()=>S(i.viewer.email),"data-testid":"apigee-leave-team",children:"Leave team"})}),e(fe,{items:[{type:"link",label:N?`Apps (${N.length})`:"Apps",link:r(B),icon:"key",active:d==="apps"},{type:"link",label:`Members (${a.members.length})`,link:r(`${B}/members`),icon:"user",active:d==="members"}]}),d==="apps"?e(ke,{team:a,apps:N}):e(Ae,{team:a,onAdd:()=>Y(!0),onRemove:S,onChangeRole:ie}),e(ye,{open:ae,onClose:()=>Y(!1),onSubmit:v=>A(this,void 0,void 0,function*(){const T=yield x.addMember(a.id,v);return L(T),T})}),e(te,{open:n,onClose:()=>b(!1),initial:a,onSubmit:v=>A(this,void 0,void 0,function*(){const T=yield x.updateTeam(a.id,v);return L(T),T})}),e(Z,{open:k,onClose:()=>t(!1),title:"Delete team?",confirmLabel:"Delete team",danger:!0,onConfirm:()=>A(this,void 0,void 0,function*(){return yield x.deleteTeam(a.id),g(r("/teams")),K(a.id),c.success(`${a.name} deleted`),!0}),children:o("p",{children:[e("strong",{children:a.name}),", its apps and all of their keys are removed from Apigee. This cannot be undone."]})}),e(Z,{open:u!==null,onClose:()=>S(null),title:u===i.viewer.email?"Leave team?":"Remove member?",confirmLabel:u===i.viewer.email?"Leave team":"Remove member",danger:!0,onConfirm:()=>A(this,void 0,void 0,function*(){if(!u)return!0;const v=yield x.removeMember(a.id,u);return u===i.viewer.email?(g(r("/teams")),K(a.id),c.success(`You left ${a.name}`)):L(v),!0}),children:e("p",{children:u===i.viewer.email?"You lose access to the team apps and their keys.":`${u} loses access to the team apps and their keys.`})})]})}function ke({team:s,apps:d}){var m;const{link:l}=M(),f=_(),[r,i]=D(),g=(m=d?.filter(c=>I(r,c.name,c.description)))!==null&&m!==void 0?m:[];return o(C,{children:[o(P,{children:[e($,{value:r,onChange:i,placeholder:"Search team apps",testId:"apigee-team-app-search"}),e(w,{variant:"primary",onClick:()=>f(l("",{createApp:"",team:s.id})),icon:e(y,{name:"plus",size:"16px"}),"data-testid":"apigee-new-team-app",children:"New team app"})]}),d?d.length===0?e(O,{icon:"key",title:"No team apps yet",text:"Create an app for this team so every member can use its keys."}):g.length===0?e(E,{onClear:()=>i("")}):e(we,{apps:g,showOwner:!1}):e(z,{label:"Loading apps\u2026",rows:2})]})}function Ae({team:s,onAdd:d,onRemove:m,onChangeRole:l}){const{meta:f}=M(),[r,i]=D(),[g,c]=pe("role"),p=s.myRole==="owner",h=s.members.filter(n=>(!g||n.role===g)&&I(r,n.email));return o(C,{children:[o(P,{children:[e($,{value:r,onChange:i,placeholder:"Search members by email",testId:"apigee-member-search"}),e(he,{children:e(le,{value:g,options:Ce,onChange:n=>c(String(n)),dataTestId:"apigee-role-filter"})}),p?e(w,{variant:"primary",onClick:d,icon:e(y,{name:"plus",size:"16px"}),"data-testid":"apigee-add-member",children:"Add member"}):null]}),h.length===0?e(E,{onClear:()=>{i(""),c("")}}):e(J,{children:o(H,{"data-testid":"apigee-members-table",children:[e("thead",{children:o("tr",{children:[e("th",{children:"Member"}),e("th",{children:"Role"}),e("th",{children:"Added"}),p?e("th",{className:"actions"}):null]})}),e("tbody",{children:h.map(n=>{var b;const k=n.email===f.viewer.email;return o("tr",{"data-testid":"apigee-member-row",children:[e("td",{children:o(ve,{children:[n.email,k?e(W,{color:"grey",children:"You"}):null]})}),e("td",{className:"trail",children:p?e(U,{trigger:e(w,{variant:"outlined",size:"small",icon:e(y,{name:"chevron-down",size:"12px"}),iconPosition:"right","data-testid":"apigee-member-role",children:(b=ee.find(t=>t.value===n.role))===null||b===void 0?void 0:b.element}),portalled:!0,children:e(V,{items:ee.map(t=>({content:t.element,active:t.value===n.role,onAction:()=>l(n.email,t.value)}))})}):e(F,{role:n.role})}),e("td",{className:"meta","data-label":"Added",children:ce(n.addedAt)}),p?e("td",{className:"actions",children:k?null:e(se,{tip:"Remove member",placement:"bottom",children:e(w,{variant:"text",size:"small",tone:"danger","aria-label":"Remove member",icon:e(y,{name:"trash-can",size:"14px"}),onClick:()=>m(n.email),"data-testid":"apigee-remove-member"})})}):null]},n.email)})})]})}),e(q,{as:"p",style:{marginTop:"var(--spacing-xs)"},children:"Members sign in with the portal account that matches their email. Owners can add and remove members and delete the team."})]})}export{Te as TEAMS_DESCRIPTION,We as TeamDetailView,Ve as TeamsView};
@@ -2,7 +2,7 @@ import type { SERVER_ONLY_VALUE_KEY } from '@redocly/framework/plugin';
2
2
  export declare const APIGEE_PLUGIN_ID = "redocly.apigee";
3
3
  export declare const APIGEE_TEMPLATE_ID = "apigee-apps";
4
4
  export declare const APIGEE_DEFAULT_BASE_PATH = "/apps";
5
- export declare const APIGEE_DEFAULT_TITLE = "API keys";
5
+ export declare const APIGEE_DEFAULT_TITLE = "Apps";
6
6
  export declare const APIGEE_DEFAULT_API_URL = "https://apigee.googleapis.com/v1";
7
7
  /** The server-only entity that maps Apigee API product names to the API pages that document them. */
8
8
  export declare const APIGEE_PRODUCTS_ENTITY_KEY = "apigee:api-products";
package/lib/constants.js CHANGED
@@ -1 +1 @@
1
- const s="redocly.apigee",p="apigee-apps",a="/apps",t="API keys",E="https://apigee.googleapis.com/v1",_="apigee:api-products",o="__serverOnly",e="/_apigee",I={meta:`${e}/meta`,access:`${e}/access`,apps:`${e}/apps`,app:`${e}/apps/:appId`,appKeys:`${e}/apps/:appId/keys`,appKey:`${e}/apps/:appId/keys/:consumerKey`,teams:`${e}/teams`,team:`${e}/teams/:teamId`,teamMembers:`${e}/teams/:teamId/members`,teamMember:`${e}/teams/:teamId/members/:email`,adminRequests:`${e}/admin/requests`,adminRequestApprove:`${e}/admin/requests/:requestId/approve`,adminRequestRevoke:`${e}/admin/requests/:requestId/revoke`,adminApps:`${e}/admin/apps`,adminAudit:`${e}/admin/audit`},m="__apigee_reserved__developer_details",r="DisplayName",A="Notes",T=3600*24*365;export{E as APIGEE_DEFAULT_API_URL,a as APIGEE_DEFAULT_BASE_PATH,T as APIGEE_DEFAULT_KEY_LIFETIME_SECONDS,t as APIGEE_DEFAULT_TITLE,r as APIGEE_DISPLAY_NAME_ATTRIBUTE,A as APIGEE_NOTES_ATTRIBUTE,s as APIGEE_PLUGIN_ID,_ as APIGEE_PRODUCTS_ENTITY_KEY,o as APIGEE_PRODUCTS_VALUE_KEY,I as APIGEE_ROUTES,m as APIGEE_TEAM_MEMBERS_ATTRIBUTE,p as APIGEE_TEMPLATE_ID};
1
+ const p="redocly.apigee",s="apigee-apps",a="/apps",t="Apps",E="https://apigee.googleapis.com/v1",_="apigee:api-products",o="__serverOnly",e="/_apigee",I={meta:`${e}/meta`,access:`${e}/access`,apps:`${e}/apps`,app:`${e}/apps/:appId`,appKeys:`${e}/apps/:appId/keys`,appKey:`${e}/apps/:appId/keys/:consumerKey`,teams:`${e}/teams`,team:`${e}/teams/:teamId`,teamMembers:`${e}/teams/:teamId/members`,teamMember:`${e}/teams/:teamId/members/:email`,adminRequests:`${e}/admin/requests`,adminRequestApprove:`${e}/admin/requests/:requestId/approve`,adminRequestRevoke:`${e}/admin/requests/:requestId/revoke`,adminApps:`${e}/admin/apps`,adminAudit:`${e}/admin/audit`},m="__apigee_reserved__developer_details",r="DisplayName",A="Notes",T=3600*24*365;export{E as APIGEE_DEFAULT_API_URL,a as APIGEE_DEFAULT_BASE_PATH,T as APIGEE_DEFAULT_KEY_LIFETIME_SECONDS,t as APIGEE_DEFAULT_TITLE,r as APIGEE_DISPLAY_NAME_ATTRIBUTE,A as APIGEE_NOTES_ATTRIBUTE,p as APIGEE_PLUGIN_ID,_ as APIGEE_PRODUCTS_ENTITY_KEY,o as APIGEE_PRODUCTS_VALUE_KEY,I as APIGEE_ROUTES,m as APIGEE_TEAM_MEMBERS_ATTRIBUTE,s as APIGEE_TEMPLATE_ID};
package/lib/contract.d.ts CHANGED
@@ -16,6 +16,8 @@ export type Decision = {
16
16
  };
17
17
  type ApiProductStatus = {
18
18
  id: string;
19
+ /** The product's display name; only the reviewer routes send it, and only when Apigee has one. */
20
+ name?: string;
19
21
  status: ApprovalStatus;
20
22
  decision?: Decision;
21
23
  };
@@ -100,11 +102,15 @@ export type AccessRequest = {
100
102
  owner: AppOwner;
101
103
  /** The developer who asked, when the request was made through this portal. */
102
104
  requestedBy?: string;
105
+ /** The display name of the owning team, when Apigee has one. */
106
+ teamName?: string;
103
107
  appId: string;
104
108
  appName: string;
105
109
  /** Masked: the first and last characters only. */
106
110
  consumerKey: string;
107
111
  apiProduct: string;
112
+ /** The product's display name, when Apigee has one. */
113
+ apiProductName?: string;
108
114
  note?: string;
109
115
  requestedAt: number | null;
110
116
  /** Whether the viewer may decide this request: `maintain` or `admin` on the product's page or the apps page. */
@@ -117,15 +123,21 @@ export type AuditEntry = {
117
123
  actor: string;
118
124
  action: AuditAction;
119
125
  owner: AppOwner;
126
+ /** The display name of the owning team, when Apigee has one; the audit route adds it. */
127
+ teamName?: string;
120
128
  appId: string;
121
129
  appName: string;
122
130
  /** Masked: the first and last characters only. */
123
131
  consumerKey: string;
124
132
  apiProduct: string;
133
+ /** The product's display name, when Apigee has one; the audit route adds it. */
134
+ apiProductName?: string;
125
135
  note?: string;
126
136
  };
127
137
  /** An app as reviewers see it: its keys without their values. */
128
138
  export type AdminApp = Omit<App, 'credentials'> & {
139
+ /** The display name of the owning team, when Apigee has one. */
140
+ teamName?: string;
129
141
  credentials: Omit<Credential, 'consumerKey' | 'consumerSecret'>[];
130
142
  };
131
143
  /** The viewer's standing on the Approvals page, from the rbac roles on the API pages and the apps page. */
@@ -173,6 +185,7 @@ export type ApigeeAppData = {
173
185
  accountLinks: {
174
186
  label: string;
175
187
  link: string;
188
+ icon: string;
176
189
  }[];
177
190
  /** Answers `ApiAccess` for the sidebar button and Try it on a page whose metadata has `apiId`. */
178
191
  apiAccessRoute: string;
package/lib/plugin.d.ts CHANGED
@@ -2,7 +2,7 @@ import { type ContentPlugin } from '@redocly/framework/plugin';
2
2
  export { APIGEE_TEMPLATE_ID } from './constants.js';
3
3
  export type { ApigeeAppData } from './contract.js';
4
4
  /**
5
- * The Apigee developer onboarding plugin for Realm Plus: an API keys page for signed-in
5
+ * The Apigee developer onboarding plugin for Realm Plus: an apps page for signed-in
6
6
  * developers, teams through Apigee app groups, reviewer approvals, and the API access protocol
7
7
  * that API reference pages follow.
8
8
  */
package/lib/plugin.js CHANGED
@@ -1 +1 @@
1
- import{createRequire as A}from"node:module";import{createInlineEntity as g,defineContentPlugin as f,isPlanClaimGranted as I,runtimeFile as _,runtimeTemplate as G}from"@redocly/framework/plugin";import{APIGEE_CONFIG_SCHEMA as b,APIGEE_PLAN_CLAIM as S,readApigeeSettings as v,resolveApigeeSettings as y}from"./config.js";import{APIGEE_PLUGIN_ID as C,APIGEE_PRODUCTS_ENTITY_KEY as L,APIGEE_PRODUCTS_VALUE_KEY as D,APIGEE_ROUTES as e,APIGEE_TEMPLATE_ID as c}from"./constants.js";import{APIGEE_TEMPLATE_ID as w}from"./constants.js";const{version:R}=A(import.meta.url)("../package.json");function t(a,i,r){return{path:a,method:r,auth:"manual",handler:{filePath:"./server/routes.ts",importer:import.meta.url,exportName:i}}}const h=[t(e.meta,"meta","GET"),t(e.access,"access","GET"),t(e.apps,"listApps","GET"),t(e.apps,"createApp","POST"),t(e.app,"updateApp",["PUT","PATCH"]),t(e.app,"deleteApp",["DELETE"]),t(e.appKeys,"createKey","POST"),t(e.appKey,"updateKey",["PUT","PATCH"]),t(e.appKey,"deleteKey",["DELETE"]),t(e.teams,"listTeams","GET"),t(e.teams,"createTeam","POST"),t(e.team,"getTeam","GET"),t(e.team,"updateTeam",["PUT","PATCH"]),t(e.team,"deleteTeam",["DELETE"]),t(e.teamMembers,"addTeamMember","POST"),t(e.teamMember,"updateTeamMember",["PUT","PATCH"]),t(e.teamMember,"removeTeamMember",["DELETE"]),t(e.adminRequests,"adminRequests","GET"),t(e.adminRequestApprove,"adminApprove","POST"),t(e.adminRequestRevoke,"adminRevoke","POST"),t(e.adminApps,"adminApps","GET"),t(e.adminAudit,"adminAudit","GET")],O={code:"configuration/ignored",message:"Developer onboarding is not in this project's plan, so the Apigee pages are skipped."};function M(a){return{accountLinks:[{label:a.title,link:a.basePath}],apiAccessRoute:e.access}}function K(a){var i,r,l;const d=a.routes.metadata("apiId"),T=a.routes.metadata("title"),E=a.routes.metadata("type"),p={},m={};for(const{slug:n,canonicalSlug:P}of a.routes.all()){if(E[n]!=="openapi"||P!=="")continue;const s=d[n],u=T[n],o=typeof u=="string"?u.trim():"";typeof s=="string"&&s!==""&&((i=p[s])!==null&&i!==void 0||(p[s]={slug:n,title:o||s})),o&&((r=m[l=o.toLowerCase()])!==null&&r!==void 0||(m[l]={slug:n,title:o}))}return{byApiId:p,byTitle:m}}const U=f({id:C,version:R,configSchema:b,templates:{[c]:G(_("./client/ApigeeTemplate.tsx",import.meta.url))},server:{routes:h},content:{filter:{match:()=>!1},extractAll(a){const i=y(a.config);return i?{routes:[{routeId:"apps",slug:i.basePath,template:c,wildcardPrefix:!0,metadata:{title:i.title,excludeFromSearch:!0}}]}:null}},finalize(a){const i=v(a.config);if(!i)return{};if(!I(a.config,S))return{problems:[O]};const r=g({[D]:K(a)},{stableKey:L,metadata:{routeSlug:i.basePath}});return{appData:{apigee:M(i)},entities:[r]}}});var F=U;export{w as APIGEE_TEMPLATE_ID,F as default};
1
+ import{createRequire as A}from"node:module";import{createInlineEntity as g,defineContentPlugin as f,isPlanClaimGranted as I,runtimeFile as _,runtimeTemplate as b}from"@redocly/framework/plugin";import{APIGEE_CONFIG_SCHEMA as G,APIGEE_PLAN_CLAIM as S,readApigeeSettings as v,resolveApigeeSettings as y}from"./config.js";import{APIGEE_PLUGIN_ID as C,APIGEE_PRODUCTS_ENTITY_KEY as L,APIGEE_PRODUCTS_VALUE_KEY as D,APIGEE_ROUTES as e,APIGEE_TEMPLATE_ID as c}from"./constants.js";import{APIGEE_TEMPLATE_ID as w}from"./constants.js";const{version:R}=A(import.meta.url)("../package.json");function t(a,i,r){return{path:a,method:r,auth:"manual",handler:{filePath:"./server/routes.ts",importer:import.meta.url,exportName:i}}}const h=[t(e.meta,"meta","GET"),t(e.access,"access","GET"),t(e.apps,"listApps","GET"),t(e.apps,"createApp","POST"),t(e.app,"updateApp",["PUT","PATCH"]),t(e.app,"deleteApp",["DELETE"]),t(e.appKeys,"createKey","POST"),t(e.appKey,"updateKey",["PUT","PATCH"]),t(e.appKey,"deleteKey",["DELETE"]),t(e.teams,"listTeams","GET"),t(e.teams,"createTeam","POST"),t(e.team,"getTeam","GET"),t(e.team,"updateTeam",["PUT","PATCH"]),t(e.team,"deleteTeam",["DELETE"]),t(e.teamMembers,"addTeamMember","POST"),t(e.teamMember,"updateTeamMember",["PUT","PATCH"]),t(e.teamMember,"removeTeamMember",["DELETE"]),t(e.adminRequests,"adminRequests","GET"),t(e.adminRequestApprove,"adminApprove","POST"),t(e.adminRequestRevoke,"adminRevoke","POST"),t(e.adminApps,"adminApps","GET"),t(e.adminAudit,"adminAudit","GET")],O={code:"configuration/ignored",message:"Developer onboarding is not in this project's plan, so the Apigee pages are skipped."};function M(a){return{accountLinks:[{label:a.title,link:a.basePath,icon:"key"}],apiAccessRoute:e.access}}function K(a){var i,r,l;const d=a.routes.metadata("apiId"),E=a.routes.metadata("title"),T=a.routes.metadata("type"),p={},m={};for(const{slug:n,canonicalSlug:P}of a.routes.all()){if(T[n]!=="openapi"||P!=="")continue;const s=d[n],u=E[n],o=typeof u=="string"?u.trim():"";typeof s=="string"&&s!==""&&((i=p[s])!==null&&i!==void 0||(p[s]={slug:n,title:o||s})),o&&((r=m[l=o.toLowerCase()])!==null&&r!==void 0||(m[l]={slug:n,title:o}))}return{byApiId:p,byTitle:m}}const U=f({id:C,version:R,configSchema:G,templates:{[c]:b(_("./client/ApigeeTemplate.tsx",import.meta.url))},server:{routes:h},content:{filter:{match:()=>!1},extractAll(a){const i=y(a.config);return i?{routes:[{routeId:"apps",slug:i.basePath,template:c,wildcardPrefix:!0,metadata:{title:i.title,teamsEnabled:i.teamsEnabled,excludeFromSearch:!0}}]}:null}},finalize(a){const i=v(a.config);if(!i)return{};if(!I(a.config,S))return{problems:[O]};const r=g({[D]:K(a)},{stableKey:L,metadata:{routeSlug:i.basePath}});return{appData:{apigee:M(i)},entities:[r]}}});var F=U;export{w as APIGEE_TEMPLATE_ID,F as default};
@@ -70,8 +70,6 @@ export declare class ApigeeService {
70
70
  private withRole;
71
71
  /** The teams whose AppGroup lists the viewer, read from every AppGroup of the organization. */
72
72
  listMyTeams(): Promise<Team[]>;
73
- /** The teams in the viewer's KV index whose AppGroup still lists them, without reading every AppGroup. */
74
- private indexedTeams;
75
73
  private requireTeam;
76
74
  getTeam(teamId: string): Promise<Team>;
77
75
  createTeam(input: TeamInput): Promise<Team>;
@@ -83,6 +81,11 @@ export declare class ApigeeService {
83
81
  removeMember(teamId: string, email: string): Promise<Team>;
84
82
  private syncAppGroup;
85
83
  private ownerOf;
84
+ /**
85
+ * AppGroup display names by AppGroup name; groups without one are left out. Empty when teams
86
+ * are off or the AppGroups cannot be read.
87
+ */
88
+ private teamNames;
86
89
  /** Requests for the products the viewer may review, newest first. */
87
90
  listRequests(): Promise<AccessRequest[]>;
88
91
  decideRequest(requestId: string, action: KeyAction, note?: string): Promise<AuditEntry>;