Skip to content

PM-21057 Apply truncation in View notification bar if item name is long #14631

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

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
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export function CipherInfo({ cipher, theme }: CipherInfoProps) {
</span>

${login?.username
? html`<span class=${cipherInfoSecondaryTextStyles(theme)}>${login.username}</span>`
? html`<span title=${login.username} class=${cipherInfoSecondaryTextStyles(theme)}
>${login.username}</span
>`
Comment on lines +32 to +34
Copy link
Contributor

@jprusik jprusik May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIHI, Prettier

: null}
</div>
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { Theme } from "@bitwarden/common/platform/enums";

import { themes } from "../../constants/styles";
import { spacing, themes } from "../../constants/styles";

Check warning on line 6 in apps/browser/src/autofill/content/components/notification/confirmation/body.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/content/components/notification/confirmation/body.ts#L6

Added line #L6 was not covered by tests
import { Celebrate, Keyhole, Warning } from "../../illustrations";

import { NotificationConfirmationMessage } from "./message";
Expand Down Expand Up @@ -66,7 +66,7 @@
}
`;
const notificationConfirmationBodyStyles = ({ theme }: { theme: Theme }) => css`
gap: 16px;
gap: ${spacing[4]};
display: flex;
align-items: center;
justify-content: flex-start;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
type,
}: NotificationConfirmationContainerProps) {
const headerMessage = getHeaderMessage(i18n, type, error);
const confirmationMessage = getConfirmationMessage(i18n, itemName, type, error);
const confirmationMessage = getConfirmationMessage(i18n, type, error);

Check warning on line 46 in apps/browser/src/autofill/content/components/notification/confirmation/container.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/content/components/notification/confirmation/container.ts#L46

Added line #L46 was not covered by tests
const buttonText = error ? i18n.newItem : i18n.view;
const buttonAria = chrome.i18n.getMessage("notificationViewAria", [itemName]);

Expand Down Expand Up @@ -109,19 +109,13 @@
}
`;

function getConfirmationMessage(
i18n: I18n,
itemName: string,
type?: NotificationType,
error?: string,
) {
const loginSaveConfirmation = chrome.i18n.getMessage("loginSaveConfirmation", [itemName]);
const loginUpdatedConfirmation = chrome.i18n.getMessage("loginUpdatedConfirmation", [itemName]);

function getConfirmationMessage(i18n: I18n, type?: NotificationType, error?: string) {
if (error) {
return i18n.saveFailureDetails;
}
return type === NotificationTypes.Add ? loginSaveConfirmation : loginUpdatedConfirmation;
return type === NotificationTypes.Add
? i18n.loginSaveConfirmation
: i18n.loginUpdatedConfirmation;
}

function getHeaderMessage(i18n: I18n, type?: NotificationType, error?: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { Theme } from "@bitwarden/common/platform/enums";

import { themes, typography } from "../../constants/styles";
import { spacing, themes, typography } from "../../constants/styles";

Check warning on line 6 in apps/browser/src/autofill/content/components/notification/confirmation/message.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/content/components/notification/confirmation/message.ts#L6

Added line #L6 was not covered by tests

export type NotificationConfirmationMessageProps = {
buttonAria?: string;
Expand All @@ -18,15 +18,17 @@
export function NotificationConfirmationMessage({
buttonAria,
buttonText,
itemName,
message,
messageDetails,
handleClick,
theme,
}: NotificationConfirmationMessageProps) {
return html`
<div>
<div class=${containerStyles}>
${message || buttonText
? html`
<span class=${itemNameStyles(theme)} title=${itemName}> ${itemName} </span>
<span
title=${message || buttonText}
class=${notificationConfirmationMessageStyles(theme)}
Expand Down Expand Up @@ -57,8 +59,15 @@
`;
}

const containerStyles = css`

Check warning on line 62 in apps/browser/src/autofill/content/components/notification/confirmation/message.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/content/components/notification/confirmation/message.ts#L62

Added line #L62 was not covered by tests
display: flex;
flex-wrap: wrap;
align-items: center;
gap: ${spacing[1]};
width: 100%;
`;

const baseTextStyles = css`
flex-grow: 1;
overflow-x: hidden;
text-align: left;
text-overflow: ellipsis;
Expand All @@ -74,6 +83,15 @@
font-weight: 400;
`;

const itemNameStyles = (theme: Theme) => css`

Check warning on line 86 in apps/browser/src/autofill/content/components/notification/confirmation/message.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/content/components/notification/confirmation/message.ts#L86

Added line #L86 was not covered by tests
${baseTextStyles}

color: ${themes[theme].text.main};
font-weight: 400;
white-space: nowrap;
max-width: 300px;
`;

const notificationConfirmationButtonTextStyles = (theme: Theme) => css`
${baseTextStyles}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { Theme, ThemeTypes } from "@bitwarden/common/platform/enums";

import { CloseButton } from "../buttons/close-button";
import { themes } from "../constants/styles";
import { spacing, themes } from "../constants/styles";

Check warning on line 7 in apps/browser/src/autofill/content/components/notification/header.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/content/components/notification/header.ts#L7

Added line #L7 was not covered by tests
import { BrandIconContainer } from "../icons/brand-icon-container";

import { NotificationHeaderMessage } from "./header-message";
Expand Down Expand Up @@ -47,7 +47,7 @@
standalone: boolean;
theme: Theme;
}) => css`
gap: 8px;
gap: ${spacing[2]};
display: flex;
align-items: center;
justify-content: flex-start;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function ButtonRow({ theme, primaryButton, selectButtons }: ButtonRowProp
}

const buttonRowStyles = css`
gap: 16px;
gap: ${spacing[4]};
display: flex;
align-items: center;
justify-content: space-between;
Expand Down
Loading