Skip to content

Commit

Permalink
fix(console): copy to clipboard component should display at full widt…
Browse files Browse the repository at this point in the history
…h properly (#5764)
  • Loading branch information
charIeszhao authored Apr 19, 2024
1 parent 3ddf63b commit 0b49f9c
Show file tree
Hide file tree
Showing 21 changed files with 37 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
@use '@/scss/underscore' as _;

.copyToClipboard {
display: block;
}

.description {
color: var(--color-text-secondary);
font: var(--font-body-2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function ConfigForm({
tip={conditional(!isSamlConnector && t('connectors.guide.callback_uri_description'))}
>
<CopyToClipboard
className={styles.copyToClipboard}
displayType="block"
variant="border"
value={applyCustomDomain(displayUrl)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
border: 1px solid var(--color-border);
}

&.fullWidth {
width: 100%;
&.block {
display: block;
}

.row {
Expand Down
6 changes: 3 additions & 3 deletions packages/console/src/ds-components/CopyToClipboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ type Props = {
readonly variant?: 'text' | 'contained' | 'border' | 'icon';
readonly hasVisibilityToggle?: boolean;
readonly size?: 'default' | 'small';
readonly displayType?: 'block' | 'inline';
readonly isWordWrapAllowed?: boolean;
readonly isFullWidth?: boolean;
};

type CopyState = TFuncKey<'translation', 'admin_console.general'>;
Expand All @@ -46,7 +46,7 @@ function CopyToClipboard(
variant = 'contained',
size = 'default',
isWordWrapAllowed = false,
isFullWidth = false,
displayType = 'inline',
}: Props,
ref: ForwardedRef<HTMLDivElement>
) {
Expand Down Expand Up @@ -90,7 +90,7 @@ function CopyToClipboard(
styles.container,
styles[variant],
styles[size],
isFullWidth && styles.fullWidth,
styles[displayType],
className
)}
role="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@ function ApplicationCredentials() {
</Trans>
)}
>
<CopyToClipboard isFullWidth value={id} variant="border" />
<CopyToClipboard displayType="block" value={id} variant="border" />
</FormField>
)}
{secret && (
<FormField title="application_details.application_secret">
<CopyToClipboard isFullWidth hasVisibilityToggle value={secret} variant="border" />
<CopyToClipboard
hasVisibilityToggle
displayType="block"
value={secret}
variant="border"
/>
</FormField>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
@use '@/scss/underscore' as _;

.copyToClipboard {
display: block;
}

.inputField {
margin: _.unit(4) 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function OidcCallbackUri() {
className={styles.inputField}
>
<CopyToClipboard
className={styles.copyToClipboard}
displayType="block"
variant="border"
value={applyCustomDomain(new URL(`/callback/${id}`, tenantEndpoint).toString())}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
@use '@/scss/underscore' as _;

.copyToClipboard {
display: block;
}

.inputField {
margin: _.unit(4) 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function SsoSamlSpMetadata() {
className={styles.inputField}
>
<CopyToClipboard
className={styles.copyToClipboard}
displayType="block"
variant="border"
value={serviceProviderMetadata?.entityId ?? ''}
/>
Expand All @@ -57,7 +57,7 @@ function SsoSamlSpMetadata() {
className={styles.inputField}
>
<CopyToClipboard
className={styles.copyToClipboard}
displayType="block"
variant="border"
value={serviceProviderMetadata?.assertionConsumerServiceUrl ?? ''}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function EndpointsAndCredentials({ app: { type, secret, id, isThirdParty }, oidc
{tenantEndpoint && !isThirdParty && (
<FormField title="application_details.logto_endpoint">
<CopyToClipboard
isFullWidth
displayType="block"
value={applyCustomDomain(tenantEndpoint.href)}
variant="border"
/>
Expand All @@ -63,7 +63,7 @@ function EndpointsAndCredentials({ app: { type, secret, id, isThirdParty }, oidc
{tenantEndpoint && (
<FormField title="application_details.config_endpoint">
<CopyToClipboard
isFullWidth
displayType="block"
value={applyCustomDomain(appendPath(tenantEndpoint, openIdProviderConfigPath).href)}
variant="border"
/>
Expand All @@ -90,21 +90,21 @@ function EndpointsAndCredentials({ app: { type, secret, id, isThirdParty }, oidc
)}
>
<CopyToClipboard
isFullWidth
displayType="block"
value={applyCustomDomain(oidcConfig.authorization_endpoint)}
variant="border"
/>
</FormField>
<FormField title="application_details.token_endpoint">
<CopyToClipboard
isFullWidth
displayType="block"
value={applyCustomDomain(oidcConfig.token_endpoint)}
variant="border"
/>
</FormField>
<FormField title="application_details.user_info_endpoint">
<CopyToClipboard
isFullWidth
displayType="block"
value={applyCustomDomain(oidcConfig.userinfo_endpoint)}
variant="border"
/>
Expand Down Expand Up @@ -137,15 +137,20 @@ function EndpointsAndCredentials({ app: { type, secret, id, isThirdParty }, oidc
</div>
)}
<FormField title="application_details.application_id">
<CopyToClipboard isFullWidth value={id} variant="border" />
<CopyToClipboard displayType="block" value={id} variant="border" />
</FormField>
{[
ApplicationType.Traditional,
ApplicationType.MachineToMachine,
ApplicationType.Protected,
].includes(type) && (
<FormField title="application_details.application_secret">
<CopyToClipboard hasVisibilityToggle isFullWidth value={secret} variant="border" />
<CopyToClipboard
hasVisibilityToggle
displayType="block"
value={secret}
variant="border"
/>
</FormField>
)}
</FormCard>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
@use '@/scss/underscore' as _;

.copyToClipboard {
display: block;
}

.oidcConfigPreview {
margin-top: _.unit(3);
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function OidcMetadataForm({ providerConfig, config, providerName }: Props) {
>
{providerName === SsoProviderName.GOOGLE_WORKSPACE ? (
<CopyToClipboard
className={styles.copyToClipboard}
displayType="block"
variant="border"
// TODO: this hard-coded value should align with the `googleIssuer` value defined in `packages/core/src/sso/GoogleWorkspaceSsoConnector/index.ts`.
value={providerConfig?.issuer ?? 'https://accounts.google.com'}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
@use '@/scss/underscore' as _;

.copyToClipboard {
display: block;
}

.table {
width: 100%;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ function SamlAttributeMapping({ samlProviderConfig }: Props) {
return (
<tr key={key} className={styles.row}>
<td>
<CopyToClipboard className={styles.copyToClipboard} variant="border" value={key} />
<CopyToClipboard displayType="block" variant="border" value={key} />
</td>
<td>
{/* Show default value of `id` field to show that Logto has handled the default value. */}
{/* Per SAML protocol, this field is not eligible to change in most cases. */}
{key === 'id' ? (
<CopyToClipboard
className={styles.copyToClipboard}
displayType="block"
variant="border"
value={conditionalString(samlProviderConfig?.defaultAttributeMapping[key])}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,4 @@
.errorStatus {
background: var(--color-on-error-container);
}

.copyToClipboard {
margin-left: _.unit(1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function CertificatePreview({
),
}}
/>
<CopyToClipboard className={styles.copyToClipboard} variant="icon" value={x509Certificate} />
<CopyToClipboard displayType="block" variant="icon" value={x509Certificate} />
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import CopyToClipboard from '@/ds-components/CopyToClipboard';
import FormField from '@/ds-components/FormField';
import useCustomDomain from '@/hooks/use-custom-domain';

import * as styles from './index.module.scss';

type Props = {
readonly ssoConnectorId: string;
};
Expand All @@ -19,7 +17,7 @@ function OidcConnectorSpInfo({ ssoConnectorId }: Props) {
<FormField title="enterprise_sso.basic_info.oidc.redirect_uri_field_name">
{/* Generated and passed in by Admin console. */}
<CopyToClipboard
className={styles.copyToClipboard}
displayType="block"
variant="border"
value={applyCustomDomain(new URL(`/callback/${ssoConnectorId}`, tenantEndpoint).toString())}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import useCustomDomain from '@/hooks/use-custom-domain';

import { type SamlProviderConfig } from '../../types/saml';

import * as styles from './index.module.scss';

type Props = {
readonly samlProviderConfig?: SamlProviderConfig;
};
Expand All @@ -23,7 +21,7 @@ function SamlConnectorSpInfo({ samlProviderConfig }: Props) {
<>
<FormField title="enterprise_sso.basic_info.saml.acs_url_field_name">
<CopyToClipboard
className={styles.copyToClipboard}
displayType="block"
variant="border"
value={conditionalString(
samlProviderConfig?.serviceProvider &&
Expand All @@ -33,7 +31,7 @@ function SamlConnectorSpInfo({ samlProviderConfig }: Props) {
</FormField>
<FormField title="enterprise_sso.basic_info.saml.audience_uri_field_name">
<CopyToClipboard
className={styles.copyToClipboard}
displayType="block"
variant="border"
value={conditionalString(
samlProviderConfig?.serviceProvider &&
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function ProfileForm({ currentTenantId }: Props) {
return (
<FormCard title="tenants.settings.title" description="tenants.settings.description">
<FormField title="tenants.settings.tenant_id">
<CopyToClipboard isFullWidth value={currentTenantId} variant="border" />
<CopyToClipboard displayType="block" value={currentTenantId} variant="border" />
</FormField>
<FormField isRequired title="tenants.settings.tenant_name">
<TextInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const getAndCheckValueByFieldName = async (page: Page, fieldName: string, expect
{ text: fieldName }
);
const value = await valueField.$eval(
[dcls('copyToClipboard'), dcls('row'), dcls('content')].join(' '),
[dcls('container'), dcls('row'), dcls('content')].join(' '),
(element) => element.textContent
);

Expand Down

0 comments on commit 0b49f9c

Please sign in to comment.