diff --git a/packages/console/src/components/CopyToClipboard/index.module.scss b/packages/console/src/components/CopyToClipboard/index.module.scss index 8b639bdce..ce9da939b 100644 --- a/packages/console/src/components/CopyToClipboard/index.module.scss +++ b/packages/console/src/components/CopyToClipboard/index.module.scss @@ -25,6 +25,12 @@ justify-content: space-between; cursor: text; + .content { + flex: 1; + overflow: hidden; + text-overflow: ellipsis; + } + .copyIcon { margin-left: _.unit(3); } diff --git a/packages/console/src/components/CopyToClipboard/index.tsx b/packages/console/src/components/CopyToClipboard/index.tsx index 31593d548..9fb8b7d89 100644 --- a/packages/console/src/components/CopyToClipboard/index.tsx +++ b/packages/console/src/components/CopyToClipboard/index.tsx @@ -1,8 +1,10 @@ import classNames from 'classnames'; -import { MouseEventHandler, useEffect, useRef, useState } from 'react'; +import { MouseEventHandler, useEffect, useMemo, useRef, useState } from 'react'; import { TFuncKey, useTranslation } from 'react-i18next'; import Copy from '@/icons/Copy'; +import Eye from '@/icons/Eye'; +import EyeClosed from '@/icons/EyeClosed'; import IconButton from '../IconButton'; import Tooltip from '../Tooltip'; @@ -12,14 +14,29 @@ type Props = { value: string; className?: string; variant?: 'text' | 'contained' | 'border' | 'icon'; + hasVisibilityToggle?: boolean; }; type CopyState = TFuncKey<'translation', 'admin_console.general'>; -const CopyToClipboard = ({ value, className, variant = 'contained' }: Props) => { +const CopyToClipboard = ({ + value, + className, + hasVisibilityToggle, + variant = 'contained', +}: Props) => { const copyIconReference = useRef(null); const [copyState, setCopyState] = useState('copy'); const { t } = useTranslation(undefined, { keyPrefix: 'admin_console.general' }); + const [showHiddenContent, setShowHiddenContent] = useState(false); + + const displayValue = useMemo(() => { + if (!hasVisibilityToggle || showHiddenContent) { + return value; + } + + return '*'.repeat(value.length); + }, [hasVisibilityToggle, showHiddenContent, value]); useEffect(() => { copyIconReference.current?.addEventListener('mouseleave', () => { @@ -33,6 +50,10 @@ const CopyToClipboard = ({ value, className, variant = 'contained' }: Props) => setCopyState('copied'); }; + const toggleHiddenContent = () => { + setShowHiddenContent((previous) => !previous); + }; + return (
}} >
- {variant === 'icon' ? null : value} + {variant !== 'icon' &&
{displayValue}
} + {hasVisibilityToggle && ( +
+ + {showHiddenContent ? : } + +
+ )}
diff --git a/packages/console/src/icons/EyeClosed.tsx b/packages/console/src/icons/EyeClosed.tsx new file mode 100644 index 000000000..27560b91c --- /dev/null +++ b/packages/console/src/icons/EyeClosed.tsx @@ -0,0 +1,21 @@ +import { SVGProps } from 'react'; + +const EyeClosed = (props: SVGProps) => ( + + + +); + +export default EyeClosed; diff --git a/packages/console/src/pages/ApplicationDetails/components/Settings.tsx b/packages/console/src/pages/ApplicationDetails/components/Settings.tsx index 5a913ea5f..1e6b34923 100644 --- a/packages/console/src/pages/ApplicationDetails/components/Settings.tsx +++ b/packages/console/src/pages/ApplicationDetails/components/Settings.tsx @@ -64,6 +64,16 @@ const Settings = ({ applicationType, oidcConfig, defaultData, isDeleted }: Props placeholder={t('application_details.description_placeholder')} /> + {applicationType === ApplicationType.Traditional && ( + + + + )}