mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-10 10:33:11 +03:00
hide descriptions for additional properties arrays
This commit is contained in:
parent
8dd05a6cb4
commit
8582ac9dec
@ -70,6 +70,20 @@ function humanizeKey(value: string): string {
|
||||
.join(" ");
|
||||
}
|
||||
|
||||
function _isArrayItemInAdditionalProperty(
|
||||
pathSegments: Array<string | number>,
|
||||
): boolean {
|
||||
// // If we find a numeric index, this is an array item
|
||||
for (let i = 0; i < pathSegments.length; i++) {
|
||||
const segment = pathSegments[i];
|
||||
if (typeof segment === "number") {
|
||||
// Consider any array item as being inside additional properties if it's not at the root level
|
||||
return i > 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
type FieldRenderSpec =
|
||||
| ReactNode
|
||||
| ComponentType<unknown>
|
||||
@ -147,6 +161,19 @@ export function FieldTemplate(props: FieldTemplateProps) {
|
||||
const pathSegments = fieldPathId.path.filter(
|
||||
(segment): segment is string => typeof segment === "string",
|
||||
);
|
||||
|
||||
// Check if this is an array item inside an object with additionalProperties
|
||||
const isArrayItemInAdditionalProp = _isArrayItemInAdditionalProperty(
|
||||
fieldPathId.path,
|
||||
);
|
||||
|
||||
// Conditions for showing descriptions/docs links
|
||||
const shouldShowDescription =
|
||||
!isMultiSchemaWrapper &&
|
||||
!isObjectField &&
|
||||
!isAdditionalProperty &&
|
||||
!isArrayItemInAdditionalProp;
|
||||
|
||||
const translationPath = buildTranslationPath(pathSegments, sectionI18nPrefix);
|
||||
const filterObjectLabel = getFilterObjectLabel(pathSegments);
|
||||
const translatedFilterObjectLabel = filterObjectLabel
|
||||
@ -402,48 +429,12 @@ export function FieldTemplate(props: FieldTemplateProps) {
|
||||
)}
|
||||
</Label>
|
||||
)}
|
||||
{finalDescription &&
|
||||
!isMultiSchemaWrapper &&
|
||||
!isAdditionalProperty && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{finalDescription}
|
||||
</p>
|
||||
)}
|
||||
{fieldDocsUrl &&
|
||||
!isMultiSchemaWrapper &&
|
||||
!isObjectField &&
|
||||
!isAdditionalProperty && (
|
||||
<div className="flex items-center text-xs text-primary-variant">
|
||||
<Link
|
||||
to={fieldDocsUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline"
|
||||
>
|
||||
{t("readTheDocumentation", { ns: "common" })}
|
||||
<LuExternalLink className="ml-2 inline-flex size-3" />
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-2">{children}</div>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
{children}
|
||||
|
||||
{finalDescription &&
|
||||
!isMultiSchemaWrapper &&
|
||||
!isObjectField &&
|
||||
!isAdditionalProperty && (
|
||||
{finalDescription && shouldShowDescription && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{finalDescription}
|
||||
</p>
|
||||
)}
|
||||
{fieldDocsUrl &&
|
||||
!isMultiSchemaWrapper &&
|
||||
!isObjectField &&
|
||||
!isAdditionalProperty && (
|
||||
{fieldDocsUrl && shouldShowDescription && (
|
||||
<div className="flex items-center text-xs text-primary-variant">
|
||||
<Link
|
||||
to={fieldDocsUrl}
|
||||
@ -456,6 +447,31 @@ export function FieldTemplate(props: FieldTemplateProps) {
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-2">{children}</div>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
{children}
|
||||
|
||||
{finalDescription && shouldShowDescription && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{finalDescription}
|
||||
</p>
|
||||
)}
|
||||
{fieldDocsUrl && shouldShowDescription && (
|
||||
<div className="flex items-center text-xs text-primary-variant">
|
||||
<Link
|
||||
to={fieldDocsUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline"
|
||||
>
|
||||
{t("readTheDocumentation", { ns: "common" })}
|
||||
<LuExternalLink className="ml-2 inline-flex size-3" />
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
|
||||
@ -220,11 +220,11 @@ export function ObjectFieldTemplate(props: ObjectFieldTemplateProps) {
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{groups.map((group) => (
|
||||
<div key={group.key} className="space-y-4">
|
||||
<div key={group.key} className="space-y-6">
|
||||
<div className="text-md font-medium text-primary">
|
||||
{group.label}
|
||||
</div>
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-6">
|
||||
{group.items.map((element) => (
|
||||
<div key={element.name}>{element.content}</div>
|
||||
))}
|
||||
@ -233,7 +233,7 @@ export function ObjectFieldTemplate(props: ObjectFieldTemplateProps) {
|
||||
))}
|
||||
|
||||
{ungrouped.length > 0 && (
|
||||
<div className={cn("space-y-4", groups.length > 0 && "pt-2")}>
|
||||
<div className={cn("space-y-6", groups.length > 0 && "pt-2")}>
|
||||
{ungrouped.map((element) => (
|
||||
<div key={element.name}>{element.content}</div>
|
||||
))}
|
||||
|
||||
@ -341,6 +341,7 @@ const settingsGroups = [
|
||||
key: "integrationObjectClassification",
|
||||
component: IntegrationObjectClassificationSettingsPage,
|
||||
},
|
||||
{ key: "triggers", component: TriggerView },
|
||||
{
|
||||
key: "integrationAudioTranscription",
|
||||
component: IntegrationAudioTranscriptionSettingsPage,
|
||||
@ -387,10 +388,7 @@ const settingsGroups = [
|
||||
},
|
||||
{
|
||||
label: "notifications",
|
||||
items: [
|
||||
{ key: "notifications", component: NotificationView },
|
||||
{ key: "triggers", component: TriggerView },
|
||||
],
|
||||
items: [{ key: "notifications", component: NotificationView }],
|
||||
},
|
||||
{
|
||||
label: "frigateplus",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user