From 6b6be0e1bc52f66d08d63589d150e2d2b737193a Mon Sep 17 00:00:00 2001 From: amvanbaren Date: Wed, 5 Jun 2024 16:41:42 +0300 Subject: [PATCH] Don't use nullish coalescing everywhere --- .../main/java/org/eclipse/openvsx/entities/Namespace.java | 2 +- .../main/java/org/eclipse/openvsx/json/ExtensionJson.java | 1 + .../org/eclipse/openvsx/json/NamespaceDetailsJson.java | 1 + webui/src/extension-registry-types.ts | 8 ++++---- webui/src/pages/extension-detail/extension-detail.tsx | 8 ++++---- webui/src/pages/namespace-detail/namespace-detail.tsx | 4 ++-- webui/src/pages/user/user-namespace-details.tsx | 2 +- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/server/src/main/java/org/eclipse/openvsx/entities/Namespace.java b/server/src/main/java/org/eclipse/openvsx/entities/Namespace.java index 8cb8ec764..b13803226 100644 --- a/server/src/main/java/org/eclipse/openvsx/entities/Namespace.java +++ b/server/src/main/java/org/eclipse/openvsx/entities/Namespace.java @@ -179,7 +179,7 @@ public void setMemberships(List memberships) { public NamespaceDetailsJson toNamespaceDetailsJson() { var details = new NamespaceDetailsJson(); details.name = name; - details.displayName = displayName; + details.displayName = StringUtils.isNotEmpty(displayName) ? displayName : name; details.description = description; details.website = website; details.supportLink = supportLink; diff --git a/server/src/main/java/org/eclipse/openvsx/json/ExtensionJson.java b/server/src/main/java/org/eclipse/openvsx/json/ExtensionJson.java index c21cc17f0..28931973d 100644 --- a/server/src/main/java/org/eclipse/openvsx/json/ExtensionJson.java +++ b/server/src/main/java/org/eclipse/openvsx/json/ExtensionJson.java @@ -120,6 +120,7 @@ public static ExtensionJson error(String message) { public String displayName; @Schema(description = "Namespace name to be displayed in user interfaces") + @NotNull public String namespaceDisplayName; public String description; diff --git a/server/src/main/java/org/eclipse/openvsx/json/NamespaceDetailsJson.java b/server/src/main/java/org/eclipse/openvsx/json/NamespaceDetailsJson.java index 701224a70..26678d7d6 100644 --- a/server/src/main/java/org/eclipse/openvsx/json/NamespaceDetailsJson.java +++ b/server/src/main/java/org/eclipse/openvsx/json/NamespaceDetailsJson.java @@ -28,6 +28,7 @@ public static NamespaceDetailsJson error(String message) { public String name; @Schema(description = "Display name of the namespace") + @NotNull public String displayName; @Schema(description = "Description of the namespace") diff --git a/webui/src/extension-registry-types.ts b/webui/src/extension-registry-types.ts index dfea85d06..fa045029a 100644 --- a/webui/src/extension-registry-types.ts +++ b/webui/src/extension-registry-types.ts @@ -86,7 +86,7 @@ export interface Extension { timestamp: TimestampString; preview?: boolean; displayName?: string; - namespaceDisplayName?: string; + namespaceDisplayName: string; description?: string; // key: engine, value: version constraint @@ -98,8 +98,8 @@ export interface Extension { repository?: string; bugs?: string; markdown?: 'github' | 'standard'; - galleryColor?: string; - galleryTheme?: 'light' | 'dark'; + galleryColor: string; + galleryTheme: 'light' | 'dark' | ''; qna?: UrlString | 'marketplace' | 'false'; badges?: Badge[]; dependencies?: ExtensionReference[]; @@ -216,7 +216,7 @@ export interface Namespace { export interface NamespaceDetails { name: string; - displayName?: string; + displayName: string; description?: string; logo?: UrlString; logoBytes?: string; diff --git a/webui/src/pages/extension-detail/extension-detail.tsx b/webui/src/pages/extension-detail/extension-detail.tsx index 1967b2003..8c4416203 100644 --- a/webui/src/pages/extension-detail/extension-detail.tsx +++ b/webui/src/pages/extension-detail/extension-detail.tsx @@ -216,12 +216,12 @@ export const ExtensionDetail: FunctionComponent = () => { const renderExtension = (extension: Extension): ReactNode => { const tab = versionPointsToTab(version) ? version as string : 'overview'; - const headerTheme = extension.galleryTheme ?? pageSettings.themeType ?? 'light'; + const headerTheme = (extension.galleryTheme || pageSettings.themeType) ?? 'light'; const headerColor = headerTheme === 'dark' ? '#fff' : '#151515'; return <> @@ -335,7 +335,7 @@ export const ExtensionDetail: FunctionComponent = () => { - {extension.namespaceDisplayName ?? extension.namespace} + {extension.namespaceDisplayName} @@ -449,7 +449,7 @@ export const ExtensionDetail: FunctionComponent = () => { href={extension.files.license} sx={{ color: themeColor }} title={extension.license ? 'License type' : undefined} > - {extension.license ?? 'Provided license'} + {extension.license || 'Provided license'} ; } else if (extension.license) { return extension.license; diff --git a/webui/src/pages/namespace-detail/namespace-detail.tsx b/webui/src/pages/namespace-detail/namespace-detail.tsx index 4287e6a1c..4094485ed 100644 --- a/webui/src/pages/namespace-detail/namespace-detail.tsx +++ b/webui/src/pages/namespace-detail/namespace-detail.tsx @@ -127,12 +127,12 @@ export const NamespaceDetail: FunctionComponent = () => { mr: { xs: 0, sm: 0, md: '2rem', lg: '2rem', xl: '2rem' }, pt: 1 }} - alt={namespaceDetails.displayName ?? namespaceDetails.name} /> + alt={namespaceDetails.displayName} /> - {namespaceDetails.displayName ?? namespaceDetails.name} + {namespaceDetails.displayName} { diff --git a/webui/src/pages/user/user-namespace-details.tsx b/webui/src/pages/user/user-namespace-details.tsx index 4f67b9c00..7502adb1b 100644 --- a/webui/src/pages/user/user-namespace-details.tsx +++ b/webui/src/pages/user/user-namespace-details.tsx @@ -188,7 +188,7 @@ export const UserNamespaceDetails: FunctionComponent setDetailsUpdated(true); setCurrentDetails(copy(details)); - setBannerNamespaceName(details.displayName ?? details.name); + setBannerNamespaceName(details.displayName || details.name); } catch (err) { context.handleError(err); } finally {