Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding secret copy button for token #414

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion client/components/modules/hubs/HubFormCard/HubFormCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import validate, { FormValues } from './validate';
import { useIsProfessional } from 'hooks/usePlans';
import Hub from 'classes/Hub';
import { HubT } from 'types/General';
import SecretCopy from '@Shared/SecretCopy/SecretCopy';
import { CookiesE } from 'types/Cookies';
import { getCookie } from 'cookies-next';

type HubFormCardPropsT = {
hub: HubT;
Expand Down Expand Up @@ -303,6 +306,11 @@ const HubFormCard = ({ hub: _hub, classProp = '' }: HubFormCardPropsT) => {
troubleshooting custom domains.
</p>

<SecretCopy
secret={getCookie(CookiesE.TurkeyAuthToken) as string}
classProp="mb-24"
/>

<div className="mb-20 youtube-video">
<iframe
src="https://www.youtube.com/embed/0PTmHNKdZB0"
Expand All @@ -321,7 +329,6 @@ const HubFormCard = ({ hub: _hub, classProp = '' }: HubFormCardPropsT) => {
</a>
</section>
)}

<section className={styles.actions_wrapper}>
<Button
label="cancel"
Expand Down
6 changes: 6 additions & 0 deletions client/components/shared/SecretCopy/SecretCopy.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.buttons {
margin-top: 12px;
display: flex;
flex-shrink: 0;
align-items: center;
}
40 changes: 40 additions & 0 deletions client/components/shared/SecretCopy/SecretCopy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { useState } from 'react';
import { Button, CopyButton, Input, ToolTip } from '@mozilla/lilypad-ui';
import styles from './SecretCopy.module.scss';

type SecretCopyPropsT = {
secret: string;
classProp?: string;
};

const SecretCopy = ({ secret, classProp = '' }: SecretCopyPropsT) => {
const [isVisible, seIsVisible] = useState(false);

return (
<div className={`flex ${classProp}`}>
<Input
readOnly={true}
type={isVisible ? 'text' : 'password'}
label="Get turkeyauthtoken"
value={secret}
placeholder="Token"
name="Token"
/>
<div className={styles.buttons}>
<Button
icon={isVisible ? 'eye-off' : 'eye'}
category="primary_outline"
size="small"
classProp="mx-12"
onClick={() => seIsVisible((state) => !state)}
/>

<ToolTip description="Copy token to clipboard." location="left">
<CopyButton value={secret} />
</ToolTip>
</div>
</div>
);
};

export default SecretCopy;
Loading