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

ECOPROJECT-2491: Wait to load the sources table until agents and sources are loaded #55

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 @@ -97,9 +97,9 @@ export const Provider: React.FC<PropsWithChildren> = (props) => {
}, [listSourcesState.value]);


const selectAgent = useCallback((agent: Agent) => {
const selectAgent = useCallback(async (agent: Agent) => {
setAgentSelected(agent);
if (agent && agent.sourceId!==null) selectSourceById(agent.sourceId ?? '');
if (agent && agent.sourceId!==null) await selectSourceById(agent.sourceId ?? '');
}, [selectSourceById]);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ import { Columns } from "./Columns";
import { DEFAULT_POLLING_DELAY, VALUE_NOT_AVAILABLE } from "./Constants";
import { SourceStatusView } from "./SourceStatusView";
import { useDiscoverySources } from "#/migration-wizard/contexts/discovery-sources/Context";
import { Radio } from "@patternfly/react-core";
import { Radio, Spinner } from "@patternfly/react-core";
import { Link } from "react-router-dom";

export const SourcesTable: React.FC = () => {
const discoverySourcesContext = useDiscoverySources();
const hasAgents = discoverySourcesContext.agents && discoverySourcesContext.agents.length > 0;
const [firstAgent, ..._otherAgents] = discoverySourcesContext.agents ?? [];

useMount(() => {
useMount(async () => {
if (!discoverySourcesContext.isPolling) {
discoverySourcesContext.listSources();
discoverySourcesContext.listAgents();
await Promise.all([
discoverySourcesContext.listSources(),
discoverySourcesContext.listAgents()
]);
}
});

Expand All @@ -40,8 +42,9 @@ export const SourcesTable: React.FC = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [discoverySourcesContext.agentSelected?.status]);



if (!discoverySourcesContext.agentSelected && !discoverySourcesContext.sourceSelected) {
return <Spinner />; // Loading agent and source
}
return (
<Table aria-label="Sources table" variant="compact" borders={false}>
{hasAgents && (
Expand Down
Loading