Skip to content

Commit

Permalink
Initialize error on namespace switch (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferhoyos committed Apr 3, 2024
1 parent 330b73e commit 28e768a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions plugin/src/openshift/pages/IstioConfigListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ const newIstioResourceList = {
const IstioConfigListPage = () => {
const { ns } = useParams<{ ns: string }>();
const [loaded, setLoaded] = React.useState<boolean>(false);
const [listItems, setListItems] = React.useState<any[]>([]);
const [loadError, setLoadError] = React.useState<OSSMCError>();
const [listItems, setListItems] = React.useState<IstioConfigObject[]>([]);
const [loadError, setLoadError] = React.useState<OSSMCError | null>(null);
const history = useHistory();

const promises = React.useMemo(() => new PromisesRegistry(), []);
Expand Down Expand Up @@ -221,6 +221,10 @@ const IstioConfigListPage = () => {
};

React.useEffect(() => {
// initialize page
setLoaded(false);
setLoadError(null);

fetchIstioConfigs()
.then(istioConfigs => {
const istioConfigObjects = istioConfigs.map(istioConfig => {
Expand All @@ -232,11 +236,12 @@ const IstioConfigListPage = () => {
});

setListItems(istioConfigObjects);
setLoaded(true);
})
.catch(error => {
setLoadError({ title: error.response.statusText, message: error.response.data.error });
return [];
})
.finally(() => {
setLoaded(true);
});
}, [ns, fetchIstioConfigs]);

Expand Down

0 comments on commit 28e768a

Please sign in to comment.