@kuadrant/kuadrant-backstage-plugin-frontend 0.0.2-dev-3d7caf4 → 0.0.2-dev-415994c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/empty-state-illustration.png +0 -0
- package/dist/components/ApiProductDetailPage/ApiProductDetailPage.esm.js +248 -0
- package/dist/components/ApiProductDetailPage/ApiProductDetailPage.esm.js.map +1 -0
- package/dist/components/ApiProductDetailPage/index.esm.js +2 -0
- package/dist/components/ApiProductDetailPage/index.esm.js.map +1 -0
- package/dist/components/ApiProductDetails/ApiProductDetails.esm.js +86 -0
- package/dist/components/ApiProductDetails/ApiProductDetails.esm.js.map +1 -0
- package/dist/components/ApiProductInfoCard/ApiProductInfoCard.esm.js +24 -43
- package/dist/components/ApiProductInfoCard/ApiProductInfoCard.esm.js.map +1 -1
- package/dist/components/ApprovalQueueTable/ApprovalQueueTable.esm.js +2 -1
- package/dist/components/ApprovalQueueTable/ApprovalQueueTable.esm.js.map +1 -1
- package/dist/components/CreateAPIProductDialog/CreateAPIProductDialog.esm.js +148 -134
- package/dist/components/CreateAPIProductDialog/CreateAPIProductDialog.esm.js.map +1 -1
- package/dist/components/EditAPIProductDialog/EditAPIProductDialog.esm.js +104 -128
- package/dist/components/EditAPIProductDialog/EditAPIProductDialog.esm.js.map +1 -1
- package/dist/components/KuadrantPage/KuadrantPage.esm.js +328 -125
- package/dist/components/KuadrantPage/KuadrantPage.esm.js.map +1 -1
- package/dist/components/MyApiKeysTable/MyApiKeysTable.esm.js +2 -1
- package/dist/components/MyApiKeysTable/MyApiKeysTable.esm.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.esm.js +1 -1
- package/dist/plugin.esm.js +8 -1
- package/dist/plugin.esm.js.map +1 -1
- package/dist/utils/validation.esm.js +1 -11
- package/dist/utils/validation.esm.js.map +1 -1
- package/dist-scalprum/{internal.plugin-kuadrant.793ab10dddb55e70abe2.js → internal.plugin-kuadrant.47663f119ccb78d7ec47.js} +2 -2
- package/dist-scalprum/internal.plugin-kuadrant.47663f119ccb78d7ec47.js.map +1 -0
- package/dist-scalprum/plugin-manifest.json +2 -2
- package/dist-scalprum/static/2759.fceb317f.chunk.js +2 -0
- package/dist-scalprum/static/2759.fceb317f.chunk.js.map +1 -0
- package/dist-scalprum/static/2928.4303c12e.chunk.js +3 -0
- package/dist-scalprum/static/2928.4303c12e.chunk.js.map +1 -0
- package/dist-scalprum/static/2967.ac3a4bee.chunk.js +2 -0
- package/dist-scalprum/static/2967.ac3a4bee.chunk.js.map +1 -0
- package/dist-scalprum/static/{6979.9699b350.chunk.js → 2987.1da15560.chunk.js} +2 -2
- package/dist-scalprum/static/2987.1da15560.chunk.js.map +1 -0
- package/dist-scalprum/static/3459.5c90b5a3.chunk.js +2 -0
- package/dist-scalprum/static/3459.5c90b5a3.chunk.js.map +1 -0
- package/dist-scalprum/static/3503.66b6e510.chunk.js +2 -0
- package/dist-scalprum/static/3503.66b6e510.chunk.js.map +1 -0
- package/dist-scalprum/static/4682.9ee4e285.chunk.js +2 -0
- package/dist-scalprum/static/4682.9ee4e285.chunk.js.map +1 -0
- package/dist-scalprum/static/5010.a4aa0f8e.chunk.js +3 -0
- package/dist-scalprum/static/5010.a4aa0f8e.chunk.js.map +1 -0
- package/dist-scalprum/static/5453.280127dd.chunk.js +2 -0
- package/dist-scalprum/static/5453.280127dd.chunk.js.map +1 -0
- package/dist-scalprum/static/6422.97baf774.chunk.js +2 -0
- package/dist-scalprum/static/6422.97baf774.chunk.js.map +1 -0
- package/dist-scalprum/static/7791.12162a71.chunk.js +2 -0
- package/dist-scalprum/static/7791.12162a71.chunk.js.map +1 -0
- package/dist-scalprum/static/8799.7c749838.chunk.js +2 -0
- package/dist-scalprum/static/8799.7c749838.chunk.js.map +1 -0
- package/dist-scalprum/static/empty-state-illustration.7e3ad5a9..png +0 -0
- package/dist-scalprum/static/exposed-PluginRoot.a5792fb2.chunk.js +2 -0
- package/dist-scalprum/static/exposed-PluginRoot.a5792fb2.chunk.js.map +1 -0
- package/package.json +1 -1
- package/dist-scalprum/internal.plugin-kuadrant.793ab10dddb55e70abe2.js.map +0 -1
- package/dist-scalprum/static/2120.44884438.chunk.js +0 -3
- package/dist-scalprum/static/2120.44884438.chunk.js.map +0 -1
- package/dist-scalprum/static/2967.c684efaf.chunk.js +0 -2
- package/dist-scalprum/static/2967.c684efaf.chunk.js.map +0 -1
- package/dist-scalprum/static/5010.acf9a415.chunk.js +0 -3
- package/dist-scalprum/static/5010.acf9a415.chunk.js.map +0 -1
- package/dist-scalprum/static/5453.c1f90bdf.chunk.js +0 -2
- package/dist-scalprum/static/5453.c1f90bdf.chunk.js.map +0 -1
- package/dist-scalprum/static/6813.036a322f.chunk.js +0 -2
- package/dist-scalprum/static/6813.036a322f.chunk.js.map +0 -1
- package/dist-scalprum/static/6979.9699b350.chunk.js.map +0 -1
- package/dist-scalprum/static/7684.3d1fc1a1.chunk.js +0 -2
- package/dist-scalprum/static/7684.3d1fc1a1.chunk.js.map +0 -1
- package/dist-scalprum/static/8416.3604a311.chunk.js +0 -2
- package/dist-scalprum/static/8416.3604a311.chunk.js.map +0 -1
- package/dist-scalprum/static/exposed-PluginRoot.16bf7897.chunk.js +0 -2
- package/dist-scalprum/static/exposed-PluginRoot.16bf7897.chunk.js.map +0 -1
- /package/dist-scalprum/static/{2120.44884438.chunk.js.LICENSE.txt → 2928.4303c12e.chunk.js.LICENSE.txt} +0 -0
- /package/dist-scalprum/static/{5010.acf9a415.chunk.js.LICENSE.txt → 5010.a4aa0f8e.chunk.js.LICENSE.txt} +0 -0
|
Binary file
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useParams, useNavigate } from 'react-router-dom';
|
|
3
|
+
import { useApi, configApiRef, fetchApiRef, alertApiRef } from '@backstage/core-plugin-api';
|
|
4
|
+
import { useAsync } from 'react-use';
|
|
5
|
+
import { Progress, ResponseErrorPanel, Page, Header, Link, Content, Breadcrumbs, InfoCard } from '@backstage/core-components';
|
|
6
|
+
import { makeStyles, Box, Button, Tooltip, IconButton, Typography, Tabs, Tab, Grid, Chip, Table, TableHead, TableRow, TableCell, TableBody } from '@material-ui/core';
|
|
7
|
+
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
|
8
|
+
import EditIcon from '@material-ui/icons/Edit';
|
|
9
|
+
import DeleteIcon from '@material-ui/icons/Delete';
|
|
10
|
+
import { EditAPIProductDialog } from '../EditAPIProductDialog/EditAPIProductDialog.esm.js';
|
|
11
|
+
import { ConfirmDeleteDialog } from '../ConfirmDeleteDialog/ConfirmDeleteDialog.esm.js';
|
|
12
|
+
import { ApiProductDetails } from '../ApiProductDetails/ApiProductDetails.esm.js';
|
|
13
|
+
import { useKuadrantPermission } from '../../utils/permissions.esm.js';
|
|
14
|
+
import { kuadrantApiProductUpdateAllPermission, kuadrantApiProductDeleteAllPermission } from '../../permissions.esm.js';
|
|
15
|
+
|
|
16
|
+
const useStyles = makeStyles((theme) => ({
|
|
17
|
+
label: {
|
|
18
|
+
fontWeight: 600,
|
|
19
|
+
color: theme.palette.text.secondary,
|
|
20
|
+
marginBottom: theme.spacing(0.5),
|
|
21
|
+
fontSize: "0.75rem",
|
|
22
|
+
textTransform: "uppercase"
|
|
23
|
+
},
|
|
24
|
+
actionButtons: {
|
|
25
|
+
display: "flex",
|
|
26
|
+
gap: theme.spacing(1),
|
|
27
|
+
alignItems: "center"
|
|
28
|
+
},
|
|
29
|
+
cardHeader: {
|
|
30
|
+
display: "flex",
|
|
31
|
+
justifyContent: "space-between",
|
|
32
|
+
alignItems: "flex-start",
|
|
33
|
+
marginBottom: theme.spacing(2)
|
|
34
|
+
},
|
|
35
|
+
cardActions: {
|
|
36
|
+
display: "flex",
|
|
37
|
+
gap: theme.spacing(1),
|
|
38
|
+
alignItems: "center"
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
const ApiProductDetailPage = () => {
|
|
42
|
+
const classes = useStyles();
|
|
43
|
+
const { namespace, name } = useParams();
|
|
44
|
+
const navigate = useNavigate();
|
|
45
|
+
const config = useApi(configApiRef);
|
|
46
|
+
const fetchApi = useApi(fetchApiRef);
|
|
47
|
+
const alertApi = useApi(alertApiRef);
|
|
48
|
+
const backendUrl = config.getString("backend.baseUrl");
|
|
49
|
+
const [selectedTab, setSelectedTab] = useState(0);
|
|
50
|
+
const [editDialogOpen, setEditDialogOpen] = useState(false);
|
|
51
|
+
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
|
|
52
|
+
const [deleting, setDeleting] = useState(false);
|
|
53
|
+
const [refreshKey, setRefreshKey] = useState(0);
|
|
54
|
+
const { allowed: canUpdateApiProduct } = useKuadrantPermission(kuadrantApiProductUpdateAllPermission);
|
|
55
|
+
const { allowed: canDeleteApiProduct } = useKuadrantPermission(kuadrantApiProductDeleteAllPermission);
|
|
56
|
+
const canPublishApiProduct = canUpdateApiProduct;
|
|
57
|
+
const {
|
|
58
|
+
value: product,
|
|
59
|
+
loading,
|
|
60
|
+
error
|
|
61
|
+
} = useAsync(async () => {
|
|
62
|
+
const response = await fetchApi.fetch(
|
|
63
|
+
`${backendUrl}/api/kuadrant/apiproducts/${namespace}/${name}`
|
|
64
|
+
);
|
|
65
|
+
if (!response.ok) {
|
|
66
|
+
throw new Error("Failed to fetch API product");
|
|
67
|
+
}
|
|
68
|
+
return response.json();
|
|
69
|
+
}, [namespace, name, backendUrl, fetchApi, refreshKey]);
|
|
70
|
+
const handlePublishToggle = async () => {
|
|
71
|
+
if (!product) return;
|
|
72
|
+
const newStatus = product.spec?.publishStatus === "Published" ? "Draft" : "Published";
|
|
73
|
+
try {
|
|
74
|
+
const response = await fetchApi.fetch(
|
|
75
|
+
`${backendUrl}/api/kuadrant/apiproducts/${namespace}/${name}`,
|
|
76
|
+
{
|
|
77
|
+
method: "PATCH",
|
|
78
|
+
headers: { "Content-Type": "application/json" },
|
|
79
|
+
body: JSON.stringify({ spec: { publishStatus: newStatus } })
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
if (!response.ok) throw new Error("Failed to update publish status");
|
|
83
|
+
alertApi.post({
|
|
84
|
+
message: `API Product ${newStatus === "Published" ? "published" : "unpublished"} successfully`,
|
|
85
|
+
severity: "success",
|
|
86
|
+
display: "transient"
|
|
87
|
+
});
|
|
88
|
+
setRefreshKey((k) => k + 1);
|
|
89
|
+
} catch (err) {
|
|
90
|
+
alertApi.post({
|
|
91
|
+
message: "Failed to update publish status",
|
|
92
|
+
severity: "error",
|
|
93
|
+
display: "transient"
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const handleEditSuccess = () => {
|
|
98
|
+
setEditDialogOpen(false);
|
|
99
|
+
setRefreshKey((k) => k + 1);
|
|
100
|
+
alertApi.post({
|
|
101
|
+
message: "API Product updated successfully",
|
|
102
|
+
severity: "success",
|
|
103
|
+
display: "transient"
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
const handleDelete = async () => {
|
|
107
|
+
if (!product) return;
|
|
108
|
+
setDeleting(true);
|
|
109
|
+
try {
|
|
110
|
+
const response = await fetchApi.fetch(
|
|
111
|
+
`${backendUrl}/api/kuadrant/apiproducts/${namespace}/${name}`,
|
|
112
|
+
{ method: "DELETE" }
|
|
113
|
+
);
|
|
114
|
+
if (!response.ok) throw new Error("Failed to delete API product");
|
|
115
|
+
setDeleteDialogOpen(false);
|
|
116
|
+
alertApi.post({
|
|
117
|
+
message: "API Product deleted successfully",
|
|
118
|
+
severity: "success",
|
|
119
|
+
display: "transient"
|
|
120
|
+
});
|
|
121
|
+
navigate("/kuadrant/api-products");
|
|
122
|
+
} catch (err) {
|
|
123
|
+
alertApi.post({
|
|
124
|
+
message: "Failed to delete API product",
|
|
125
|
+
severity: "error",
|
|
126
|
+
display: "transient"
|
|
127
|
+
});
|
|
128
|
+
} finally {
|
|
129
|
+
setDeleting(false);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
if (loading) {
|
|
133
|
+
return /* @__PURE__ */ React.createElement(Progress, null);
|
|
134
|
+
}
|
|
135
|
+
if (error || !product) {
|
|
136
|
+
return /* @__PURE__ */ React.createElement(ResponseErrorPanel, { error: error || new Error("API product not found") });
|
|
137
|
+
}
|
|
138
|
+
const isPublished = product.spec?.publishStatus === "Published";
|
|
139
|
+
const planPolicyCondition = product.status?.conditions?.find(
|
|
140
|
+
(c) => c.type === "PlanPolicyDiscovered"
|
|
141
|
+
);
|
|
142
|
+
const authPolicyCondition = product.status?.conditions?.find(
|
|
143
|
+
(c) => c.type === "AuthPolicyDiscovered"
|
|
144
|
+
);
|
|
145
|
+
const discoveredPlans = product.status?.discoveredPlans || [];
|
|
146
|
+
const hasDefinitionTab = !!product.spec?.documentation?.openAPISpecURL;
|
|
147
|
+
const hasPoliciesTab = !!(planPolicyCondition || authPolicyCondition || discoveredPlans.length > 0);
|
|
148
|
+
const definitionTabIndex = hasDefinitionTab ? 1 : -1;
|
|
149
|
+
const policiesTabIndex = hasPoliciesTab ? hasDefinitionTab ? 2 : 1 : -1;
|
|
150
|
+
const formatLimits = (limits) => {
|
|
151
|
+
if (!limits) return "No limits";
|
|
152
|
+
const parts = [];
|
|
153
|
+
if (limits.daily) parts.push(`${limits.daily}/day`);
|
|
154
|
+
if (limits.weekly) parts.push(`${limits.weekly}/week`);
|
|
155
|
+
if (limits.monthly) parts.push(`${limits.monthly}/month`);
|
|
156
|
+
if (limits.yearly) parts.push(`${limits.yearly}/year`);
|
|
157
|
+
return parts.length > 0 ? parts.join(", ") : "No limits";
|
|
158
|
+
};
|
|
159
|
+
return /* @__PURE__ */ React.createElement(Page, { themeId: "tool" }, /* @__PURE__ */ React.createElement(
|
|
160
|
+
Header,
|
|
161
|
+
{
|
|
162
|
+
title: product.spec?.displayName || product.metadata.name,
|
|
163
|
+
subtitle: product.spec?.description || ""
|
|
164
|
+
},
|
|
165
|
+
/* @__PURE__ */ React.createElement(Box, { className: classes.actionButtons }, /* @__PURE__ */ React.createElement(Link, { to: "/kuadrant/api-products" }, /* @__PURE__ */ React.createElement(Button, { startIcon: /* @__PURE__ */ React.createElement(ArrowBackIcon, null) }, "Back")), canPublishApiProduct && /* @__PURE__ */ React.createElement(
|
|
166
|
+
Button,
|
|
167
|
+
{
|
|
168
|
+
variant: "outlined",
|
|
169
|
+
color: isPublished ? "default" : "primary",
|
|
170
|
+
onClick: handlePublishToggle
|
|
171
|
+
},
|
|
172
|
+
isPublished ? "Unpublish API product" : "Publish API product"
|
|
173
|
+
), canUpdateApiProduct && /* @__PURE__ */ React.createElement(Tooltip, { title: "Edit" }, /* @__PURE__ */ React.createElement(IconButton, { onClick: () => setEditDialogOpen(true), size: "small" }, /* @__PURE__ */ React.createElement(EditIcon, null))), canDeleteApiProduct && /* @__PURE__ */ React.createElement(Tooltip, { title: "Delete" }, /* @__PURE__ */ React.createElement(IconButton, { onClick: () => setDeleteDialogOpen(true), size: "small" }, /* @__PURE__ */ React.createElement(DeleteIcon, null))))
|
|
174
|
+
), /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(Box, { mb: 2 }, /* @__PURE__ */ React.createElement(Breadcrumbs, { "aria-label": "breadcrumb" }, /* @__PURE__ */ React.createElement(Link, { to: "/kuadrant/api-products" }, "API Products"), /* @__PURE__ */ React.createElement(Typography, null, product.spec?.displayName || product.metadata.name))), /* @__PURE__ */ React.createElement(Box, { mb: 2 }, /* @__PURE__ */ React.createElement(
|
|
175
|
+
Tabs,
|
|
176
|
+
{
|
|
177
|
+
value: selectedTab,
|
|
178
|
+
onChange: (_, newValue) => setSelectedTab(newValue),
|
|
179
|
+
indicatorColor: "primary",
|
|
180
|
+
textColor: "primary"
|
|
181
|
+
},
|
|
182
|
+
/* @__PURE__ */ React.createElement(Tab, { label: "Overview" }),
|
|
183
|
+
hasDefinitionTab && /* @__PURE__ */ React.createElement(Tab, { label: "Definition" }),
|
|
184
|
+
hasPoliciesTab && /* @__PURE__ */ React.createElement(Tab, { label: "Policies" })
|
|
185
|
+
)), selectedTab === 0 && /* @__PURE__ */ React.createElement(InfoCard, { title: "API Product" }, /* @__PURE__ */ React.createElement(Box, { className: classes.cardHeader }, /* @__PURE__ */ React.createElement(Box, null, /* @__PURE__ */ React.createElement(Typography, { variant: "caption", className: classes.label }, "Product Name"), /* @__PURE__ */ React.createElement(Typography, { variant: "h6" }, product.spec?.displayName || product.metadata.name)), /* @__PURE__ */ React.createElement(Box, { className: classes.cardActions }, canPublishApiProduct && /* @__PURE__ */ React.createElement(
|
|
186
|
+
Button,
|
|
187
|
+
{
|
|
188
|
+
variant: "outlined",
|
|
189
|
+
color: isPublished ? "default" : "primary",
|
|
190
|
+
onClick: handlePublishToggle,
|
|
191
|
+
size: "small"
|
|
192
|
+
},
|
|
193
|
+
isPublished ? "Unpublish API product" : "Publish API product"
|
|
194
|
+
), canUpdateApiProduct && /* @__PURE__ */ React.createElement(IconButton, { onClick: () => setEditDialogOpen(true), size: "small" }, /* @__PURE__ */ React.createElement(EditIcon, { fontSize: "small" })), canDeleteApiProduct && /* @__PURE__ */ React.createElement(IconButton, { onClick: () => setDeleteDialogOpen(true), size: "small" }, /* @__PURE__ */ React.createElement(DeleteIcon, { fontSize: "small" })))), /* @__PURE__ */ React.createElement(
|
|
195
|
+
ApiProductDetails,
|
|
196
|
+
{
|
|
197
|
+
product,
|
|
198
|
+
showStatus: true,
|
|
199
|
+
showCatalogLink: true
|
|
200
|
+
}
|
|
201
|
+
)), selectedTab === definitionTabIndex && hasDefinitionTab && /* @__PURE__ */ React.createElement(InfoCard, { title: "API Definition" }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2", color: "textSecondary" }, "View the OpenAPI specification at:", " ", /* @__PURE__ */ React.createElement(Link, { to: product.spec?.documentation?.openAPISpecURL || "", target: "_blank" }, product.spec?.documentation?.openAPISpecURL))), selectedTab === policiesTabIndex && hasPoliciesTab && /* @__PURE__ */ React.createElement(Grid, { container: true, spacing: 3 }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(InfoCard, { title: "Discovered Policies" }, /* @__PURE__ */ React.createElement(Grid, { container: true, spacing: 2 }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, md: 6 }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2", color: "textSecondary", gutterBottom: true }, "Plan Policy"), planPolicyCondition ? /* @__PURE__ */ React.createElement(Box, null, /* @__PURE__ */ React.createElement(
|
|
202
|
+
Chip,
|
|
203
|
+
{
|
|
204
|
+
label: planPolicyCondition.status === "True" ? "Found" : "Not Found",
|
|
205
|
+
size: "small",
|
|
206
|
+
style: {
|
|
207
|
+
backgroundColor: planPolicyCondition.status === "True" ? "#4caf50" : "#ff9800",
|
|
208
|
+
color: "#fff",
|
|
209
|
+
marginBottom: 8
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
), /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, planPolicyCondition.message || "No details available")) : /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, "No plan policy information")), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, md: 6 }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2", color: "textSecondary", gutterBottom: true }, "Auth Policy"), authPolicyCondition ? /* @__PURE__ */ React.createElement(Box, null, /* @__PURE__ */ React.createElement(
|
|
213
|
+
Chip,
|
|
214
|
+
{
|
|
215
|
+
label: authPolicyCondition.status === "True" ? "Found" : "Not Found",
|
|
216
|
+
size: "small",
|
|
217
|
+
style: {
|
|
218
|
+
backgroundColor: authPolicyCondition.status === "True" ? "#4caf50" : "#ff9800",
|
|
219
|
+
color: "#fff",
|
|
220
|
+
marginBottom: 8
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
), /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, authPolicyCondition.message || "No details available")) : /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, "No auth policy information"))))), discoveredPlans.length > 0 && /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(InfoCard, { title: "Effective Plan Tiers" }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2", color: "textSecondary", paragraph: true }, "These tiers are computed from all attached PlanPolicies (including gateway-level policies)."), /* @__PURE__ */ React.createElement(Table, { size: "small" }, /* @__PURE__ */ React.createElement(TableHead, null, /* @__PURE__ */ React.createElement(TableRow, null, /* @__PURE__ */ React.createElement(TableCell, null, "Tier"), /* @__PURE__ */ React.createElement(TableCell, null, "Rate Limits"))), /* @__PURE__ */ React.createElement(TableBody, null, discoveredPlans.map((plan) => /* @__PURE__ */ React.createElement(TableRow, { key: plan.tier }, /* @__PURE__ */ React.createElement(TableCell, null, /* @__PURE__ */ React.createElement(Chip, { label: plan.tier, size: "small", color: "primary" })), /* @__PURE__ */ React.createElement(TableCell, null, formatLimits(plan.limits)))))))))), /* @__PURE__ */ React.createElement(
|
|
224
|
+
EditAPIProductDialog,
|
|
225
|
+
{
|
|
226
|
+
open: editDialogOpen,
|
|
227
|
+
onClose: () => setEditDialogOpen(false),
|
|
228
|
+
onSuccess: handleEditSuccess,
|
|
229
|
+
namespace: namespace || "",
|
|
230
|
+
name: name || ""
|
|
231
|
+
}
|
|
232
|
+
), /* @__PURE__ */ React.createElement(
|
|
233
|
+
ConfirmDeleteDialog,
|
|
234
|
+
{
|
|
235
|
+
open: deleteDialogOpen,
|
|
236
|
+
title: "Delete API Product",
|
|
237
|
+
description: `Are you sure you want to delete "${product.spec?.displayName || product.metadata.name}"? This action cannot be undone.`,
|
|
238
|
+
severity: "high",
|
|
239
|
+
confirmText: product.metadata.name,
|
|
240
|
+
deleting,
|
|
241
|
+
onConfirm: handleDelete,
|
|
242
|
+
onCancel: () => setDeleteDialogOpen(false)
|
|
243
|
+
}
|
|
244
|
+
));
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
export { ApiProductDetailPage };
|
|
248
|
+
//# sourceMappingURL=ApiProductDetailPage.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiProductDetailPage.esm.js","sources":["../../../src/components/ApiProductDetailPage/ApiProductDetailPage.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { useParams, useNavigate } from \"react-router-dom\";\nimport {\n useApi,\n configApiRef,\n fetchApiRef,\n alertApiRef,\n} from \"@backstage/core-plugin-api\";\nimport { useAsync } from \"react-use\";\nimport {\n Header,\n Page,\n Content,\n Progress,\n ResponseErrorPanel,\n InfoCard,\n Link,\n Breadcrumbs,\n} from \"@backstage/core-components\";\nimport {\n Box,\n Typography,\n IconButton,\n Tooltip,\n Tabs,\n Tab,\n Button,\n makeStyles,\n Grid,\n Chip,\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableRow,\n} from \"@material-ui/core\";\nimport ArrowBackIcon from \"@material-ui/icons/ArrowBack\";\nimport EditIcon from \"@material-ui/icons/Edit\";\nimport DeleteIcon from \"@material-ui/icons/Delete\";\nimport { APIProduct } from \"../../types/api-management\";\nimport { EditAPIProductDialog } from \"../EditAPIProductDialog\";\nimport { ConfirmDeleteDialog } from \"../ConfirmDeleteDialog\";\nimport { ApiProductDetails } from \"../ApiProductDetails\";\nimport { useKuadrantPermission } from \"../../utils/permissions\";\nimport {\n kuadrantApiProductUpdateAllPermission,\n kuadrantApiProductDeleteAllPermission,\n} from \"../../permissions\";\n\nconst useStyles = makeStyles((theme) => ({\n label: {\n fontWeight: 600,\n color: theme.palette.text.secondary,\n marginBottom: theme.spacing(0.5),\n fontSize: '0.75rem',\n textTransform: 'uppercase',\n },\n actionButtons: {\n display: \"flex\",\n gap: theme.spacing(1),\n alignItems: \"center\",\n },\n cardHeader: {\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'flex-start',\n marginBottom: theme.spacing(2),\n },\n cardActions: {\n display: 'flex',\n gap: theme.spacing(1),\n alignItems: 'center',\n },\n}));\n\nexport const ApiProductDetailPage = () => {\n const classes = useStyles();\n const { namespace, name } = useParams<{ namespace: string; name: string }>();\n const navigate = useNavigate();\n const config = useApi(configApiRef);\n const fetchApi = useApi(fetchApiRef);\n const alertApi = useApi(alertApiRef);\n const backendUrl = config.getString(\"backend.baseUrl\");\n\n const [selectedTab, setSelectedTab] = useState(0);\n const [editDialogOpen, setEditDialogOpen] = useState(false);\n const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);\n const [deleting, setDeleting] = useState(false);\n const [refreshKey, setRefreshKey] = useState(0);\n\n const { allowed: canUpdateApiProduct } = useKuadrantPermission(kuadrantApiProductUpdateAllPermission);\n const { allowed: canDeleteApiProduct } = useKuadrantPermission(kuadrantApiProductDeleteAllPermission);\n const canPublishApiProduct = canUpdateApiProduct;\n\n const {\n value: product,\n loading,\n error,\n } = useAsync(async () => {\n const response = await fetchApi.fetch(\n `${backendUrl}/api/kuadrant/apiproducts/${namespace}/${name}`\n );\n\n if (!response.ok) {\n throw new Error(\"Failed to fetch API product\");\n }\n\n return response.json() as Promise<APIProduct>;\n }, [namespace, name, backendUrl, fetchApi, refreshKey]);\n\n const handlePublishToggle = async () => {\n if (!product) return;\n const newStatus = product.spec?.publishStatus === \"Published\" ? \"Draft\" : \"Published\";\n try {\n const response = await fetchApi.fetch(\n `${backendUrl}/api/kuadrant/apiproducts/${namespace}/${name}`,\n {\n method: \"PATCH\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ spec: { publishStatus: newStatus } }),\n }\n );\n if (!response.ok) throw new Error(\"Failed to update publish status\");\n alertApi.post({\n message: `API Product ${newStatus === \"Published\" ? \"published\" : \"unpublished\"} successfully`,\n severity: \"success\",\n display: \"transient\",\n });\n setRefreshKey((k) => k + 1);\n } catch (err) {\n alertApi.post({\n message: \"Failed to update publish status\",\n severity: \"error\",\n display: \"transient\",\n });\n }\n };\n\n const handleEditSuccess = () => {\n setEditDialogOpen(false);\n setRefreshKey((k) => k + 1);\n alertApi.post({\n message: \"API Product updated successfully\",\n severity: \"success\",\n display: \"transient\",\n });\n };\n\n const handleDelete = async () => {\n if (!product) return;\n setDeleting(true);\n try {\n const response = await fetchApi.fetch(\n `${backendUrl}/api/kuadrant/apiproducts/${namespace}/${name}`,\n { method: \"DELETE\" }\n );\n if (!response.ok) throw new Error(\"Failed to delete API product\");\n setDeleteDialogOpen(false);\n alertApi.post({\n message: \"API Product deleted successfully\",\n severity: \"success\",\n display: \"transient\",\n });\n navigate(\"/kuadrant/api-products\");\n } catch (err) {\n alertApi.post({\n message: \"Failed to delete API product\",\n severity: \"error\",\n display: \"transient\",\n });\n } finally {\n setDeleting(false);\n }\n };\n\n if (loading) {\n return <Progress />;\n }\n\n if (error || !product) {\n return (\n <ResponseErrorPanel error={error || new Error(\"API product not found\")} />\n );\n }\n\n const isPublished = product.spec?.publishStatus === \"Published\";\n\n // get policy conditions from status\n const planPolicyCondition = product.status?.conditions?.find(\n (c) => c.type === \"PlanPolicyDiscovered\"\n );\n const authPolicyCondition = product.status?.conditions?.find(\n (c) => c.type === \"AuthPolicyDiscovered\"\n );\n const discoveredPlans = product.status?.discoveredPlans || [];\n\n // compute tab indices\n const hasDefinitionTab = !!product.spec?.documentation?.openAPISpecURL;\n const hasPoliciesTab = !!(planPolicyCondition || authPolicyCondition || discoveredPlans.length > 0);\n const definitionTabIndex = hasDefinitionTab ? 1 : -1;\n const policiesTabIndex = hasPoliciesTab ? (hasDefinitionTab ? 2 : 1) : -1;\n\n const formatLimits = (limits: any): string => {\n if (!limits) return \"No limits\";\n const parts: string[] = [];\n if (limits.daily) parts.push(`${limits.daily}/day`);\n if (limits.weekly) parts.push(`${limits.weekly}/week`);\n if (limits.monthly) parts.push(`${limits.monthly}/month`);\n if (limits.yearly) parts.push(`${limits.yearly}/year`);\n return parts.length > 0 ? parts.join(\", \") : \"No limits\";\n };\n\n return (\n <Page themeId=\"tool\">\n <Header\n title={product.spec?.displayName || product.metadata.name}\n subtitle={product.spec?.description || \"\"}\n >\n <Box className={classes.actionButtons}>\n <Link to=\"/kuadrant/api-products\">\n <Button startIcon={<ArrowBackIcon />}>Back</Button>\n </Link>\n {canPublishApiProduct && (\n <Button\n variant=\"outlined\"\n color={isPublished ? \"default\" : \"primary\"}\n onClick={handlePublishToggle}\n >\n {isPublished ? \"Unpublish API product\" : \"Publish API product\"}\n </Button>\n )}\n {canUpdateApiProduct && (\n <Tooltip title=\"Edit\">\n <IconButton onClick={() => setEditDialogOpen(true)} size=\"small\">\n <EditIcon />\n </IconButton>\n </Tooltip>\n )}\n {canDeleteApiProduct && (\n <Tooltip title=\"Delete\">\n <IconButton onClick={() => setDeleteDialogOpen(true)} size=\"small\">\n <DeleteIcon />\n </IconButton>\n </Tooltip>\n )}\n </Box>\n </Header>\n <Content>\n <Box mb={2}>\n <Breadcrumbs aria-label=\"breadcrumb\">\n <Link to=\"/kuadrant/api-products\">API Products</Link>\n <Typography>{product.spec?.displayName || product.metadata.name}</Typography>\n </Breadcrumbs>\n </Box>\n\n <Box mb={2}>\n <Tabs\n value={selectedTab}\n onChange={(_, newValue) => setSelectedTab(newValue)}\n indicatorColor=\"primary\"\n textColor=\"primary\"\n >\n <Tab label=\"Overview\" />\n {hasDefinitionTab && <Tab label=\"Definition\" />}\n {hasPoliciesTab && <Tab label=\"Policies\" />}\n </Tabs>\n </Box>\n\n {selectedTab === 0 && (\n <InfoCard title=\"API Product\">\n <Box className={classes.cardHeader}>\n <Box>\n <Typography variant=\"caption\" className={classes.label}>\n Product Name\n </Typography>\n <Typography variant=\"h6\">\n {product.spec?.displayName || product.metadata.name}\n </Typography>\n </Box>\n <Box className={classes.cardActions}>\n {canPublishApiProduct && (\n <Button\n variant=\"outlined\"\n color={isPublished ? \"default\" : \"primary\"}\n onClick={handlePublishToggle}\n size=\"small\"\n >\n {isPublished ? \"Unpublish API product\" : \"Publish API product\"}\n </Button>\n )}\n {canUpdateApiProduct && (\n <IconButton onClick={() => setEditDialogOpen(true)} size=\"small\">\n <EditIcon fontSize=\"small\" />\n </IconButton>\n )}\n {canDeleteApiProduct && (\n <IconButton onClick={() => setDeleteDialogOpen(true)} size=\"small\">\n <DeleteIcon fontSize=\"small\" />\n </IconButton>\n )}\n </Box>\n </Box>\n\n <ApiProductDetails\n product={product}\n showStatus={true}\n showCatalogLink={true}\n />\n </InfoCard>\n )}\n\n {selectedTab === definitionTabIndex && hasDefinitionTab && (\n <InfoCard title=\"API Definition\">\n <Typography variant=\"body2\" color=\"textSecondary\">\n View the OpenAPI specification at:{\" \"}\n <Link to={product.spec?.documentation?.openAPISpecURL || \"\"} target=\"_blank\">\n {product.spec?.documentation?.openAPISpecURL}\n </Link>\n </Typography>\n </InfoCard>\n )}\n\n {selectedTab === policiesTabIndex && hasPoliciesTab && (\n <Grid container spacing={3}>\n <Grid item xs={12}>\n <InfoCard title=\"Discovered Policies\">\n <Grid container spacing={2}>\n <Grid item xs={12} md={6}>\n <Typography variant=\"body2\" color=\"textSecondary\" gutterBottom>\n Plan Policy\n </Typography>\n {planPolicyCondition ? (\n <Box>\n <Chip\n label={planPolicyCondition.status === \"True\" ? \"Found\" : \"Not Found\"}\n size=\"small\"\n style={{\n backgroundColor: planPolicyCondition.status === \"True\" ? \"#4caf50\" : \"#ff9800\",\n color: \"#fff\",\n marginBottom: 8,\n }}\n />\n <Typography variant=\"body2\">\n {planPolicyCondition.message || \"No details available\"}\n </Typography>\n </Box>\n ) : (\n <Typography variant=\"body2\">No plan policy information</Typography>\n )}\n </Grid>\n <Grid item xs={12} md={6}>\n <Typography variant=\"body2\" color=\"textSecondary\" gutterBottom>\n Auth Policy\n </Typography>\n {authPolicyCondition ? (\n <Box>\n <Chip\n label={authPolicyCondition.status === \"True\" ? \"Found\" : \"Not Found\"}\n size=\"small\"\n style={{\n backgroundColor: authPolicyCondition.status === \"True\" ? \"#4caf50\" : \"#ff9800\",\n color: \"#fff\",\n marginBottom: 8,\n }}\n />\n <Typography variant=\"body2\">\n {authPolicyCondition.message || \"No details available\"}\n </Typography>\n </Box>\n ) : (\n <Typography variant=\"body2\">No auth policy information</Typography>\n )}\n </Grid>\n </Grid>\n </InfoCard>\n </Grid>\n\n {discoveredPlans.length > 0 && (\n <Grid item xs={12}>\n <InfoCard title=\"Effective Plan Tiers\">\n <Typography variant=\"body2\" color=\"textSecondary\" paragraph>\n These tiers are computed from all attached PlanPolicies (including gateway-level policies).\n </Typography>\n <Table size=\"small\">\n <TableHead>\n <TableRow>\n <TableCell>Tier</TableCell>\n <TableCell>Rate Limits</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {discoveredPlans.map((plan) => (\n <TableRow key={plan.tier}>\n <TableCell>\n <Chip label={plan.tier} size=\"small\" color=\"primary\" />\n </TableCell>\n <TableCell>{formatLimits(plan.limits)}</TableCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n </InfoCard>\n </Grid>\n )}\n </Grid>\n )}\n </Content>\n\n <EditAPIProductDialog\n open={editDialogOpen}\n onClose={() => setEditDialogOpen(false)}\n onSuccess={handleEditSuccess}\n namespace={namespace || \"\"}\n name={name || \"\"}\n />\n\n <ConfirmDeleteDialog\n open={deleteDialogOpen}\n title=\"Delete API Product\"\n description={`Are you sure you want to delete \"${product.spec?.displayName || product.metadata.name}\"? This action cannot be undone.`}\n severity=\"high\"\n confirmText={product.metadata.name}\n deleting={deleting}\n onConfirm={handleDelete}\n onCancel={() => setDeleteDialogOpen(false)}\n />\n </Page>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAiDA,MAAM,SAAA,GAAY,UAAW,CAAA,CAAC,KAAW,MAAA;AAAA,EACvC,KAAO,EAAA;AAAA,IACL,UAAY,EAAA,GAAA;AAAA,IACZ,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA,SAAA;AAAA,IAC1B,YAAA,EAAc,KAAM,CAAA,OAAA,CAAQ,GAAG,CAAA;AAAA,IAC/B,QAAU,EAAA,SAAA;AAAA,IACV,aAAe,EAAA;AAAA,GACjB;AAAA,EACA,aAAe,EAAA;AAAA,IACb,OAAS,EAAA,MAAA;AAAA,IACT,GAAA,E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AAA,CAAC,QAAK,KAAO,EAAA,IAAA,CAAK,MAAM,IAAK,EAAA,OAAA,EAAQ,OAAM,SAAU,EAAA,CACvD,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,SAAW,EAAA,IAAA,EAAA,YAAA,CAAa,KAAK,MAAM,CAAE,CACxC,CACD,CACH,CACF,CACF,CACF,CAEJ,CAEJ,CAEA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,oBAAA;AAAA,IAAA;AAAA,MACC,IAAM,EAAA,cAAA;AAAA,MACN,OAAA,EAAS,MAAM,iBAAA,CAAkB,KAAK,CAAA;AAAA,MACtC,SAAW,EAAA,iBAAA;AAAA,MACX,WAAW,SAAa,IAAA,EAAA;AAAA,MACxB,MAAM,IAAQ,IAAA;AAAA;AAAA,GAGhB,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,mBAAA;AAAA,IAAA;AAAA,MACC,IAAM,EAAA,gBAAA;AAAA,MACN,KAAM,EAAA,oBAAA;AAAA,MACN,aAAa,CAAoC,iCAAA,EAAA,OAAA,CAAQ,MAAM,WAAe,IAAA,OAAA,CAAQ,SAAS,IAAI,CAAA,gCAAA,CAAA;AAAA,MACnG,QAAS,EAAA,MAAA;AAAA,MACT,WAAA,EAAa,QAAQ,QAAS,CAAA,IAAA;AAAA,MAC9B,QAAA;AAAA,MACA,SAAW,EAAA,YAAA;AAAA,MACX,QAAA,EAAU,MAAM,mBAAA,CAAoB,KAAK;AAAA;AAAA,GAE7C,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { makeStyles, Box, Typography, Chip, Table, TableHead, TableRow, TableCell, TableBody, Grid } from '@material-ui/core';
|
|
3
|
+
import { Link } from '@backstage/core-components';
|
|
4
|
+
|
|
5
|
+
const useStyles = makeStyles((theme) => ({
|
|
6
|
+
label: {
|
|
7
|
+
fontWeight: 600,
|
|
8
|
+
color: theme.palette.text.secondary,
|
|
9
|
+
marginBottom: theme.spacing(0.5),
|
|
10
|
+
fontSize: "0.75rem",
|
|
11
|
+
textTransform: "uppercase"
|
|
12
|
+
},
|
|
13
|
+
tierChip: {
|
|
14
|
+
marginRight: theme.spacing(0.5),
|
|
15
|
+
marginBottom: theme.spacing(0.5)
|
|
16
|
+
},
|
|
17
|
+
statusChipPublished: {
|
|
18
|
+
backgroundColor: theme.palette.primary.main,
|
|
19
|
+
color: theme.palette.primary.contrastText
|
|
20
|
+
},
|
|
21
|
+
statusChipDraft: {
|
|
22
|
+
backgroundColor: theme.palette.grey[600],
|
|
23
|
+
color: theme.palette.common.white
|
|
24
|
+
},
|
|
25
|
+
infoGrid: {
|
|
26
|
+
display: "grid",
|
|
27
|
+
gridTemplateColumns: "repeat(auto-fill, minmax(180px, 1fr))",
|
|
28
|
+
gap: theme.spacing(3),
|
|
29
|
+
marginBottom: theme.spacing(3)
|
|
30
|
+
},
|
|
31
|
+
infoItem: {
|
|
32
|
+
minWidth: 0
|
|
33
|
+
},
|
|
34
|
+
apiLink: {
|
|
35
|
+
color: theme.palette.primary.main,
|
|
36
|
+
textDecoration: "none",
|
|
37
|
+
"&:hover": {
|
|
38
|
+
textDecoration: "underline"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}));
|
|
42
|
+
const ApiProductDetails = ({
|
|
43
|
+
product,
|
|
44
|
+
showStatus = true,
|
|
45
|
+
showCatalogLink = true
|
|
46
|
+
}) => {
|
|
47
|
+
const classes = useStyles();
|
|
48
|
+
const publishStatus = product.spec?.publishStatus || "Draft";
|
|
49
|
+
const isPublished = publishStatus === "Published";
|
|
50
|
+
const tiers = product.status?.discoveredPlans || [];
|
|
51
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, product.spec?.description && /* @__PURE__ */ React.createElement(Box, { mb: 3 }, /* @__PURE__ */ React.createElement(Typography, { variant: "caption", className: classes.label }, "Description"), /* @__PURE__ */ React.createElement(Typography, { variant: "body1" }, product.spec.description)), /* @__PURE__ */ React.createElement(Box, { className: classes.infoGrid }, showStatus && /* @__PURE__ */ React.createElement(Box, { className: classes.infoItem }, /* @__PURE__ */ React.createElement(Typography, { variant: "caption", className: classes.label }, "Status"), /* @__PURE__ */ React.createElement(Box, null, /* @__PURE__ */ React.createElement(
|
|
52
|
+
Chip,
|
|
53
|
+
{
|
|
54
|
+
label: publishStatus,
|
|
55
|
+
size: "small",
|
|
56
|
+
className: isPublished ? classes.statusChipPublished : classes.statusChipDraft,
|
|
57
|
+
"data-testid": "publish-status-chip"
|
|
58
|
+
}
|
|
59
|
+
))), /* @__PURE__ */ React.createElement(Box, { className: classes.infoItem }, /* @__PURE__ */ React.createElement(Typography, { variant: "caption", className: classes.label }, "Version"), /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, product.spec?.version || "v1")), /* @__PURE__ */ React.createElement(Box, { className: classes.infoItem }, /* @__PURE__ */ React.createElement(Typography, { variant: "caption", className: classes.label }, "Namespace"), /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, product.metadata.namespace)), /* @__PURE__ */ React.createElement(Box, { className: classes.infoItem }, /* @__PURE__ */ React.createElement(Typography, { variant: "caption", className: classes.label }, "API Key Approval"), /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, product.spec?.approvalMode === "automatic" ? "Automatic" : "Need manual approval")), product.spec?.tags && product.spec.tags.length > 0 && /* @__PURE__ */ React.createElement(Box, { className: classes.infoItem }, /* @__PURE__ */ React.createElement(Typography, { variant: "caption", className: classes.label }, "Tags"), /* @__PURE__ */ React.createElement(Box, null, product.spec.tags.map((tag) => /* @__PURE__ */ React.createElement(
|
|
60
|
+
Chip,
|
|
61
|
+
{
|
|
62
|
+
key: tag,
|
|
63
|
+
label: tag,
|
|
64
|
+
size: "small",
|
|
65
|
+
variant: "outlined",
|
|
66
|
+
className: classes.tierChip
|
|
67
|
+
}
|
|
68
|
+
))))), /* @__PURE__ */ React.createElement(Box, { className: classes.infoGrid }, /* @__PURE__ */ React.createElement(Box, { className: classes.infoItem }, /* @__PURE__ */ React.createElement(Typography, { variant: "caption", className: classes.label }, "API"), /* @__PURE__ */ React.createElement("br", null), showCatalogLink ? /* @__PURE__ */ React.createElement(
|
|
69
|
+
Link,
|
|
70
|
+
{
|
|
71
|
+
to: `/catalog/default/api/${product.metadata.name}`,
|
|
72
|
+
className: classes.apiLink
|
|
73
|
+
},
|
|
74
|
+
product.metadata.name
|
|
75
|
+
) : /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, product.metadata.name)), /* @__PURE__ */ React.createElement(Box, { className: classes.infoItem }, /* @__PURE__ */ React.createElement(Typography, { variant: "caption", className: classes.label }, "Route"), /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, product.spec?.targetRef?.name || "-"))), tiers.length > 0 && /* @__PURE__ */ React.createElement(Box, { mb: 3 }, /* @__PURE__ */ React.createElement(Typography, { variant: "caption", className: classes.label }, "Available Tiers"), /* @__PURE__ */ React.createElement(Table, { size: "small" }, /* @__PURE__ */ React.createElement(TableHead, null, /* @__PURE__ */ React.createElement(TableRow, null, /* @__PURE__ */ React.createElement(TableCell, null, "Tier"), /* @__PURE__ */ React.createElement(TableCell, null, "Rate Limits"))), /* @__PURE__ */ React.createElement(TableBody, null, tiers.map((plan) => /* @__PURE__ */ React.createElement(TableRow, { key: plan.tier }, /* @__PURE__ */ React.createElement(TableCell, null, /* @__PURE__ */ React.createElement(Chip, { label: plan.tier, size: "small" })), /* @__PURE__ */ React.createElement(TableCell, null, plan.limits && Object.entries(plan.limits).map(([key, value]) => /* @__PURE__ */ React.createElement(Typography, { key, variant: "body2" }, String(value), " per ", key)))))))), /* @__PURE__ */ React.createElement(Grid, { container: true, spacing: 3 }, (product.spec?.contact?.email || product.spec?.contact?.team) && /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, md: 6 }, /* @__PURE__ */ React.createElement(Typography, { variant: "caption", className: classes.label }, "Contact Information"), /* @__PURE__ */ React.createElement(Box, { mt: 1 }, product.spec.contact.team && /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, /* @__PURE__ */ React.createElement("strong", null, "Team:"), " ", product.spec.contact.team), product.spec.contact.email && /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, /* @__PURE__ */ React.createElement("strong", null, "Email:"), " ", /* @__PURE__ */ React.createElement(Link, { to: `mailto:${product.spec.contact.email}` }, product.spec.contact.email)))), (product.spec?.documentation?.docsURL || product.spec?.documentation?.openAPISpecURL) && /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, md: 6 }, /* @__PURE__ */ React.createElement(Typography, { variant: "caption", className: classes.label }, "Documentation"), /* @__PURE__ */ React.createElement(Box, { mt: 1 }, product.spec.documentation.docsURL && /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, /* @__PURE__ */ React.createElement("strong", null, "Docs:"), " ", /* @__PURE__ */ React.createElement(Link, { to: product.spec.documentation.docsURL, target: "_blank" }, "View Documentation")), product.spec.documentation.openAPISpecURL && /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, /* @__PURE__ */ React.createElement("strong", null, "OpenAPI Spec:"), " ", /* @__PURE__ */ React.createElement(
|
|
76
|
+
Link,
|
|
77
|
+
{
|
|
78
|
+
to: product.spec.documentation.openAPISpecURL,
|
|
79
|
+
target: "_blank"
|
|
80
|
+
},
|
|
81
|
+
"View Spec"
|
|
82
|
+
))))));
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export { ApiProductDetails };
|
|
86
|
+
//# sourceMappingURL=ApiProductDetails.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiProductDetails.esm.js","sources":["../../../src/components/ApiProductDetails/ApiProductDetails.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n Box,\n Typography,\n Chip,\n makeStyles,\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableRow,\n Grid,\n} from \"@material-ui/core\";\nimport { Link } from \"@backstage/core-components\";\nimport { APIProduct, Plan } from \"../../types/api-management\";\n\nconst useStyles = makeStyles((theme) => ({\n label: {\n fontWeight: 600,\n color: theme.palette.text.secondary,\n marginBottom: theme.spacing(0.5),\n fontSize: \"0.75rem\",\n textTransform: \"uppercase\",\n },\n tierChip: {\n marginRight: theme.spacing(0.5),\n marginBottom: theme.spacing(0.5),\n },\n statusChipPublished: {\n backgroundColor: theme.palette.primary.main,\n color: theme.palette.primary.contrastText,\n },\n statusChipDraft: {\n backgroundColor: theme.palette.grey[600],\n color: theme.palette.common.white,\n },\n infoGrid: {\n display: \"grid\",\n gridTemplateColumns: \"repeat(auto-fill, minmax(180px, 1fr))\",\n gap: theme.spacing(3),\n marginBottom: theme.spacing(3),\n },\n infoItem: {\n minWidth: 0,\n },\n apiLink: {\n color: theme.palette.primary.main,\n textDecoration: \"none\",\n \"&:hover\": {\n textDecoration: \"underline\",\n },\n },\n}));\n\ninterface ApiProductDetailsProps {\n product: APIProduct;\n showStatus?: boolean;\n showCatalogLink?: boolean;\n}\n\nexport const ApiProductDetails = ({\n product,\n showStatus = true,\n showCatalogLink = true,\n}: ApiProductDetailsProps) => {\n const classes = useStyles();\n\n const publishStatus = product.spec?.publishStatus || \"Draft\";\n const isPublished = publishStatus === \"Published\";\n const tiers = product.status?.discoveredPlans || [];\n\n return (\n <>\n {product.spec?.description && (\n <Box mb={3}>\n <Typography variant=\"caption\" className={classes.label}>\n Description\n </Typography>\n <Typography variant=\"body1\">{product.spec.description}</Typography>\n </Box>\n )}\n\n <Box className={classes.infoGrid}>\n {showStatus && (\n <Box className={classes.infoItem}>\n <Typography variant=\"caption\" className={classes.label}>\n Status\n </Typography>\n <Box>\n <Chip\n label={publishStatus}\n size=\"small\"\n className={\n isPublished\n ? classes.statusChipPublished\n : classes.statusChipDraft\n }\n data-testid=\"publish-status-chip\"\n />\n </Box>\n </Box>\n )}\n <Box className={classes.infoItem}>\n <Typography variant=\"caption\" className={classes.label}>\n Version\n </Typography>\n <Typography variant=\"body2\">\n {product.spec?.version || \"v1\"}\n </Typography>\n </Box>\n <Box className={classes.infoItem}>\n <Typography variant=\"caption\" className={classes.label}>\n Namespace\n </Typography>\n <Typography variant=\"body2\">{product.metadata.namespace}</Typography>\n </Box>\n <Box className={classes.infoItem}>\n <Typography variant=\"caption\" className={classes.label}>\n API Key Approval\n </Typography>\n <Typography variant=\"body2\">\n {product.spec?.approvalMode === \"automatic\"\n ? \"Automatic\"\n : \"Need manual approval\"}\n </Typography>\n </Box>\n {product.spec?.tags && product.spec.tags.length > 0 && (\n <Box className={classes.infoItem}>\n <Typography variant=\"caption\" className={classes.label}>\n Tags\n </Typography>\n <Box>\n {product.spec.tags.map((tag) => (\n <Chip\n key={tag}\n label={tag}\n size=\"small\"\n variant=\"outlined\"\n className={classes.tierChip}\n />\n ))}\n </Box>\n </Box>\n )}\n </Box>\n\n <Box className={classes.infoGrid}>\n <Box className={classes.infoItem}>\n <Typography variant=\"caption\" className={classes.label}>\n API\n </Typography>\n <br />\n {showCatalogLink ? (\n <Link\n to={`/catalog/default/api/${product.metadata.name}`}\n className={classes.apiLink}\n >\n {product.metadata.name}\n </Link>\n ) : (\n <Typography variant=\"body2\">{product.metadata.name}</Typography>\n )}\n </Box>\n <Box className={classes.infoItem}>\n <Typography variant=\"caption\" className={classes.label}>\n Route\n </Typography>\n <Typography variant=\"body2\">\n {product.spec?.targetRef?.name || \"-\"}\n </Typography>\n </Box>\n </Box>\n\n {tiers.length > 0 && (\n <Box mb={3}>\n <Typography variant=\"caption\" className={classes.label}>\n Available Tiers\n </Typography>\n <Table size=\"small\">\n <TableHead>\n <TableRow>\n <TableCell>Tier</TableCell>\n <TableCell>Rate Limits</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {tiers.map((plan: Plan) => (\n <TableRow key={plan.tier}>\n <TableCell>\n <Chip label={plan.tier} size=\"small\" />\n </TableCell>\n <TableCell>\n {plan.limits &&\n Object.entries(plan.limits).map(([key, value]) => (\n <Typography key={key} variant=\"body2\">\n {String(value)} per {key}\n </Typography>\n ))}\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n </Box>\n )}\n\n <Grid container spacing={3}>\n {(product.spec?.contact?.email || product.spec?.contact?.team) && (\n <Grid item xs={12} md={6}>\n <Typography variant=\"caption\" className={classes.label}>\n Contact Information\n </Typography>\n <Box mt={1}>\n {product.spec.contact.team && (\n <Typography variant=\"body2\">\n <strong>Team:</strong> {product.spec.contact.team}\n </Typography>\n )}\n {product.spec.contact.email && (\n <Typography variant=\"body2\">\n <strong>Email:</strong>{\" \"}\n <Link to={`mailto:${product.spec.contact.email}`}>\n {product.spec.contact.email}\n </Link>\n </Typography>\n )}\n </Box>\n </Grid>\n )}\n\n {(product.spec?.documentation?.docsURL ||\n product.spec?.documentation?.openAPISpecURL) && (\n <Grid item xs={12} md={6}>\n <Typography variant=\"caption\" className={classes.label}>\n Documentation\n </Typography>\n <Box mt={1}>\n {product.spec.documentation.docsURL && (\n <Typography variant=\"body2\">\n <strong>Docs:</strong>{\" \"}\n <Link to={product.spec.documentation.docsURL} target=\"_blank\">\n View Documentation\n </Link>\n </Typography>\n )}\n {product.spec.documentation.openAPISpecURL && (\n <Typography variant=\"body2\">\n <strong>OpenAPI Spec:</strong>{\" \"}\n <Link\n to={product.spec.documentation.openAPISpecURL}\n target=\"_blank\"\n >\n View Spec\n </Link>\n </Typography>\n )}\n </Box>\n </Grid>\n )}\n </Grid>\n </>\n );\n};\n"],"names":[],"mappings":";;;;AAgBA,MAAM,SAAA,GAAY,UAAW,CAAA,CAAC,KAAW,MAAA;AAAA,EACvC,KAAO,EAAA;AAAA,IACL,UAAY,EAAA,GAAA;AAAA,IACZ,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA,SAAA;AAAA,IAC1B,YAAA,EAAc,KAAM,CAAA,OAAA,CAAQ,GAAG,CAAA;AAAA,IAC/B,QAAU,EAAA,SAAA;AAAA,IAC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AAA,IAAA,EAAA,EAAK,IAAI,EAAA,IAAA,EAAC,IAAI,EAAI,EAAA,EAAA,EAAI,CACrB,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,SAAU,EAAA,SAAA,EAAW,QAAQ,KAAO,EAAA,EAAA,eAExD,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,GAAI,EAAA,EAAA,EAAA,EAAI,CACN,EAAA,EAAA,OAAA,CAAQ,KAAK,aAAc,CAAA,OAAA,oBACzB,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,OAAQ,EAAA,OAAA,EAAA,kBACjB,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA,IAAA,EAAO,OAAK,CAAA,EAAU,GACvB,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,EAAA,EAAI,OAAQ,CAAA,IAAA,CAAK,cAAc,OAAS,EAAA,MAAA,EAAO,QAAS,EAAA,EAAA,oBAE9D,CACF,CAAA,EAED,OAAQ,CAAA,IAAA,CAAK,cAAc,cAC1B,oBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,OAClB,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,QAAO,EAAA,IAAA,EAAA,eAAa,GAAU,GAC/B,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,EAAA,EAAI,OAAQ,CAAA,IAAA,CAAK,aAAc,CAAA,cAAA;AAAA,MAC/B,MAAO,EAAA;AAAA,KAAA;AAAA,IACR;AAAA,GAGH,CAEJ,CACF,CAEJ,CACF,CAAA;AAEJ;;;;"}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useEntity } from '@backstage/plugin-catalog-react';
|
|
3
3
|
import { useApi, configApiRef, fetchApiRef, identityApiRef } from '@backstage/core-plugin-api';
|
|
4
|
-
import { InfoCard, Progress, ResponseErrorPanel
|
|
5
|
-
import { Typography, Box
|
|
4
|
+
import { InfoCard, Progress, ResponseErrorPanel } from '@backstage/core-components';
|
|
5
|
+
import { makeStyles, Typography, Box } from '@material-ui/core';
|
|
6
6
|
import useAsync from 'react-use/lib/useAsync';
|
|
7
7
|
import { useKuadrantPermission } from '../../utils/permissions.esm.js';
|
|
8
8
|
import { kuadrantApiProductReadAllPermission } from '../../permissions.esm.js';
|
|
9
|
+
import { ApiProductDetails } from '../ApiProductDetails/ApiProductDetails.esm.js';
|
|
9
10
|
|
|
11
|
+
const useStyles = makeStyles((theme) => ({
|
|
12
|
+
label: {
|
|
13
|
+
fontWeight: 600,
|
|
14
|
+
color: theme.palette.text.secondary,
|
|
15
|
+
marginBottom: theme.spacing(0.5),
|
|
16
|
+
fontSize: "0.75rem",
|
|
17
|
+
textTransform: "uppercase"
|
|
18
|
+
}
|
|
19
|
+
}));
|
|
10
20
|
const ApiProductInfoCard = () => {
|
|
21
|
+
const classes = useStyles();
|
|
11
22
|
const { entity } = useEntity();
|
|
12
23
|
const config = useApi(configApiRef);
|
|
13
24
|
const fetchApi = useApi(fetchApiRef);
|
|
@@ -26,14 +37,14 @@ const ApiProductInfoCard = () => {
|
|
|
26
37
|
if (!namespace || !apiProductName) {
|
|
27
38
|
return null;
|
|
28
39
|
}
|
|
29
|
-
const
|
|
40
|
+
const productResponse = await fetchApi.fetch(
|
|
30
41
|
`${backendUrl}/api/kuadrant/apiproducts/${namespace}/${apiProductName}`
|
|
31
42
|
);
|
|
32
|
-
if (!
|
|
33
|
-
const errorData = await
|
|
34
|
-
throw new Error(errorData.error || `Failed to fetch API product: ${
|
|
43
|
+
if (!productResponse.ok) {
|
|
44
|
+
const errorData = await productResponse.json();
|
|
45
|
+
throw new Error(errorData.error || `Failed to fetch API product: ${productResponse.status}`);
|
|
35
46
|
}
|
|
36
|
-
return
|
|
47
|
+
return productResponse.json();
|
|
37
48
|
}, [backendUrl, fetchApi, namespace, apiProductName]);
|
|
38
49
|
const owner = apiProduct?.metadata?.annotations?.["backstage.io/owner"];
|
|
39
50
|
const ownerUserId = owner?.split("/")[1];
|
|
@@ -56,44 +67,14 @@ const ApiProductInfoCard = () => {
|
|
|
56
67
|
if (!apiProduct) {
|
|
57
68
|
return /* @__PURE__ */ React.createElement(InfoCard, { title: "API Product Information" }, /* @__PURE__ */ React.createElement(Typography, null, "APIProduct not found"));
|
|
58
69
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const schemeObjects = Object.values(authSchemes);
|
|
62
|
-
const hasJwt = schemeObjects.some(
|
|
63
|
-
(scheme) => scheme.hasOwnProperty("jwt")
|
|
64
|
-
);
|
|
65
|
-
const jwtScheme = schemeObjects.find((scheme) => scheme.hasOwnProperty("jwt"));
|
|
66
|
-
const jwtIssuer = jwtScheme?.jwt?.issuerUrl || "unknown";
|
|
67
|
-
const jwtTokenEndpoint = status?.oidcDiscovery?.tokenEndpoint || "unknown";
|
|
68
|
-
const plans = status?.discoveredPlans || [];
|
|
69
|
-
return /* @__PURE__ */ React.createElement(Grid, { container: true, spacing: 3 }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(InfoCard, { title: "API Product Details" }, /* @__PURE__ */ React.createElement(Box, { p: 2 }, /* @__PURE__ */ React.createElement(Typography, { variant: "h6", gutterBottom: true }, spec.displayName || apiProductName), /* @__PURE__ */ React.createElement(Typography, { variant: "body2", color: "textSecondary", paragraph: true }, spec.description), /* @__PURE__ */ React.createElement(Box, { display: "flex", alignItems: "center", flexWrap: "wrap", style: { gap: 8 } }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, /* @__PURE__ */ React.createElement("strong", null, "Version:"), " ", spec.version || "v1"), spec.tags && spec.tags.length > 0 && /* @__PURE__ */ React.createElement(Box, { display: "flex", ml: 2, style: { gap: 4 } }, spec.tags.map((tag) => /* @__PURE__ */ React.createElement(Chip, { key: tag, label: tag, size: "small" })))), /* @__PURE__ */ React.createElement(Box, { mt: 2 }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2", component: "div" }, /* @__PURE__ */ React.createElement("strong", null, "Approval Mode:"), " ", /* @__PURE__ */ React.createElement(
|
|
70
|
-
Chip,
|
|
71
|
-
{
|
|
72
|
-
label: (spec.approvalMode || "manual") === "automatic" ? "Automatic" : "Manual",
|
|
73
|
-
size: "small",
|
|
74
|
-
color: (spec.approvalMode || "manual") === "automatic" ? "primary" : "default",
|
|
75
|
-
style: { marginLeft: 8 }
|
|
76
|
-
}
|
|
77
|
-
)), /* @__PURE__ */ React.createElement(Typography, { variant: "caption", color: "textSecondary", style: { marginTop: 4, display: "block" } }, (spec.approvalMode || "manual") === "automatic" ? "API keys are created immediately when requested" : "API keys require manual approval before creation"))))), plans.length > 0 && /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(InfoCard, { title: "Available Plans" }, /* @__PURE__ */ React.createElement(Table, { size: "small" }, /* @__PURE__ */ React.createElement(TableHead, null, /* @__PURE__ */ React.createElement(TableRow, null, /* @__PURE__ */ React.createElement(TableCell, null, "Tier"), /* @__PURE__ */ React.createElement(TableCell, null, "Rate Limits"))), /* @__PURE__ */ React.createElement(TableBody, null, plans.map((plan) => /* @__PURE__ */ React.createElement(TableRow, { key: plan.tier }, /* @__PURE__ */ React.createElement(TableCell, null, /* @__PURE__ */ React.createElement(
|
|
78
|
-
Chip,
|
|
79
|
-
{
|
|
80
|
-
label: plan.tier,
|
|
81
|
-
size: "small"
|
|
82
|
-
}
|
|
83
|
-
)), /* @__PURE__ */ React.createElement(TableCell, null, plan.limits && Object.entries(plan.limits).map(([key, value]) => /* @__PURE__ */ React.createElement(Typography, { key, variant: "body2" }, String(value), " per ", key))))))), spec.targetRef && /* @__PURE__ */ React.createElement(Box, { mt: 2 }, /* @__PURE__ */ React.createElement(Typography, { variant: "caption", color: "textSecondary" }, "HTTPRoute: ", /* @__PURE__ */ React.createElement("strong", null, spec.targetRef.name))))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, md: 6 }, /* @__PURE__ */ React.createElement(InfoCard, { title: "Contact Information" }, spec.contact ? /* @__PURE__ */ React.createElement(Box, { p: 2 }, /* @__PURE__ */ React.createElement(Grid, { container: true, spacing: 2 }, spec.contact.team && /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, /* @__PURE__ */ React.createElement("strong", null, "Team:"), " ", spec.contact.team)), spec.contact.email && /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, /* @__PURE__ */ React.createElement("strong", null, "Email:"), " ", /* @__PURE__ */ React.createElement(Link, { to: `mailto:${spec.contact.email}` }, spec.contact.email))), spec.contact.slack && /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, /* @__PURE__ */ React.createElement("strong", null, "Slack:"), " ", spec.contact.slack)))) : /* @__PURE__ */ React.createElement(Box, { p: 2 }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2", color: "textSecondary" }, "No contact information available")))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, md: 6 }, /* @__PURE__ */ React.createElement(InfoCard, { title: "Documentation" }, spec.documentation ? /* @__PURE__ */ React.createElement(Box, { p: 2 }, /* @__PURE__ */ React.createElement(Grid, { container: true, spacing: 2 }, spec.documentation.docsURL && /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, /* @__PURE__ */ React.createElement("strong", null, "Documentation:"), " ", /* @__PURE__ */ React.createElement(Link, { to: spec.documentation.docsURL, target: "_blank" }, "View Docs"))), spec.documentation.openAPISpec && /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, /* @__PURE__ */ React.createElement("strong", null, "OpenAPI Spec:"), " ", /* @__PURE__ */ React.createElement(Link, { to: spec.documentation.openAPISpec, target: "_blank" }, "View Spec"))))) : /* @__PURE__ */ React.createElement(Box, { p: 2 }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2", color: "textSecondary" }, "No documentation links available")))), hasJwt && /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, md: 6 }, /* @__PURE__ */ React.createElement(InfoCard, { title: "OIDC Provider Discovery" }, /* @__PURE__ */ React.createElement(Box, { p: 2 }, /* @__PURE__ */ React.createElement(Grid, { container: true, spacing: 2 }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, "This API uses OIDC authentication. Obtain a token from the identity provider below.")), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, /* @__PURE__ */ React.createElement("strong", null, "Identity Provider: "), /* @__PURE__ */ React.createElement(Link, { to: jwtIssuer, target: "_blank" }, jwtIssuer))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, /* @__PURE__ */ React.createElement("strong", null, "Token Endpoint: "), /* @__PURE__ */ React.createElement(Link, { to: jwtTokenEndpoint, target: "_blank" }, jwtTokenEndpoint))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(
|
|
84
|
-
CodeSnippet,
|
|
70
|
+
return /* @__PURE__ */ React.createElement(InfoCard, { title: "API Product Details" }, /* @__PURE__ */ React.createElement(Box, { mb: 2 }, /* @__PURE__ */ React.createElement(Typography, { variant: "caption", className: classes.label }, "Product Name"), /* @__PURE__ */ React.createElement(Typography, { variant: "h6" }, apiProduct.spec?.displayName || apiProductName)), /* @__PURE__ */ React.createElement(
|
|
71
|
+
ApiProductDetails,
|
|
85
72
|
{
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
-d "client_id=YOUR_CLIENT_ID" \\
|
|
90
|
-
-d "client_secret=YOUR_CLIENT_SECRET" \\
|
|
91
|
-
${jwtTokenEndpoint}
|
|
92
|
-
`,
|
|
93
|
-
language: "bash",
|
|
94
|
-
showCopyCodeButton: true
|
|
73
|
+
product: apiProduct,
|
|
74
|
+
showStatus: false,
|
|
75
|
+
showCatalogLink: false
|
|
95
76
|
}
|
|
96
|
-
))
|
|
77
|
+
));
|
|
97
78
|
};
|
|
98
79
|
|
|
99
80
|
export { ApiProductInfoCard };
|