Skip to content

Commit

Permalink
feat: hide secrets by default (NangoHQ#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chakravarthy7102 authored Apr 20, 2023
1 parent 45bee9a commit 8d55bf8
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
11 changes: 11 additions & 0 deletions packages/webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"buffer": "^6.0.3",
"classnames": "^2.3.2",
"env-cmd": "^10.1.0",
"posthog-js": "^1.51.4",
"react": "^18.2.0",
Expand Down
30 changes: 30 additions & 0 deletions packages/webapp/src/components/ui/SecretInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { forwardRef, useCallback, useState } from 'react';
import classNames from 'classnames';

const SecretInput = forwardRef<HTMLInputElement, JSX.IntrinsicElements['input']>(function PasswordField({ className, ...props }, ref) {
const [isSecretVisible, setIsSecretVisible] = useState(false);

const toggleSecretVisibility = useCallback(() => setIsSecretVisible(!isSecretVisible), [isSecretVisible, setIsSecretVisible]);

return (
<div className="relative">
<input
type={isSecretVisible ? 'text' : 'password'}
ref={ref}
className={classNames(
'border-border-gray bg-bg-black text-text-light-gray focus:border-white focus:ring-white block h-11 w-full appearance-none rounded-md border px-3 py-2 text-base placeholder-gray-400 shadow-sm focus:outline-none',
className
)}
{...props}
/>
<label
className="absolute right-4 top-2 bg-gray-300 hover:bg-gray-400 rounded px-2 py-1 text-sm text-gray-600 cursor-pointer"
onClick={toggleSecretVisibility}
>
{isSecretVisible ? 'hide' : 'show'}
</label>
</div>
);
});

export default SecretInput;
5 changes: 2 additions & 3 deletions packages/webapp/src/pages/IntegrationCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { HelpCircle } from '@geist-ui/icons';
import { Tooltip } from '@geist-ui/core';
import { defaultCallback } from '../utils/utils';
import { Prism } from '@mantine/prism';
import SecretInput from '../components/ui/SecretInput';

interface Integration {
uniqueKey: string;
Expand Down Expand Up @@ -304,13 +305,11 @@ export default function IntegrationCreate() {
</Tooltip>
</div>
<div className="mt-1">
<input
<SecretInput
id="client_secret"
name="client_secret"
type="text"
defaultValue={integration ? integration.clientSecret : ''}
required
className="border-border-gray bg-bg-black text-text-light-gray focus:ring-white block h-11 w-full appearance-none rounded-md border px-3 py-2 text-base placeholder-gray-400 shadow-sm focus:border-white focus:outline-none"
/>
</div>
</div>
Expand Down

0 comments on commit 8d55bf8

Please sign in to comment.