From cb5809608ae64db568bef437002f53142cd2d790 Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Tue, 7 Jun 2022 11:59:14 +0200 Subject: [PATCH] change(ui) - code snippet --- .../shared/CodeSnippet/CodeSnippet.tsx | 63 +++++++++++++++++++ .../components/shared/CodeSnippet/index.ts | 1 + .../ProjectCodeSnippet/ProjectCodeSnippet.js | 13 ++-- .../components/ui/CopyButton/CopyButton.js | 9 ++- 4 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 frontend/app/components/shared/CodeSnippet/CodeSnippet.tsx create mode 100644 frontend/app/components/shared/CodeSnippet/index.ts diff --git a/frontend/app/components/shared/CodeSnippet/CodeSnippet.tsx b/frontend/app/components/shared/CodeSnippet/CodeSnippet.tsx new file mode 100644 index 000000000..0979684bd --- /dev/null +++ b/frontend/app/components/shared/CodeSnippet/CodeSnippet.tsx @@ -0,0 +1,63 @@ +import React from 'react'; +import { CopyButton } from 'UI'; +import Highlight from 'react-highlight'; + +const inputModeOptions = [ + { label: 'Record all inputs', value: 'plain' }, + { label: 'Ignore all inputs', value: 'obscured' }, + { label: 'Obscure all inputs', value: 'hidden' }, +]; + +const inputModeOptionsMap: any = {} +inputModeOptions.forEach((o: any, i: any) => inputModeOptionsMap[o.value] = i) + + +interface Props { + host: string; + projectKey: string; + ingestPoint: string; + defaultInputMode: any; + obscureTextNumbers: boolean; + obscureTextEmails: boolean; +} +function CodeSnippet(props: Props) { + const { host, projectKey, ingestPoint, defaultInputMode, obscureTextNumbers, obscureTextEmails } = props; + const codeSnippet = ` +`; + + return ( +
+
+ +
+ + {codeSnippet} + +
+ ); +} + +export default CodeSnippet; \ No newline at end of file diff --git a/frontend/app/components/shared/CodeSnippet/index.ts b/frontend/app/components/shared/CodeSnippet/index.ts new file mode 100644 index 000000000..023f75773 --- /dev/null +++ b/frontend/app/components/shared/CodeSnippet/index.ts @@ -0,0 +1 @@ +export { default } from './CodeSnippet'; \ No newline at end of file diff --git a/frontend/app/components/shared/TrackingCodeModal/ProjectCodeSnippet/ProjectCodeSnippet.js b/frontend/app/components/shared/TrackingCodeModal/ProjectCodeSnippet/ProjectCodeSnippet.js index 0c8a09e25..bf8393f41 100644 --- a/frontend/app/components/shared/TrackingCodeModal/ProjectCodeSnippet/ProjectCodeSnippet.js +++ b/frontend/app/components/shared/TrackingCodeModal/ProjectCodeSnippet/ProjectCodeSnippet.js @@ -8,6 +8,7 @@ import cn from 'classnames' import styles from './projectCodeSnippet.module.css' import Highlight from 'react-highlight' import Select from 'Shared/Select' +import CodeSnippet from '../../CodeSnippet'; const inputModeOptions = [ { label: 'Record all inputs', value: 'plain' }, @@ -142,10 +143,14 @@ const ProjectCodeSnippet = props => {
{ 'Project Key: ' } { site.projectKey }
- - - {_snippet} - +
You can also setup OpenReplay using Google Tag Manager (GTM).
diff --git a/frontend/app/components/ui/CopyButton/CopyButton.js b/frontend/app/components/ui/CopyButton/CopyButton.js index 2eeafd8d3..bb231cdb3 100644 --- a/frontend/app/components/ui/CopyButton/CopyButton.js +++ b/frontend/app/components/ui/CopyButton/CopyButton.js @@ -1,8 +1,9 @@ import React from 'react' import { useState } from 'react'; import copy from 'copy-to-clipboard'; +import { Button } from 'UI'; -function CopyButton({ content, className, btnText = 'copy' }) { +function CopyButton({ content, variant="text-primary", className = '', btnText = 'copy' }) { const [copied, setCopied] = useState(false) const copyHandler = () => { @@ -12,13 +13,15 @@ function CopyButton({ content, className, btnText = 'copy' }) { setCopied(false); }, 1000); }; + return ( - + ) }