mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 23:03:32 +00:00
pm-18084 Connect new notification bar experience buttons (#13339)
* pm-18084 -initial structure and functions implemented * update stories to match new args * change handleSave name * include new login button for save * fix stories
This commit is contained in:
@@ -12,6 +12,7 @@ type Args = {
|
|||||||
ciphers: NotificationCipherData[];
|
ciphers: NotificationCipherData[];
|
||||||
notificationType: NotificationType;
|
notificationType: NotificationType;
|
||||||
theme: Theme;
|
theme: Theme;
|
||||||
|
handleEditOrUpdateAction: (e: Event) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { NotificationFooter } from "../../notification/footer";
|
|||||||
type Args = {
|
type Args = {
|
||||||
notificationType: NotificationType;
|
notificationType: NotificationType;
|
||||||
theme: Theme;
|
theme: Theme;
|
||||||
|
handleSaveAction: (e: Event) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { ButtonRow } from "../../rows/button-row";
|
|||||||
|
|
||||||
type Args = {
|
type Args = {
|
||||||
theme: Theme;
|
theme: Theme;
|
||||||
|
buttonAction: (e: Event) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@@ -19,11 +19,13 @@ export function NotificationBody({
|
|||||||
ciphers,
|
ciphers,
|
||||||
notificationType,
|
notificationType,
|
||||||
theme = ThemeTypes.Light,
|
theme = ThemeTypes.Light,
|
||||||
|
handleEditOrUpdateAction,
|
||||||
}: {
|
}: {
|
||||||
ciphers: NotificationCipherData[];
|
ciphers: NotificationCipherData[];
|
||||||
customClasses?: string[];
|
customClasses?: string[];
|
||||||
notificationType?: NotificationType;
|
notificationType?: NotificationType;
|
||||||
theme: Theme;
|
theme: Theme;
|
||||||
|
handleEditOrUpdateAction: (e: Event) => void;
|
||||||
}) {
|
}) {
|
||||||
// @TODO get client vendor from context
|
// @TODO get client vendor from context
|
||||||
const isSafari = false;
|
const isSafari = false;
|
||||||
@@ -37,9 +39,7 @@ export function NotificationBody({
|
|||||||
cipher,
|
cipher,
|
||||||
notificationType,
|
notificationType,
|
||||||
theme,
|
theme,
|
||||||
handleAction: () => {
|
handleAction: handleEditOrUpdateAction,
|
||||||
// @TODO connect update or edit actions to handler
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -24,7 +24,13 @@ export function NotificationContainer({
|
|||||||
theme = ThemeTypes.Light,
|
theme = ThemeTypes.Light,
|
||||||
type,
|
type,
|
||||||
ciphers,
|
ciphers,
|
||||||
}: NotificationBarIframeInitData & { handleCloseNotification: (e: Event) => void } & {
|
handleSaveAction,
|
||||||
|
handleEditOrUpdateAction,
|
||||||
|
}: NotificationBarIframeInitData & {
|
||||||
|
handleCloseNotification: (e: Event) => void;
|
||||||
|
handleSaveAction: (e: Event) => void;
|
||||||
|
handleEditOrUpdateAction: (e: Event) => void;
|
||||||
|
} & {
|
||||||
i18n: { [key: string]: string };
|
i18n: { [key: string]: string };
|
||||||
type: NotificationType; // @TODO typing override for generic `NotificationBarIframeInitData.type`
|
type: NotificationType; // @TODO typing override for generic `NotificationBarIframeInitData.type`
|
||||||
ciphers: NotificationCipherData[];
|
ciphers: NotificationCipherData[];
|
||||||
@@ -42,12 +48,14 @@ export function NotificationContainer({
|
|||||||
})}
|
})}
|
||||||
${showBody
|
${showBody
|
||||||
? NotificationBody({
|
? NotificationBody({
|
||||||
|
handleEditOrUpdateAction,
|
||||||
ciphers,
|
ciphers,
|
||||||
notificationType: type,
|
notificationType: type,
|
||||||
theme,
|
theme,
|
||||||
})
|
})
|
||||||
: null}
|
: null}
|
||||||
${NotificationFooter({
|
${NotificationFooter({
|
||||||
|
handleSaveAction,
|
||||||
theme,
|
theme,
|
||||||
notificationType: type,
|
notificationType: type,
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -12,9 +12,11 @@ import { ActionRow } from "../rows/action-row";
|
|||||||
import { ButtonRow } from "../rows/button-row";
|
import { ButtonRow } from "../rows/button-row";
|
||||||
|
|
||||||
export function NotificationFooter({
|
export function NotificationFooter({
|
||||||
|
handleSaveAction,
|
||||||
notificationType,
|
notificationType,
|
||||||
theme,
|
theme,
|
||||||
}: {
|
}: {
|
||||||
|
handleSaveAction: (e: Event) => void;
|
||||||
notificationType?: NotificationType;
|
notificationType?: NotificationType;
|
||||||
theme: Theme;
|
theme: Theme;
|
||||||
}) {
|
}) {
|
||||||
@@ -25,8 +27,12 @@ export function NotificationFooter({
|
|||||||
return html`
|
return html`
|
||||||
<div class=${notificationFooterStyles({ theme })}>
|
<div class=${notificationFooterStyles({ theme })}>
|
||||||
${isChangeNotification
|
${isChangeNotification
|
||||||
? ActionRow({ itemText: saveNewItemText, handleAction: () => {}, theme })
|
? ActionRow({
|
||||||
: ButtonRow({ theme })}
|
itemText: saveNewItemText,
|
||||||
|
handleAction: handleSaveAction,
|
||||||
|
theme,
|
||||||
|
})
|
||||||
|
: ButtonRow({ theme, buttonAction: handleSaveAction })}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,18 @@ import { spacing, themes } from "../../../content/components/constants/styles";
|
|||||||
import { Folder, User } from "../../../content/components/icons";
|
import { Folder, User } from "../../../content/components/icons";
|
||||||
import { DropdownMenu } from "../dropdown-menu";
|
import { DropdownMenu } from "../dropdown-menu";
|
||||||
|
|
||||||
export function ButtonRow({ theme }: { theme: Theme }) {
|
export function ButtonRow({
|
||||||
|
theme,
|
||||||
|
buttonAction,
|
||||||
|
}: {
|
||||||
|
theme: Theme;
|
||||||
|
buttonAction: (e: Event) => void;
|
||||||
|
}) {
|
||||||
return html`
|
return html`
|
||||||
<div class=${buttonRowStyles}>
|
<div class=${buttonRowStyles}>
|
||||||
${[
|
${[
|
||||||
ActionButton({
|
ActionButton({
|
||||||
buttonAction: () => {},
|
buttonAction: buttonAction,
|
||||||
buttonText: "Action Button",
|
buttonText: "Action Button",
|
||||||
theme,
|
theme,
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -97,6 +97,8 @@ function initNotificationBar(message: NotificationBarWindowMessage) {
|
|||||||
type: notificationBarIframeInitData.type as NotificationType,
|
type: notificationBarIframeInitData.type as NotificationType,
|
||||||
theme: resolvedTheme,
|
theme: resolvedTheme,
|
||||||
handleCloseNotification,
|
handleCloseNotification,
|
||||||
|
handleSaveAction,
|
||||||
|
handleEditOrUpdateAction,
|
||||||
i18n,
|
i18n,
|
||||||
ciphers: cipherData,
|
ciphers: cipherData,
|
||||||
}),
|
}),
|
||||||
@@ -169,14 +171,27 @@ function initNotificationBar(message: NotificationBarWindowMessage) {
|
|||||||
|
|
||||||
globalThis.addEventListener("resize", adjustHeight);
|
globalThis.addEventListener("resize", adjustHeight);
|
||||||
adjustHeight();
|
adjustHeight();
|
||||||
}
|
|
||||||
|
|
||||||
function handleCloseNotification(e: Event) {
|
function handleCloseNotification(e: Event) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
sendPlatformMessage({
|
sendPlatformMessage({
|
||||||
command: "bgCloseNotificationBar",
|
command: "bgCloseNotificationBar",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function handleEditOrUpdateAction(e: Event) {
|
||||||
|
const notificationType = initData.type;
|
||||||
|
e.preventDefault();
|
||||||
|
notificationType === "add" ? sendSaveCipherMessage(true) : sendSaveCipherMessage(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSaveAction(e: Event) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
sendSaveCipherMessage(removeIndividualVault());
|
||||||
|
if (removeIndividualVault()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function handleTypeAdd() {
|
function handleTypeAdd() {
|
||||||
setContent(document.getElementById("template-add") as HTMLTemplateElement);
|
setContent(document.getElementById("template-add") as HTMLTemplateElement);
|
||||||
|
|||||||
Reference in New Issue
Block a user