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

Change token secret to have middle truncation #3505

Merged
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
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 @@
);
}

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;
Loading