Skip to content

Commit

Permalink
Merge pull request #933 from amvanbaren/fix-null-coalesce
Browse files Browse the repository at this point in the history
Don't use nullish coalescing everywhere
  • Loading branch information
amvanbaren authored Jun 5, 2024
2 parents 2d1b280 + 6b6be0e commit 7e3cad2
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public void setMemberships(List<NamespaceMembership> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions webui/src/extension-registry-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export interface Extension {
timestamp: TimestampString;
preview?: boolean;
displayName?: string;
namespaceDisplayName?: string;
namespaceDisplayName: string;
description?: string;

// key: engine, value: version constraint
Expand All @@ -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[];
Expand Down Expand Up @@ -216,7 +216,7 @@ export interface Namespace {

export interface NamespaceDetails {
name: string;
displayName?: string;
displayName: string;
description?: string;
logo?: UrlString;
logoBytes?: string;
Expand Down
8 changes: 4 additions & 4 deletions webui/src/pages/extension-detail/extension-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <>
<Box
sx={{
bgcolor: extension.galleryColor ?? 'neutral.dark',
bgcolor: extension.galleryColor || 'neutral.dark',
color: headerColor
}}
>
Expand Down Expand Up @@ -335,7 +335,7 @@ export const ExtensionDetail: FunctionComponent = () => {
<StyledRouteLink
to={createRoute([NamespaceDetailRoutes.ROOT, extension.namespace])}
style={{ color: themeColor }}>
{extension.namespaceDisplayName ?? extension.namespace}
{extension.namespaceDisplayName}
</StyledRouteLink>
</Box>
<TextDivider themeType={themeType} collapseSmall={true} />
Expand Down Expand Up @@ -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'}
</StyledLink>;
} else if (extension.license) {
return extension.license;
Expand Down
4 changes: 2 additions & 2 deletions webui/src/pages/namespace-detail/namespace-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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} />
</Grid>
<Grid item xs={7}>
<Grid container spacing={2}>
<Grid item xs={12}>
<Typography variant='h5'>{namespaceDetails.displayName ?? namespaceDetails.name}</Typography>
<Typography variant='h5'>{namespaceDetails.displayName}</Typography>
</Grid>
<Grid item xs={12} sx={{ pr: '0 !important' }}>
{
Expand Down
2 changes: 1 addition & 1 deletion webui/src/pages/user/user-namespace-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export const UserNamespaceDetails: FunctionComponent<UserNamespaceDetailsProps>

setDetailsUpdated(true);
setCurrentDetails(copy(details));
setBannerNamespaceName(details.displayName ?? details.name);
setBannerNamespaceName(details.displayName || details.name);
} catch (err) {
context.handleError(err);
} finally {
Expand Down

0 comments on commit 7e3cad2

Please sign in to comment.