Skip to content

Commit

Permalink
fix: Component crash, tekton 404 pages (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
callmevladik committed Nov 20, 2024
1 parent 2b7a86d commit 5055cc5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ export const DynamicDataContextProvider: React.FC = ({ children }) => {
labelSelector: `${CODEBASE_BRANCH_LABEL_SELECTOR_CODEBASE_NAME}=${name}`,
});

const sortedCodebaseBranches = codebaseBranches?.sort((a) =>
isDefaultBranch(component, a) ? -1 : 1
);
const sortedCodebaseBranches =
component === null
? null
: codebaseBranches?.sort((a) => (isDefaultBranch(component, a) ? -1 : 1));

const DataContextValue = React.useMemo(
() => ({
Expand Down
19 changes: 14 additions & 5 deletions src/pages/configuration/pages/pipeline-details/view.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { useParams } from 'react-router-dom';
import { ErrorContent } from '../../../../components/ErrorContent';
import { LoadingWrapper } from '../../../../components/LoadingWrapper';
import { PageWrapper } from '../../../../components/PageWrapper';
import { Section } from '../../../../components/Section';
Expand All @@ -18,6 +19,18 @@ export const PageView = () => {

const { activeTab, handleChangeTab } = useTabsContext();

const renderPageContent = React.useCallback(() => {
if (error) {
return <ErrorContent error={error} />;
}

return (
<LoadingWrapper isLoading={item === null}>
<Tabs tabs={tabs} activeTabIdx={activeTab} handleChangeTab={handleChangeTab} />
</LoadingWrapper>
);
}, [activeTab, error, handleChangeTab, item, tabs]);

return (
<PageWrapper
containerMaxWidth={'xl'}
Expand All @@ -33,11 +46,7 @@ export const PageView = () => {
},
]}
>
<Section title={name}>
<LoadingWrapper isLoading={item === null && !error}>
<Tabs tabs={tabs} activeTabIdx={activeTab} handleChangeTab={handleChangeTab} />
</LoadingWrapper>
</Section>
<Section title={name}>{renderPageContent()}</Section>
</PageWrapper>
);
};
19 changes: 14 additions & 5 deletions src/pages/configuration/pages/task-details/view.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { useParams } from 'react-router-dom';
import { ErrorContent } from '../../../../components/ErrorContent';
import { LoadingWrapper } from '../../../../components/LoadingWrapper';
import { PageWrapper } from '../../../../components/PageWrapper';
import { Section } from '../../../../components/Section';
Expand All @@ -17,6 +18,18 @@ export const PageView = () => {
const tabs = useTabs({ task: item });
const { activeTab, handleChangeTab } = useTabsContext();

const renderPageContent = React.useCallback(() => {
if (error) {
return <ErrorContent error={error} />;
}

return (
<LoadingWrapper isLoading={item === null}>
<Tabs tabs={tabs} activeTabIdx={activeTab} handleChangeTab={handleChangeTab} />
</LoadingWrapper>
);
}, [activeTab, error, handleChangeTab, item, tabs]);

return (
<PageWrapper
containerMaxWidth={'xl'}
Expand All @@ -32,11 +45,7 @@ export const PageView = () => {
},
]}
>
<Section title={name}>
<LoadingWrapper isLoading={item === null && !error}>
<Tabs tabs={tabs} activeTabIdx={activeTab} handleChangeTab={handleChangeTab} />
</LoadingWrapper>
</Section>
<Section title={name}>{renderPageContent()}</Section>
</PageWrapper>
);
};

0 comments on commit 5055cc5

Please sign in to comment.