Skip to content

Commit

Permalink
Change token secret to have middle truncation
Browse files Browse the repository at this point in the history
  • Loading branch information
ashley-o0o committed Nov 22, 2024
1 parent 01165de commit c82491d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 8 additions & 2 deletions frontend/src/components/InlineTruncatedClipboardCopy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as React from 'react';

type Props = {
textToCopy: string;
truncatePosition?: 'start' | 'middle' | 'end';
testId?: string;
maxWidth?: number;
};
Expand All @@ -12,7 +13,12 @@ type Props = {
* https://github.com/patternfly/patternfly-react/issues/10890
**/

const InlineTruncatedClipboardCopy: React.FC<Props> = ({ textToCopy, testId, maxWidth }) => (
const InlineTruncatedClipboardCopy: React.FC<Props> = ({
textToCopy,
testId,
maxWidth,
truncatePosition,
}) => (
<ClipboardCopy
variant="inline-compact"
style={{ display: 'inline-flex', maxWidth }}
Expand All @@ -23,7 +29,7 @@ const InlineTruncatedClipboardCopy: React.FC<Props> = ({ textToCopy, testId, max
}}
data-testid={testId}
>
<Truncate content={textToCopy} />
<Truncate content={textToCopy} position={truncatePosition} />
</ClipboardCopy>
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { ClipboardCopy, HelperText, HelperTextItem, Skeleton } from '@patternfly/react-core';
import { HelperText, HelperTextItem, Skeleton } from '@patternfly/react-core';
import { SecretKind } from '~/k8sTypes';
import InlineTruncatedClipboardCopy from '~/components/InlineTruncatedClipboardCopy';

type ServingRuntimeTokenDisplayProps = {
token: SecretKind;
Expand All @@ -27,7 +28,13 @@ const ServingRuntimeTokenDisplay: React.FC<ServingRuntimeTokenDisplayProps> = ({
);
}

return <ClipboardCopy isReadOnly>{atob(token.data.token)}</ClipboardCopy>;
return (

Check warning on line 31 in frontend/src/pages/modelServing/screens/projects/ModelMeshSection/ServingRuntimeTokenDisplay.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/pages/modelServing/screens/projects/ModelMeshSection/ServingRuntimeTokenDisplay.tsx#L31

Added line #L31 was not covered by tests
<InlineTruncatedClipboardCopy
testId="token-secret"
textToCopy={atob(token.data.token)}
truncatePosition="middle"
/>
);
};

export default ServingRuntimeTokenDisplay;

0 comments on commit c82491d

Please sign in to comment.