Skip to content
Merged
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
21 changes: 13 additions & 8 deletions dashboard/src/components/TopBar/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@ const OriginSelect = ({
[navigate],
);

const selectItems = useMemo(() => {
if (originData === undefined) {
return <></>;
const pageOrigins = useMemo(() => {
if (!originData) {
return [];
}

const pageOrigins = isHardwarePath
return isHardwarePath
? originData.test_origins
: originData.checkout_origins;
}, [originData, isHardwarePath]);

const selectItems = useMemo(() => {
return pageOrigins.map(option => (
<SelectItem
key={option}
Expand All @@ -59,10 +60,14 @@ const OriginSelect = ({
{option}
</SelectItem>
));
}, [originData, isHardwarePath]);
}, [pageOrigins]);

useEffect(() => {
if (origin === undefined) {
if (pageOrigins.length === 0) {
return;
}

if (origin === undefined || !pageOrigins.includes(origin)) {
navigate({
to: '.',
search: previousSearch => ({
Expand All @@ -71,7 +76,7 @@ const OriginSelect = ({
}),
});
}
}, [navigate, origin]);
}, [navigate, origin, pageOrigins]);

if (originStatus === 'pending') {
return <FormattedMessage id="global.loading" />;
Expand Down
Loading