Skip to content

Commit

Permalink
feat: Update capitalizeFirstLetter function to handle optional string…
Browse files Browse the repository at this point in the history
… input and improve app key display in portal apps
  • Loading branch information
Noggling committed Dec 17, 2024
1 parent a78e9e5 commit 59d40b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const defaultGridOptions: GridOptions = {

export const bottomPadding = 70;

export function capitalizeFirstLetter(str: string) {
export function capitalizeFirstLetter(str?: string) {
if (!str) return ''; // Handle empty string
return str.charAt(0).toUpperCase() + str.slice(1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { CustomCellRendererProps } from '@ag-grid-community/react';

import { AgStyles } from '../AgStyle';
import { ColDef } from '@equinor/workspace-ag-grid';

const FAIL_MESSAGE = 'Application Error!';
import { capitalizeFirstLetter } from '../Ag-Grid/defaultGridOptions';

export const colDefs: ColDef<any, any>[] = [
{
Expand Down Expand Up @@ -65,11 +64,14 @@ export const colDefs: ColDef<any, any>[] = [
cellRenderer: (
params: CustomCellRendererProps<{
appManifest?: { displayName: string };
appKey: string;
}>
) => {
return (
<AgStyles.TextCellWrapperLeft key={`active-${params.context?.appKey}`}>
{params.data?.appManifest ? params.data?.appManifest.displayName : FAIL_MESSAGE}
{params.data?.appManifest
? params.data?.appManifest.displayName
: capitalizeFirstLetter(params.data?.appKey)}
</AgStyles.TextCellWrapperLeft>
);
},
Expand All @@ -93,20 +95,6 @@ export const colDefs: ColDef<any, any>[] = [
filterOptions: ['contains', 'startsWith', 'endsWith'],
defaultOption: 'startsWith',
},
cellRenderer: (
params: CustomCellRendererProps<{
appManifest?: { category: { displayName: string } };
doesNotExistInFusion: boolean;
}>
) => {
return (
<AgStyles.TextCellWrapperLeft key={`active-${params.context?.appKey}`}>
{params.data?.doesNotExistInFusion === false
? params.data?.appManifest?.category.displayName
: FAIL_MESSAGE}
</AgStyles.TextCellWrapperLeft>
);
},
},
{
field: 'appManifest.build.version',
Expand Down

0 comments on commit 59d40b8

Please sign in to comment.