fix: address PR review findings
- Remove ternary operators from new code (widget-integration-select, TabsContainer, mock data, members page) - Remove stale /docs/management/tools/backup from sitemap type - Add value prop to error-state Select in beszel-system-stats
This commit is contained in:
6 files changed
+16
-13
No files matched your search
@@ -42,9 +42,9 @@ export default async function GroupsDetailPage(props: GroupsDetailPageProps) {
|
|||||||
const isReserved = group.name === everyoneGroup;
|
const isReserved = group.name === everyoneGroup;
|
||||||
|
|
||||||
const searchTerm = searchParams.search?.trim().toLowerCase();
|
const searchTerm = searchParams.search?.trim().toLowerCase();
|
||||||
const filteredMembers = searchTerm
|
const filteredMembers = group.members.filter(
|
||||||
? group.members.filter((member) => member.name?.toLowerCase().includes(searchTerm))
|
(member) => !searchTerm || member.name?.toLowerCase().includes(searchTerm),
|
||||||
: group.members;
|
);
|
||||||
|
|
||||||
// "local" = every enabled provider managed locally, "external" = none, "mixed" = some.
|
// "local" = every enabled provider managed locally, "external" = none, "mixed" = some.
|
||||||
const managementType = getGroupMemberManagementType();
|
const managementType = getGroupMemberManagementType();
|
||||||
|
|||||||
@@ -233,7 +233,6 @@ export type HomarrDocumentationPath =
|
|||||||
| "/docs/management/search-engines"
|
| "/docs/management/search-engines"
|
||||||
| "/docs/management/settings"
|
| "/docs/management/settings"
|
||||||
| "/docs/management/tasks"
|
| "/docs/management/tasks"
|
||||||
| "/docs/management/tools/backup"
|
|
||||||
| "/docs/management/users"
|
| "/docs/management/users"
|
||||||
| "/docs/widgets/anchor-note"
|
| "/docs/widgets/anchor-note"
|
||||||
| "/docs/widgets/app"
|
| "/docs/widgets/app"
|
||||||
|
|||||||
@@ -375,7 +375,7 @@ export class BeszelMockService {
|
|||||||
name: names[i % names.length] ?? "CPU",
|
name: names[i % names.length] ?? "CPU",
|
||||||
val: rand(60, 95),
|
val: rand(60, 95),
|
||||||
created: new Date(now - (i + 1) * 3_600_000).toISOString(),
|
created: new Date(now - (i + 1) * 3_600_000).toISOString(),
|
||||||
resolved: i % 2 === 0 ? new Date(now - i * 1_800_000).toISOString() : null,
|
resolved: i % 2 === 0 && new Date(now - i * 1_800_000).toISOString() || null,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,10 +23,8 @@ export const WidgetIntegrationSelectInput = ({
|
|||||||
|
|
||||||
const { data: selectData = [], isPending, isError } = options.useOptions(integrationIds);
|
const { data: selectData = [], isPending, isError } = options.useOptions(integrationIds);
|
||||||
const currentValue = form.getInputProps(`options.${property}`).value as string;
|
const currentValue = form.getInputProps(`options.${property}`).value as string;
|
||||||
const data =
|
const hasCurrentInData = !currentValue || selectData.some((opt) => opt.value === currentValue);
|
||||||
currentValue && !selectData.some((opt) => opt.value === currentValue)
|
const data = hasCurrentInData ? selectData : [...selectData, { value: currentValue, label: currentValue }];
|
||||||
? [...selectData, { value: currentValue, label: currentValue }]
|
|
||||||
: selectData;
|
|
||||||
|
|
||||||
if (integrationIds.length === 0) {
|
if (integrationIds.length === 0) {
|
||||||
return (
|
return (
|
||||||
@@ -36,17 +34,21 @@ export const WidgetIntegrationSelectInput = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const description = options.withDescription ? tInput("description") : undefined;
|
||||||
|
const placeholder = isPending ? t("loading") : t("placeholder");
|
||||||
|
const error = isError ? t("loadError") : undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
label={tInput("label")}
|
label={tInput("label")}
|
||||||
description={options.withDescription ? tInput("description") : undefined}
|
description={description}
|
||||||
placeholder={(isPending && t("loading")) || t("placeholder")}
|
placeholder={placeholder}
|
||||||
clearable={options.clearable}
|
clearable={options.clearable}
|
||||||
searchable={options.searchable}
|
searchable={options.searchable}
|
||||||
nothingFoundMessage={t("noResults")}
|
nothingFoundMessage={t("noResults")}
|
||||||
data={data}
|
data={data}
|
||||||
disabled={isError}
|
disabled={isError}
|
||||||
error={(isError && t("loadError")) || undefined}
|
error={error}
|
||||||
{...form.getInputProps(`options.${property}`)}
|
{...form.getInputProps(`options.${property}`)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ export default function BeszelSystemStatsWidget({
|
|||||||
<Select
|
<Select
|
||||||
size="xs"
|
size="xs"
|
||||||
data={systems}
|
data={systems}
|
||||||
|
value={selectedSystem}
|
||||||
placeholder={t("selectSystem")}
|
placeholder={t("selectSystem")}
|
||||||
onChange={(value) => value && handleSelectSystem(value)}
|
onChange={(value) => value && handleSelectSystem(value)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -70,7 +70,8 @@ export function TabsContainer({ children, defaultTab }: TabsContainerProps) {
|
|||||||
const panels = Children.toArray(children).filter(isTabPanel);
|
const panels = Children.toArray(children).filter(isTabPanel);
|
||||||
const firstPanel = panels[0];
|
const firstPanel = panels[0];
|
||||||
const panelValues = new Set(panels.map((p) => p.props.value));
|
const panelValues = new Set(panels.map((p) => p.props.value));
|
||||||
const initialTab = (defaultTab && panelValues.has(defaultTab) ? defaultTab : firstPanel?.props.value) ?? null;
|
const resolvedDefault = defaultTab && panelValues.has(defaultTab) && defaultTab;
|
||||||
|
const initialTab = resolvedDefault || firstPanel?.props.value || null;
|
||||||
const [activeTab, setActiveTab] = useState<string | null>(initialTab);
|
const [activeTab, setActiveTab] = useState<string | null>(initialTab);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in new issue
Block a user