Skip to content

Commit e424602

Browse files
authored
Added indicator for deprecated attributes (#424)
1 parent e1ce48c commit e424602

1 file changed

Lines changed: 38 additions & 2 deletions

File tree

src/main/frontend/app/routes/studio/context/context-input.tsx

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import React, { useState } from 'react'
1+
import React, { useRef, useState } from 'react'
22
import HelpIcon from '/icons/solar/Help.svg?react'
3+
import DangerTriangle from '/icons/solar/Danger Triangle.svg?react'
34
import { useJavadocTransform } from '@frankframework/doc-library-react'
45
import ContextInputField from './context-input-field'
56
import type { Attribute, Elements } from '@frankframework/doc-library-core'
7+
import type { DeprecatedInfo } from './deprecated-list-popover'
8+
import { DeprecatedPopover } from '../canvas/nodetypes/components/deprecated-popover'
69

710
export interface ContextInputProperties {
811
id: string
@@ -28,12 +31,16 @@ export default function ContextInput({
2831
const type = attribute?.type
2932
const description = attribute?.description
3033
const required = attribute?.mandatory
34+
const deprecated = attribute?.deprecated
3135

3236
return (
3337
<div className="group font-small text-foreground relative block text-sm">
3438
<div className="flex items-center gap-2">
3539
{required && <span className="text-red-500">*</span>}
36-
<label htmlFor={id}>{label}</label>
40+
<label htmlFor={id} className={`${deprecated ? 'text-muted-foreground line-through' : 'text-foreground'}`}>
41+
{label}
42+
</label>
43+
{deprecated && <DeprecatedIcon deprecated={deprecated} />}
3744
{description && <DescriptionHelpIcon description={description} elements={elements ?? null} />}
3845
</div>
3946

@@ -74,3 +81,32 @@ function DescriptionHelpIcon({ description, elements }: Readonly<{ description:
7481
</div>
7582
)
7683
}
84+
85+
function DeprecatedIcon({ deprecated }: Readonly<{ deprecated: DeprecatedInfo }>) {
86+
const ref = useRef<HTMLDivElement | null>(null)
87+
const [anchorRect, setAnchorRect] = useState<DOMRect | null>(null)
88+
const [show, setShow] = useState(false)
89+
90+
if (!deprecated) return null
91+
92+
const handleMouseEnter = () => {
93+
if (ref.current) {
94+
setAnchorRect(ref.current.getBoundingClientRect())
95+
setShow(true)
96+
}
97+
}
98+
99+
const handleMouseLeave = () => {
100+
setShow(false)
101+
}
102+
103+
return (
104+
<>
105+
<div ref={ref} onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave} className="inline-flex">
106+
<DangerTriangle className="text-error h-auto w-4 cursor-pointer fill-current" />
107+
</div>
108+
109+
{show && <DeprecatedPopover deprecated={deprecated} anchorRect={anchorRect} />}
110+
</>
111+
)
112+
}

0 commit comments

Comments
 (0)