Skip to content

Commit de6aa5d

Browse files
authored
chore: Add obfuscate to TextSelectCopy, add Credentials to Plugin type (#55833)
- Allow obfuscating value of TextSelectCopy and replacing with bullets - Add `Credentials` field to Plugin type, get OAuthCredentials on Plugin creation if present
1 parent 6dc9d18 commit de6aa5d

File tree

3 files changed

+74
-14
lines changed

3 files changed

+74
-14
lines changed

web/packages/shared/components/TextSelectCopy/TextSelectCopy.story.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,9 @@ export const BashCommand = () => {
2929
export const NonBash = () => {
3030
return <Component text="some text to be copied" bash={false} />;
3131
};
32+
33+
export const Obfuscated = () => {
34+
return (
35+
<Component text="Super-secret-donot-tell-anyone" bash={false} obfuscate />
36+
);
37+
};

web/packages/shared/components/TextSelectCopy/TextSelectCopy.tsx

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,17 @@ export function TextSelectCopy({
3030
allowMultiline,
3131
onCopy,
3232
bash = true,
33+
obfuscate = false,
3334
...styles
3435
}: Props) {
3536
const font = fontFamily || useTheme().fonts.mono;
3637
const ref = useRef(undefined);
3738
const abortControllerRef = useRef<AbortController>(undefined);
3839
const [copyCmd, setCopyCmd] = useState(() => 'Copy');
40+
const [isObfuscated, setIsObfuscated] = useState(false);
41+
42+
const displayText =
43+
obfuscate && !bash && !isObfuscated ? obfuscateText(text) : text;
3944

4045
function onCopyClick() {
4146
abortControllerRef.current?.abort();
@@ -84,20 +89,36 @@ export function TextSelectCopy({
8489
>
8590
<Flex mr="2" style={boxStyles}>
8691
{bash && <Box mr="1" style={{ userSelect: 'none' }}>{`$`}</Box>}
87-
<div ref={ref}>{text}</div>
92+
<div ref={ref}>{displayText}</div>
93+
</Flex>
94+
<Flex gap={2} alignItems="center">
95+
{obfuscate && (
96+
<ButtonPrimary
97+
onClick={() => setIsObfuscated(!isObfuscated)}
98+
style={{
99+
maxWidth: '48px',
100+
width: '100%',
101+
padding: '4px 8px',
102+
minHeight: '10px',
103+
fontSize: '10px',
104+
}}
105+
>
106+
{isObfuscated ? 'Hide' : 'Show'}
107+
</ButtonPrimary>
108+
)}
109+
<ButtonPrimary
110+
onClick={onCopyClick}
111+
style={{
112+
maxWidth: '48px',
113+
width: '100%',
114+
padding: '4px 8px',
115+
minHeight: '10px',
116+
fontSize: '10px',
117+
}}
118+
>
119+
{copyCmd}
120+
</ButtonPrimary>
88121
</Flex>
89-
<ButtonPrimary
90-
onClick={onCopyClick}
91-
style={{
92-
maxWidth: '48px',
93-
width: '100%',
94-
padding: '4px 8px',
95-
minHeight: '10px',
96-
fontSize: '10px',
97-
}}
98-
>
99-
{copyCmd}
100-
</ButtonPrimary>
101122
</Flex>
102123
);
103124
}
@@ -109,4 +130,16 @@ type Props = {
109130
allowMultiline?: boolean;
110131
// handles styles
111132
[key: string]: any;
112-
};
133+
// only one of `bash`/`obfuscate` should be set at a time
134+
} & (
135+
| {
136+
bash: false;
137+
obfuscate?: true;
138+
}
139+
| {
140+
bash?: true;
141+
obfuscate?: false;
142+
}
143+
);
144+
145+
const obfuscateText = (value: string): string => '•'.repeat(value.length);

web/packages/teleport/src/services/integrations/types.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export type IntegrationTemplate<
7070
details?: string;
7171
statusCode: IntegrationStatusCode;
7272
status?: SD;
73+
credentials?: PluginCredentials;
7374
};
7475
// IntegrationKind string values should be in sync
7576
// with the backend value for defining the integration
@@ -228,6 +229,26 @@ export type PluginStatus<D = any> = {
228229
* contains provider-specific status information
229230
*/
230231
details?: D;
232+
/**
233+
* credentials contains information about the plugin's credentials,
234+
* if applicable, only on creation.
235+
*/
236+
credentials?: PluginCredentials;
237+
};
238+
239+
export type PluginCredentials = {
240+
OAuthCredentials?: PluginOAuthCredentials;
241+
};
242+
243+
type PluginOAuthCredentials = {
244+
/**
245+
* clientId is the OAuth client ID
246+
*/
247+
clientId: string;
248+
/**
249+
* clientSecret is the OAuth client secret
250+
*/
251+
clientSecret: string;
231252
};
232253

233254
/**

0 commit comments

Comments
 (0)