mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-21 07:38:22 +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(" ");
|
.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 =
|
type FieldRenderSpec =
|
||||||
| ReactNode
|
| ReactNode
|
||||||
| ComponentType<unknown>
|
| ComponentType<unknown>
|
||||||
@ -147,6 +161,19 @@ export function FieldTemplate(props: FieldTemplateProps) {
|
|||||||
const pathSegments = fieldPathId.path.filter(
|
const pathSegments = fieldPathId.path.filter(
|
||||||
(segment): segment is string => typeof segment === "string",
|
(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 translationPath = buildTranslationPath(pathSegments, sectionI18nPrefix);
|
||||||
const filterObjectLabel = getFilterObjectLabel(pathSegments);
|
const filterObjectLabel = getFilterObjectLabel(pathSegments);
|
||||||
const translatedFilterObjectLabel = filterObjectLabel
|
const translatedFilterObjectLabel = filterObjectLabel
|
||||||
@ -402,48 +429,12 @@ export function FieldTemplate(props: FieldTemplateProps) {
|
|||||||
)}
|
)}
|
||||||
</Label>
|
</Label>
|
||||||
)}
|
)}
|
||||||
{finalDescription &&
|
{finalDescription && shouldShowDescription && (
|
||||||
!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 && (
|
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
{finalDescription}
|
{finalDescription}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{fieldDocsUrl &&
|
{fieldDocsUrl && shouldShowDescription && (
|
||||||
!isMultiSchemaWrapper &&
|
|
||||||
!isObjectField &&
|
|
||||||
!isAdditionalProperty && (
|
|
||||||
<div className="flex items-center text-xs text-primary-variant">
|
<div className="flex items-center text-xs text-primary-variant">
|
||||||
<Link
|
<Link
|
||||||
to={fieldDocsUrl}
|
to={fieldDocsUrl}
|
||||||
@ -456,6 +447,31 @@ export function FieldTemplate(props: FieldTemplateProps) {
|
|||||||
</Link>
|
</Link>
|
||||||
</div>
|
</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 (
|
return (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
{groups.map((group) => (
|
{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">
|
<div className="text-md font-medium text-primary">
|
||||||
{group.label}
|
{group.label}
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-4">
|
<div className="space-y-6">
|
||||||
{group.items.map((element) => (
|
{group.items.map((element) => (
|
||||||
<div key={element.name}>{element.content}</div>
|
<div key={element.name}>{element.content}</div>
|
||||||
))}
|
))}
|
||||||
@ -233,7 +233,7 @@ export function ObjectFieldTemplate(props: ObjectFieldTemplateProps) {
|
|||||||
))}
|
))}
|
||||||
|
|
||||||
{ungrouped.length > 0 && (
|
{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) => (
|
{ungrouped.map((element) => (
|
||||||
<div key={element.name}>{element.content}</div>
|
<div key={element.name}>{element.content}</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@ -341,6 +341,7 @@ const settingsGroups = [
|
|||||||
key: "integrationObjectClassification",
|
key: "integrationObjectClassification",
|
||||||
component: IntegrationObjectClassificationSettingsPage,
|
component: IntegrationObjectClassificationSettingsPage,
|
||||||
},
|
},
|
||||||
|
{ key: "triggers", component: TriggerView },
|
||||||
{
|
{
|
||||||
key: "integrationAudioTranscription",
|
key: "integrationAudioTranscription",
|
||||||
component: IntegrationAudioTranscriptionSettingsPage,
|
component: IntegrationAudioTranscriptionSettingsPage,
|
||||||
@ -387,10 +388,7 @@ const settingsGroups = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "notifications",
|
label: "notifications",
|
||||||
items: [
|
items: [{ key: "notifications", component: NotificationView }],
|
||||||
{ key: "notifications", component: NotificationView },
|
|
||||||
{ key: "triggers", component: TriggerView },
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "frigateplus",
|
label: "frigateplus",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user