Skip to content

Commit 18f253f

Browse files
authored
[dashboard] Update openapi-ui v1.0.3 + fixes (#1564)
Signed-off-by: Andrei Kvapil <[email protected]> <!-- Thank you for making a contribution! Here are some tips for you: - Start the PR title with the [label] of Cozystack component: - For system components: [platform], [system], [linstor], [cilium], [kube-ovn], [dashboard], [cluster-api], etc. - For managed apps: [apps], [tenant], [kubernetes], [postgres], [virtual-machine] etc. - For development and maintenance: [tests], [ci], [docs], [maintenance]. - If it's a work in progress, consider creating this PR as a draft. - Don't hesistate to ask for opinion and review in the community chats, even if it's still a draft. - Add the label `backport` if it's a bugfix that needs to be backported to a previous version. --> ## What this PR does - Update openapi-ui to v1.0.3 - Show YAML editor as readonly in YAML tab - Remove inside link from user menu - fix editing for tenantmodules, fixes #1550 - fix editing valuesOverride, fixes #1560 ### Release note <!-- Write a release note: - Explain what has changed internally and for users. - Start with the same [label] as in the PR title - Follow the guidelines at https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md. --> ```release-note [dashboard] Update openapi-ui v1.0.3 + fixes ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Made YAML editor read-only to prevent accidental modifications in details view * Fixed API request header handling to prevent stream abort issues * Updated resource API endpoint paths for correct data retrieval * Removed menu navigation item from user interface <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents 8f5adcc + bd9dcb5 commit 18f253f

9 files changed

Lines changed: 86 additions & 14 deletions

File tree

‎internal/controller/dashboard/factory.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ func yamlTab(plural string) map[string]any {
324324
"type": "builtin",
325325
"typeName": plural,
326326
"prefillValuesRequestIndex": float64(0),
327+
"readOnly": true,
327328
"substractHeight": float64(400),
328329
},
329330
},

‎internal/controller/dashboard/static_refactored.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ func CreateAllFactories() []*dashboardv1alpha1.Factory {
796796
"substractHeight": float64(400),
797797
"type": "builtin",
798798
"typeName": "secrets",
799+
"readOnly": true,
799800
},
800801
},
801802
},

‎packages/system/dashboard/images/openapi-ui-k8s-bff/Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ FROM node:${NODE_VERSION}-alpine AS builder
44
RUN apk add git
55
WORKDIR /src
66

7-
ARG COMMIT_REF=22f9143f5109fb90332651c857d70b51bffccd9b
7+
ARG COMMIT_REF=88531ed6881b4ce4808e56c00905951d7ba8031c
88
RUN wget -O- https://github.com/PRO-Robotech/openapi-ui-k8s-bff/archive/${COMMIT_REF}.tar.gz | tar xzf - --strip-components=1
99

1010
COPY patches /patches

