[PUI] Fix licensing dialog (#6993)

* make licensing dialog more failure tolerant

* add error text if no info can be parsed

* Update LicenseModal.tsx

fix copy
co-author: @SchrodingersGat
This commit is contained in:
Matthias Mair 2024-04-10 16:00:48 +01:00 committed by GitHub
parent 0d59f6e8a9
commit 1e0382c719
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -20,7 +20,7 @@ export function LicenceView(entries: Readonly<any[]>) {
return (
<Stack spacing="xs">
<Divider />
{entries?.length > 0 && (
{entries?.length > 0 ? (
<Accordion variant="contained" defaultValue="-">
{entries?.map((entry: any, index: number) => (
<Accordion.Item key={entry.name} value={`entry-${index}`}>
@ -38,6 +38,10 @@ export function LicenceView(entries: Readonly<any[]>) {
</Accordion.Item>
))}
</Accordion>
) : (
<Text>
<Trans>No Information provided - this is likely a server issue</Trans>
</Text>
)}
</Stack>
);
@ -53,6 +57,8 @@ export function LicenseModal() {
.catch(() => {})
});
const rspdata = !data ? [] : Object.keys(data ?? {});
return (
<Stack spacing="xs">
<Divider />
@ -69,16 +75,16 @@ export function LicenseModal() {
</Text>
</Alert>
) : (
<Tabs defaultValue={Object.keys(data)[0] ?? ''}>
<Tabs defaultValue={rspdata[0] ?? ''}>
<Tabs.List>
{Object.keys(data ?? {}).map((key) => (
{rspdata.map((key) => (
<Tabs.Tab key={key} value={key}>
<Trans>{key} Packages</Trans>
</Tabs.Tab>
))}
</Tabs.List>
{Object.keys(data ?? {}).map((key) => (
{rspdata.map((key) => (
<Tabs.Panel key={key} value={key}>
{LicenceView(data[key] ?? [])}
</Tabs.Panel>