Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Component crash, tekton 404 pages #495

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
);
};
Loading