From 9d3c6c5c5765b66c6846a30e9ebb26870c5edb42 Mon Sep 17 00:00:00 2001 From: Hubert Date: Tue, 15 Apr 2025 09:45:13 +0200 Subject: [PATCH 1/2] first part of linter issues --- .../ControlPlane/MCPHealthPopoverButton.tsx | 4 +--- .../List/ControlPlaneListAllWorkspaces.tsx | 2 +- .../List/ControlPlaneListWorkspaceGridTile.tsx | 5 +++-- .../ControlPlanes/List/MembersAvatarView.tsx | 15 +-------------- src/components/Core/ShellBar.tsx | 2 +- .../Controllers/KubectlDeleteWorkspace.tsx | 2 +- .../KubectlCommandInfo/KubectlBaseDialog.tsx | 2 +- .../KubectlCommandInfo/KubectlTerminal.tsx | 4 ++-- src/components/Helper/GenerateInitialsForEmail.ts | 13 +++++++++++++ src/utils/index.ts | 1 - src/utils/testing.ts | 4 ++-- 11 files changed, 26 insertions(+), 28 deletions(-) create mode 100644 src/components/Helper/GenerateInitialsForEmail.ts diff --git a/src/components/ControlPlane/MCPHealthPopoverButton.tsx b/src/components/ControlPlane/MCPHealthPopoverButton.tsx index 35466b0b..3ce79ea8 100644 --- a/src/components/ControlPlane/MCPHealthPopoverButton.tsx +++ b/src/components/ControlPlane/MCPHealthPopoverButton.tsx @@ -101,9 +101,7 @@ function StatusTable({ ); } -export function getIconForOverallStatus( - status: ReadyStatus | undefined, -): JSX.Element { +function getIconForOverallStatus(status: ReadyStatus | undefined): JSX.Element { switch (status) { case ReadyStatus.Ready: return ; diff --git a/src/components/ControlPlanes/List/ControlPlaneListAllWorkspaces.tsx b/src/components/ControlPlanes/List/ControlPlaneListAllWorkspaces.tsx index 3d95a754..c9250c62 100644 --- a/src/components/ControlPlanes/List/ControlPlaneListAllWorkspaces.tsx +++ b/src/components/ControlPlanes/List/ControlPlaneListAllWorkspaces.tsx @@ -6,7 +6,7 @@ import '@ui5/webcomponents-icons/dist/delete'; import Loading from '../../Shared/Loading.tsx'; import ButtonDesign from '@ui5/webcomponents/dist/types/ButtonDesign.js'; import { ControlPlaneListWorkspaceGridTile } from './ControlPlaneListWorkspaceGridTile.tsx'; -import useApiResource from '../../../lib/api/useApiResource.ts'; +import { useApiResource } from '../../../lib/api/useApiResource.ts'; import { ListWorkspaces } from '../../../lib/api/types/crate/listWorkspaces.ts'; import { useFrontendConfig } from '../../../context/FrontendConfigContext.tsx'; import { useTranslation } from 'react-i18next'; diff --git a/src/components/ControlPlanes/List/ControlPlaneListWorkspaceGridTile.tsx b/src/components/ControlPlanes/List/ControlPlaneListWorkspaceGridTile.tsx index e2e37fb3..1a5778a2 100644 --- a/src/components/ControlPlanes/List/ControlPlaneListWorkspaceGridTile.tsx +++ b/src/components/ControlPlanes/List/ControlPlaneListWorkspaceGridTile.tsx @@ -22,8 +22,9 @@ import { DeleteWorkspaceResource, DeleteWorkspaceType, } from '../../../lib/api/types/crate/deleteWorkspace.ts'; -import useApiResource, { +import { useApiResourceMutation, + useApiResource, } from '../../../lib/api/useApiResource.ts'; import { DISPLAY_NAME_ANNOTATION } from '../../../lib/api/types/shared/keyNames.ts'; import { DeleteConfirmationDialog } from '../../Dialogs/DeleteConfirmationDialog.tsx'; @@ -64,7 +65,7 @@ export function ControlPlaneListWorkspaceGridTile({ function createErrorView(error: APIError) { if (error) { - if (error.status == 403) { + if (error.status === 403) { return ( ); } - -export function generateInitialsForEmail(email: string | undefined): string { - if (!email) { - return ''; - } - const [name, _] = email.split('@'); - const nameParts = name.split('.'); - // return the first letter of each part of the name up to 3 characters - return nameParts - .map((part) => part[0]) - .join('') - .substring(0, 3) - .toUpperCase(); -} diff --git a/src/components/Core/ShellBar.tsx b/src/components/Core/ShellBar.tsx index f20666de..e8912880 100644 --- a/src/components/Core/ShellBar.tsx +++ b/src/components/Core/ShellBar.tsx @@ -8,12 +8,12 @@ import { ShellBarDomRef, Ui5CustomEvent, } from '@ui5/webcomponents-react'; -import { generateInitialsForEmail } from '../ControlPlanes/List/MembersAvatarView.tsx'; import { useAuth } from 'react-oidc-context'; import { RefObject, useRef, useState } from 'react'; import { ShellBarProfileClickEventDetail } from '@ui5/webcomponents-fiori/dist/ShellBar.js'; import PopoverPlacement from '@ui5/webcomponents/dist/types/PopoverPlacement.js'; import { useTranslation } from 'react-i18next'; +import { generateInitialsForEmail } from '../Helper/GenerateInitialsForEmail'; export function ShellBarComponent() { const auth = useAuth(); diff --git a/src/components/Dialogs/KubectlCommandInfo/Controllers/KubectlDeleteWorkspace.tsx b/src/components/Dialogs/KubectlCommandInfo/Controllers/KubectlDeleteWorkspace.tsx index d4636ffa..fb7ae92c 100644 --- a/src/components/Dialogs/KubectlCommandInfo/Controllers/KubectlDeleteWorkspace.tsx +++ b/src/components/Dialogs/KubectlCommandInfo/Controllers/KubectlDeleteWorkspace.tsx @@ -27,4 +27,4 @@ export const KubectlDeleteWorkspace = ({ /> ); -}; \ No newline at end of file +}; diff --git a/src/components/Dialogs/KubectlCommandInfo/KubectlBaseDialog.tsx b/src/components/Dialogs/KubectlCommandInfo/KubectlBaseDialog.tsx index c99cc3c4..7ef6cbc9 100644 --- a/src/components/Dialogs/KubectlCommandInfo/KubectlBaseDialog.tsx +++ b/src/components/Dialogs/KubectlCommandInfo/KubectlBaseDialog.tsx @@ -54,7 +54,7 @@ export const KubectlBaseDialog = ({ initialValues[field.id] = field.defaultValue; }); setFormValues(initialValues); - }, []); + }, [formFields]); const handleFieldChange = (fieldId: string) => (event: Ui5CustomEvent) => { diff --git a/src/components/Dialogs/KubectlCommandInfo/KubectlTerminal.tsx b/src/components/Dialogs/KubectlCommandInfo/KubectlTerminal.tsx index 54e4f547..d74ac873 100644 --- a/src/components/Dialogs/KubectlCommandInfo/KubectlTerminal.tsx +++ b/src/components/Dialogs/KubectlCommandInfo/KubectlTerminal.tsx @@ -38,9 +38,9 @@ export const KubectlTerminal = ({ command }: KubeCtlTerminalProps) => { return ( <> - echo ' + echo '
{yamlLines}
- ' | {kubectlPart} + ' | {kubectlPart} ); } diff --git a/src/components/Helper/GenerateInitialsForEmail.ts b/src/components/Helper/GenerateInitialsForEmail.ts new file mode 100644 index 00000000..b8c193c8 --- /dev/null +++ b/src/components/Helper/GenerateInitialsForEmail.ts @@ -0,0 +1,13 @@ +export function generateInitialsForEmail(email: string | undefined): string { + if (!email) { + return ''; + } + const [name, _] = email.split('@'); + const nameParts = name.split('.'); + // return the first letter of each part of the name up to 3 characters + return nameParts + .map((part) => part[0]) + .join('') + .substring(0, 3) + .toUpperCase(); +} diff --git a/src/utils/index.ts b/src/utils/index.ts index 8dc63d58..434cba47 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -10,4 +10,3 @@ export const extractWorkspaceNameFromNamespace = (namespace: string) => { export const projectnameToNamespace = (projectname: string) => { return `project-${projectname}`; }; - diff --git a/src/utils/testing.ts b/src/utils/testing.ts index b191d422..fbced788 100644 --- a/src/utils/testing.ts +++ b/src/utils/testing.ts @@ -1,11 +1,11 @@ import { DocLinkCreator } from '../lib/shared/links.ts'; import { Landscape } from '../context/FrontendConfigContext.tsx'; -export const isInTestingMode: Boolean = !!window.Cypress; +export const isInTestingMode: boolean = !!window.Cypress; const documentationBaseUrl = 'http://localhost:3000'; export const mockedFrontendConfig = { backendUrl: 'http://localhost:3000', landscape: Landscape.Local, documentationBaseUrl: 'http://localhost:3000', links: new DocLinkCreator(documentationBaseUrl), -}; \ No newline at end of file +}; From 884b0b2ed9a23e78f37094e7aa628ef08cfdebda Mon Sep 17 00:00:00 2001 From: Hubert Date: Tue, 15 Apr 2025 09:58:29 +0200 Subject: [PATCH 2/2] adding auto fixable issues --- .../Dialogs/KubectlCommandInfo/KubectlBaseDialog.tsx | 2 +- src/components/Shared/ConfiguredAnalyticsTable.tsx | 2 +- src/context/FrontendConfigContext.tsx | 10 +++++----- src/types/__generated__/graphql/index.ts | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/Dialogs/KubectlCommandInfo/KubectlBaseDialog.tsx b/src/components/Dialogs/KubectlCommandInfo/KubectlBaseDialog.tsx index 7ef6cbc9..c99cc3c4 100644 --- a/src/components/Dialogs/KubectlCommandInfo/KubectlBaseDialog.tsx +++ b/src/components/Dialogs/KubectlCommandInfo/KubectlBaseDialog.tsx @@ -54,7 +54,7 @@ export const KubectlBaseDialog = ({ initialValues[field.id] = field.defaultValue; }); setFormValues(initialValues); - }, [formFields]); + }, []); const handleFieldChange = (fieldId: string) => (event: Ui5CustomEvent) => { diff --git a/src/components/Shared/ConfiguredAnalyticsTable.tsx b/src/components/Shared/ConfiguredAnalyticsTable.tsx index 84e19961..b9e9fcc3 100644 --- a/src/components/Shared/ConfiguredAnalyticsTable.tsx +++ b/src/components/Shared/ConfiguredAnalyticsTable.tsx @@ -23,7 +23,7 @@ export default function ConfiguredAnalyticsTable(props: Props) { scaleWidthMode={AnalyticalTableScaleWidthMode.Smart} loading={props.isLoading} filterable - style={{margin: "12px"}} + style={{ margin: '12px' }} /> ); } diff --git a/src/context/FrontendConfigContext.tsx b/src/context/FrontendConfigContext.tsx index 37ce09bc..bdfd94df 100644 --- a/src/context/FrontendConfigContext.tsx +++ b/src/context/FrontendConfigContext.tsx @@ -17,10 +17,8 @@ interface FrontendConfigContextProps { links: DocLinkCreator; } -export const FrontendConfigContext = createContext( - null, -); - +export const FrontendConfigContext = + createContext(null); const fetchPromise = fetch('/frontend-config.json').then((res) => res.json()); @@ -28,7 +26,9 @@ interface FrontendConfigProviderProps { children: ReactNode; } -export function FrontendConfigProvider({ children }: FrontendConfigProviderProps) { +export function FrontendConfigProvider({ + children, +}: FrontendConfigProviderProps) { const config = use(fetchPromise); const docLinks = new DocLinkCreator(config.documentationBaseUrl); const value: FrontendConfigContextProps = { diff --git a/src/types/__generated__/graphql/index.ts b/src/types/__generated__/graphql/index.ts index f5159916..c682b1e2 100644 --- a/src/types/__generated__/graphql/index.ts +++ b/src/types/__generated__/graphql/index.ts @@ -1,2 +1,2 @@ -export * from "./fragment-masking"; -export * from "./gql"; \ No newline at end of file +export * from './fragment-masking'; +export * from './gql';