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: Wrong loading state with no permissions #547

Merged
merged 1 commit into from
Jan 13, 2025
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 @@ -18,7 +18,7 @@ export const CDPipelineList = ({ filterFunction, blockerComponent }: CDPipelineL

return (
<Table
isLoading={CDPipelines.isLoading}
isLoading={CDPipelines.isLoading && (!CDPipelines.errors || !CDPipelines.errors.length)}
data={CDPipelines.data}
errors={CDPipelines.errors}
columns={columns}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { useTypedPermissions } from '../../../../../../hooks/useTypedPermissions';
import { DetailsProps } from './types';

export const Details = ({ pipelineRuns }: DetailsProps) => {
export const Details = ({ pipelineRuns, error }: DetailsProps) => {
const permissions = useTypedPermissions();

return (
Expand All @@ -32,7 +32,7 @@ export const Details = ({ pipelineRuns }: DetailsProps) => {
>
<PipelineRunList
pipelineRuns={pipelineRuns.all}
isLoading={pipelineRuns.all === null}
isLoading={pipelineRuns.all === null && !error}
permissions={permissions}
pipelineRunTypes={[
PIPELINE_TYPES.ALL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export interface DetailsProps {
all: PipelineRunKubeObjectInterface[];
latestBuildPipelineRun: PipelineRunKubeObjectInterface;
};
error: Error;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const CodebaseBranch = ({
latestBuildPipelineRun: null,
});

const [, setError] = React.useState<Error>(null);
const [error, setError] = React.useState<Error>(null);

const handleStorePipelineRuns = React.useCallback(
(socketPipelineRuns: PipelineRunKubeObjectInterface[]) => {
Expand Down Expand Up @@ -92,7 +92,7 @@ export const CodebaseBranch = ({
<Summary codebaseBranchData={codebaseBranchData} pipelineRuns={pipelineRuns} />
</AccordionSummary>
<AccordionDetails>
<Details codebaseData={codebaseData} pipelineRuns={pipelineRuns} />
<Details codebaseData={codebaseData} pipelineRuns={pipelineRuns} error={error} />
</AccordionDetails>
</Accordion>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const ComponentList = ({ noGitServers }: ComponentListProps) => {
<>
<Resources />
<Table<CodebaseKubeObjectInterface>
isLoading={codebases.isLoading}
isLoading={codebases.isLoading && (!codebases.errors || !codebases.errors.length)}
data={codebases.data}
errors={codebases.errors}
columns={columns}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/configuration/pages/pipeline-list/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const PageView = () => {
namespace: getDefaultNamespace(),
});

const isLoading = items === null;
const isLoading = items === null && !error;

return (
<PageWithSubMenu list={menu} title="Configuration">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const QuickLinkList = ({ items, errors, filterFunction }: QuickLinkListPr
return (
<>
<Table
isLoading={!items}
isLoading={items === null && (!errors || !errors.length)}
data={items}
errors={errors}
columns={columns}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/configuration/pages/task-list/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const PageView = () => {
namespace: getDefaultNamespace(),
});

const isLoading = items === null;
const isLoading = items === null && !error;

return (
<PageWithSubMenu list={menu} title="Configuration">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const TemplatesTable = ({
errors={errors}
columns={columns}
data={data}
isLoading={data === null}
isLoading={data === null && (!errors || !errors.length)}
handleRowClick={
permissions?.create?.Codebase.allowed ? (event, row) => handleTemplateClick(row) : null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const MarketplaceList = ({ filterFunction, warning }: MarketplaceListProp
<DataGrid<TemplateKubeObjectInterface>
data={templates.data}
errors={templates.errors}
isLoading={templates.isLoading}
isLoading={templates.isLoading && (!templates.errors || !templates.errors.length)}
spacing={3}
filterFunction={filterFunction}
emptyListComponent={
Expand Down
4 changes: 3 additions & 1 deletion src/pages/pipelines/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export const PageView = () => {
>
<PipelineRunList
pipelineRuns={pipelineRuns.data}
isLoading={pipelineRuns.isLoading}
isLoading={
pipelineRuns.isLoading && (!pipelineRuns.errors || !pipelineRuns.errors.length)
}
errors={pipelineRuns.errors}
permissions={permissions}
/>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/stage-details/hooks/usePageTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const usePageTabs = (): Tab[] => {
>
<PipelineRunList
pipelineRuns={pipelineRuns.data}
isLoading={pipelineRuns.isLoading}
isLoading={pipelineRuns.isLoading && !pipelineRuns.error}
blockerError={pipelineRuns.error}
permissions={permissions}
pipelineRunTypes={[
Expand Down Expand Up @@ -214,6 +214,7 @@ export const usePageTabs = (): Tab[] => {
pipelineRuns.error,
pipelineRuns.isLoading,
setNewPipelineRunAdded,
stage.data?.spec.clusterName,
stage.data?.spec.namespace,
stageName,
variablesConfigMap.data,
Expand Down
Loading