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

WEB: Devrel Bugs #275

Merged
merged 1 commit into from
Aug 12, 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
141 changes: 71 additions & 70 deletions src/apps/console/components/sync-status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
CircleFill,
WarningCircleFill,
} from '~/console/components/icons';
import Tooltip from '~/components/atoms/tooltip';
import {
Github__Com___Kloudlite___Api___Pkg___Types__SyncState as ISyncState,
Github__Com___Kloudlite___Api___Pkg___Types__SyncAction as ISyncAction,
Expand Down Expand Up @@ -286,82 +285,84 @@ export const SyncStatusV2 = ({
return [];
}

const items = checkList?.reduce(
(acc, curr) => {
const k = checks[curr.name];
if (acc.progress === 'done') {
acc.items.push({
...curr,
result: 'idle',
message: '',
});
return acc;
}
const items = checkList
?.filter((cl) => !cl.hide)
.reduce(
(acc, curr) => {
const k = checks[curr.name];
if (acc.progress === 'done') {
acc.items.push({
...curr,
result: 'idle',
message: '',
});
return acc;
}

const res = ((): {
value: OverallStates;
progress: string;
message: string;
} => {
if (k) {
if (acc.value === 'idle' && k.state === 'yet-to-be-reconciled') {
return {
value: 'idle',
message: k.message,
progress: 'done',
};
const res = ((): {
value: OverallStates;
progress: string;
message: string;
} => {
if (k) {
if (acc.value === 'idle' && k.state === 'yet-to-be-reconciled') {
return {
value: 'idle',
message: k.message,
progress: 'done',
};
}

if (k.state === 'under-reconcilation') {
return {
value: 'in-progress',

message: k.message,
progress: 'done',
};
}

if (k.state === 'errored-during-reconcilation') {
return {
value: 'error',
message: k.message,
progress: 'done',
};
}

if (k.state === 'finished-reconcilation') {
return {
value: 'ready',
message: k.message,
progress: 'init',
};
}
}

if (k.state === 'under-reconcilation') {
return {
value: 'in-progress',
return acc;
})();

message: k.message,
progress: 'done',
};
}
acc.items.push({
...curr,
result: res?.value,
message: res.message,
});

if (k.state === 'errored-during-reconcilation') {
return {
value: 'error',
message: k.message,
progress: 'done',
};
}

if (k.state === 'finished-reconcilation') {
return {
value: 'ready',
message: k.message,
progress: 'init',
};
}
}
acc.value = res.value;
acc.progress = res.progress;

return acc;
})();

acc.items.push({
...curr,
result: res?.value,
message: res.message,
});

acc.value = res.value;
acc.progress = res.progress;

return acc;
},
{
value: 'idle' as OverallStates,
items: [] as ({
result: OverallStates;
message: string;
} & ICheckList)[],
message: '',
progress: 'init',
}
);
},
{
value: 'idle' as OverallStates,
items: [] as ({
result: OverallStates;
message: string;
} & ICheckList)[],
message: '',
progress: 'init',
}
);

return items?.items;
};
Expand Down
6 changes: 5 additions & 1 deletion src/apps/console/hooks/use-cluster-status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,27 @@ const useClusterStatus = () => {
const api = useConsoleApi();

const [clusters, setClusters] = useState<any[]>([]);
const [loading, setLoading] = useState(false);

const listCluster = useCallback(async () => {
setLoading(true);
try {
const clusters = await api.listAllClusters();
setClusters(parseNodes(clusters.data) || []);
return clusters;
} catch (err) {
console.error(err);
return false;
} finally {
setLoading(false);
}
}, []);

useEffect(() => {
listCluster();
}, []);

return { findClusterStatus, clusters };
return { findClusterStatus, clusters, loading };
};

export default useClusterStatus;
2 changes: 1 addition & 1 deletion src/apps/console/page-components/handle-environment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const HandleEnvironment = ({ show, setShow }: IDialog<IEnvironment | null>) => {
clusterName: clusterList.find((c) => c.ready)?.value || '',
}));
}
}, [clusterList]);
}, [clusterList, show]);

return (
<Popup.Root
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ const GridView = ({ items = [], onAction: _ }: IResource) => {
const ListView = ({ items = [], onAction }: IResource) => {
const { environment, account, cluster } =
useOutletContext<IEnvironmentContext>();
const { findClusterStatus, clusters } = useClusterStatus();
const { findClusterStatus, clusters, loading } = useClusterStatus();

return (
<ListV2.Root
Expand Down Expand Up @@ -321,15 +321,16 @@ const ListView = ({ items = [], onAction }: IResource) => {
render: () => <AppServiceView service={i.serviceHost || ''} />,
},
status: {
render: () => (
<div className="inline-block">
{isClusterOnline ? (
<SyncStatusV2 item={i} />
) : (
<Badge type="warning">Cluster Offline</Badge>
)}
</div>
),
render: () => {
if (loading) {
return null;
}
if (!isClusterOnline) {
return <Badge type="warning">Cluster Offline</Badge>;
}

return <SyncStatusV2 item={i} />;
},
},
updated: {
render: () => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const ExtraButton = ({ onAction, item }: IExtraButton) => {
icon: <GearSix size={iconSize} />,
type: 'item',
to: `/${account}/env/${environment}/external-app/${parseName(
item,
item
)}/settings/general`,
key: 'settings',
},
Expand Down Expand Up @@ -311,7 +311,7 @@ const ListView = ({ items = [], onAction }: IResource) => {
environment?.spec?.targetNamespace
}.svc.${parseName(cluster)}.local`
: `${parseName(i)}.${parseName(
environment,
environment
)}.svc.${parseName(cluster)}.local`
}
/>
Expand All @@ -337,7 +337,7 @@ const ListView = ({ items = [], onAction }: IResource) => {
},
},
to: `/${parseName(account)}/env/${parseName(
environment,
environment
)}/external-app/${id}`,
};
}),
Expand All @@ -357,9 +357,9 @@ const ExternalNameResource = ({ items = [] }: Omit<IResource, 'onAction'>) => {
useWatchReload(
items.map((i) => {
return `account:${parseName(account)}.environment:${parseName(
environment,
environment
)}.app:${parseName(i)}`;
}),
})
);

const interceptExternalApp = async (item: BaseType, intercept: boolean) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ const Root = (props: IDialog) => {
handleChange('managedServiceName')(dummyEvent(value));
}}
error={!!errors.managedServiceName}
message={errors.clusterName}
message={errors.managedServiceName}
// loading={msvcIsLoading}
/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const GridView = ({ items = [], onAction, templates }: IResource) => {

const ListView = ({ items = [], onAction, templates }: IResource) => {
const { cluster } = useOutletContext<IEnvironmentContext>();
const { findClusterStatus, clusters } = useClusterStatus();
const { findClusterStatus, clusters, loading } = useClusterStatus();

return (
<ListV2.Root
Expand Down Expand Up @@ -229,6 +229,10 @@ const ListView = ({ items = [], onAction, templates }: IResource) => {
},
status: {
render: () => {
if (loading) {
return null;
}

if (!isClusterOnline) {
return <Badge type="warning">Cluster Offline</Badge>;
}
Expand Down
Loading
Loading