‎packages/system/dashboard/images/openapi-ui-k8s-bff/patches/namespaces.diff‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
diff --git a/src/endpoints/forms/formPrepare/formPrepare.ts b/src/endpoints/forms/formPrepare/formPrepare.ts
1+
diff --git a/src/endpoints/forms/prepareFormProps/prepareFormProps.ts b/src/endpoints/forms/prepareFormProps/prepareFormProps.ts
22
index 7e437db..90c40f6 100644
3-
--- a/src/endpoints/forms/formPrepare/formPrepare.ts
4-
+++ b/src/endpoints/forms/formPrepare/formPrepare.ts
3+
--- a/src/endpoints/forms/prepareFormProps/prepareFormProps.ts
4+
+++ b/src/endpoints/forms/prepareFormProps/prepareFormProps.ts
55
@@ -15,6 +15,7 @@ export const prepareFormProps: RequestHandler = async (req: TPrepareFormReq, res
66

77
const filteredHeaders = { ...req.headers }

‎packages/system/dashboard/images/openapi-ui/Dockerfile‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ ARG NODE_VERSION=20.18.1
33
# openapi-k8s-toolkit
44
# imported from https://github.com/cozystack/openapi-k8s-toolkit
55
FROM node:${NODE_VERSION}-alpine AS openapi-k8s-toolkit-builder
6+
RUN apk add git
67
WORKDIR /src
7-
ARG COMMIT=4f57ab295b2a886eb294b0b987554194fbe67dcd
8+
ARG COMMIT=e5f16b45de19f892de269cc4ef27e74aa62f4c92
89
RUN wget -O- https://github.com/cozystack/openapi-k8s-toolkit/archive/${COMMIT}.tar.gz | tar -xzvf- --strip-components=1
10+
11+
COPY openapi-k8s-toolkit/patches /patches
12+
RUN git apply /patches/*.diff
13+
914
RUN npm install
1015
RUN npm install --build-from-source @swc/core
1116
RUN npm run build
@@ -17,10 +22,10 @@ FROM node:${NODE_VERSION}-alpine AS builder
1722
RUN apk add git
1823
WORKDIR /src
1924

20-
ARG COMMIT_REF=65e7fa8b3dc530a36e94c8435622bb09961aef97
25+
ARG COMMIT_REF=9ce4367657f49c0032d8016b1d9491f8abbd2b15
2126
RUN wget -O- https://github.com/PRO-Robotech/openapi-ui/archive/${COMMIT_REF}.tar.gz | tar xzf - --strip-components=1
2227

23-
COPY patches /patches
28+
COPY openapi-ui/patches /patches
2429
RUN git apply /patches/*.diff
2530

2631
ENV PATH=/src/node_modules/.bin:$PATH
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
diff --git a/src/components/molecules/EnrichedTable/organisms/EnrichedTable/utils.tsx b/src/components/molecules/EnrichedTable/organisms/EnrichedTable/utils.tsx
2+
index 8bcef4d..2551e92 100644
3+
--- a/src/components/molecules/EnrichedTable/organisms/EnrichedTable/utils.tsx
4+
+++ b/src/components/molecules/EnrichedTable/organisms/EnrichedTable/utils.tsx
5+
@@ -22,6 +22,15 @@ import { TableFactory } from '../../molecules'
6+
import { ShortenedTextWithTooltip, FilterDropdown, TrimmedTags, TextAlignContainer, TinyButton } from './atoms'
7+
import { TInternalDataForControls } from './types'
8+
9+
+const getPluralForm = (singular: string): string => {
10+
+ // If already ends with 's', add 'es'
11+
+ if (singular.endsWith('s')) {
12+
+ return `${singular}es`
13+
+ }
14+
+ // Otherwise just add 's'
15+
+ return `${singular}s`
16+
+}
17+
+
18+
export const getCellRender = ({
19+
value,
20+
record,
21+
@@ -255,7 +264,7 @@ export const getEnrichedColumnsWithControls = ({
22+
key: 'controls',
23+
className: 'controls',
24+
width: 60,
25+
- render: (value: TInternalDataForControls) => {
26+
+ render: (value: TInternalDataForControls, record: unknown) => {
27+
return (
28+
// <TextAlignContainer $align="right" className="hideable">
29+
<TextAlignContainer $align="center">
30+
@@ -279,10 +288,19 @@ export const getEnrichedColumnsWithControls = ({
31+
domEvent.stopPropagation()
32+
domEvent.preventDefault()
33+
if (key === 'edit') {
34+
+ // Special case: redirect tenantmodules from core.cozystack.io to apps.cozystack.io with plural form
35+
+ let apiGroupAndVersion = value.apiGroupAndVersion
36+
+ let typeName = value.typeName
37+
+ if (apiGroupAndVersion?.startsWith('core.cozystack.io/') && typeName === 'tenantmodules') {
38+
+ const appsApiVersion = apiGroupAndVersion.replace('core.cozystack.io/', 'apps.cozystack.io/')
39+
+ const pluralTypeName = getPluralForm(value.entryName)
40+
+ apiGroupAndVersion = appsApiVersion
41+
+ typeName = pluralTypeName
42+
+ }
43+
navigate(
44+
`${baseprefix}/${value.cluster}${value.namespace ? `/${value.namespace}` : ''}${
45+
value.syntheticProject ? `/${value.syntheticProject}` : ''
46+
- }/${value.pathPrefix}/${value.apiGroupAndVersion}/${value.typeName}/${value.entryName}?backlink=${
47+
+ }/${value.pathPrefix}/${apiGroupAndVersion}/${typeName}/${value.entryName}?backlink=${
48+
value.backlink
49+
}`,
50+
)

packages/system/dashboard/images/openapi-ui/patches/namespaces.diff renamed to packages/system/dashboard/images/openapi-ui/openapi-ui/patches/namespaces.diff

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/src/components/organisms/ListInsideClusterAndNs/ListInsideClusterAndNs.tsx b/src/components/organisms/ListInsideClusterAndNs/ListInsideClusterAndNs.tsx
2-
index 577ba0f..018df9c 100644
2+
index b6fb99f..965bac0 100644
33
--- a/src/components/organisms/ListInsideClusterAndNs/ListInsideClusterAndNs.tsx
44
+++ b/src/components/organisms/ListInsideClusterAndNs/ListInsideClusterAndNs.tsx
55
@@ -1,11 +1,16 @@
@@ -26,16 +26,16 @@ index 577ba0f..018df9c 100644
2626

2727
- const namespacesData = useBuiltinResources({
2828
+ const namespacesData = useApiResources({
29-
clusterName: cluster,
29+
clusterName: selectedCluster || '',
3030
- typeName: 'namespaces',
3131
+ apiGroup: BASE_PROJECTS_API_GROUP,
3232
+ apiVersion: BASE_PROJECTS_VERSION,
3333
+ typeName: BASE_PROJECTS_RESOURCE_NAME,
3434
limit: null,
35+
isEnabled: selectedCluster !== undefined,
3536
})
36-
3737
diff --git a/src/hooks/useNavSelectorInside.ts b/src/hooks/useNavSelectorInside.ts
38-
index d69405e..5adbd5d 100644
38+
index 5736e2b..1ec0f71 100644
3939
--- a/src/hooks/useNavSelectorInside.ts
4040
+++ b/src/hooks/useNavSelectorInside.ts
4141
@@ -1,6 +1,11 @@
@@ -63,8 +63,8 @@ index d69405e..5adbd5d 100644
6363
+ apiVersion: BASE_PROJECTS_VERSION,
6464
+ typeName: BASE_PROJECTS_RESOURCE_NAME,
6565
limit: null,
66+
isEnabled: Boolean(clusterName),
6667
})
67-
6868
diff --git a/src/utils/getBacklink.ts b/src/utils/getBacklink.ts
6969
index a862354..f24e2bc 100644
7070
--- a/src/utils/getBacklink.ts
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/src/components/organisms/Header/organisms/User/User.tsx b/src/components/organisms/Header/organisms/User/User.tsx
2+
index efe7ac3..80b715c 100644
3+
--- a/src/components/organisms/Header/organisms/User/User.tsx
4+
+++ b/src/components/organisms/Header/organisms/User/User.tsx
5+
@@ -23,10 +23,6 @@ export const User: FC = () => {
6+
// key: '1',
7+
// label: <ThemeSelector />,
8+
// },
9+
- {
10+
- key: '2',
11+
- label: <div onClick={() => navigate(`${baseprefix}/inside/clusters`)}>Inside</div>,
12+
- },
13+
{
14+
key: '3',
15+
label: (
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
openapiUI:
2-
image: ghcr.io/cozystack/cozystack/openapi-ui:v0.37.0@sha256:13f38cf56830e899eb5e3d9dc8184965dd8dba9f8cd3c5ca10df0970355842d6
2+
image: ghcr.io/cozystack/cozystack/openapi-ui:latest@sha256:dfd3227aec5944e303a96f8e3197ac37a6b6bd7994ddbd681b7d5827bd621f4b
33
openapiUIK8sBff:
4-
image: ghcr.io/cozystack/cozystack/openapi-ui-k8s-bff:v0.37.0@sha256:2b626dbbf87241e8621ac5b0285f402edbc2c2069ba254ca2ace2dd5c9248ac8
4+
image: ghcr.io/cozystack/cozystack/openapi-ui-k8s-bff:latest@sha256:d2200791865a84640722079f2a3194af0c67d83c27c1bd303215183450265485
55
tokenProxy:
66
image: ghcr.io/cozystack/cozystack/token-proxy:v0.37.0@sha256:fad27112617bb17816702571e1f39d0ac3fe5283468d25eb12f79906cdab566b

0 commit comments

Comments
 (0)