Skip to content

Commit

Permalink
edit page changes as per new page header (#257)
Browse files Browse the repository at this point in the history
* edit as per new page header fixed

Signed-off-by: Riya Saxena <[email protected]>

* bug fix

Signed-off-by: Riya Saxena <[email protected]>

* bug fix

Signed-off-by: Riya Saxena <[email protected]>

---------

Signed-off-by: Riya Saxena <[email protected]>
Signed-off-by: Riya <[email protected]>
  • Loading branch information
riysaxen-amzn authored Sep 6, 2024
1 parent 68316a0 commit 0ec08ca
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 22 deletions.
34 changes: 21 additions & 13 deletions public/pages/CreateChannel/CreateChannel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,25 @@ export function CreateChannel(props: CreateChannelsProps) {
});

useEffect(() => {
setBreadcrumbs([ BREADCRUMBS.NOTIFICATIONS,
const { edit } = props;
const breadcrumbs = [
BREADCRUMBS.NOTIFICATIONS,
BREADCRUMBS.CHANNELS,
props.edit ? BREADCRUMBS.EDIT_CHANNEL : BREADCRUMBS.CREATE_CHANNEL]);
];
if (edit) {
if (getUseUpdatedUx()) {
breadcrumbs.push(BREADCRUMBS.EDIT_CHANNEL_DETAILS(name))
}
breadcrumbs.push(BREADCRUMBS.EDIT_CHANNEL)
} else {
breadcrumbs.push(BREADCRUMBS.CREATE_CHANNEL)
}
window.scrollTo(0, 0);

setBreadcrumbs(breadcrumbs);
if (props.edit) {
getChannel();
}
}, []);
}, [name, getUseUpdatedUx()]);

const getChannel = async () => {
const id = props.match.params.id;
Expand Down Expand Up @@ -415,7 +425,7 @@ export function CreateChannel(props: CreateChannelsProps) {
microsoftTeamsWebhook={microsoftTeamsWebhook}
setMicrosoftTeamsWebhook={setMicrosoftTeamsWebhook}
/>
): channelType === BACKEND_CHANNEL_TYPE.EMAIL ? (
) : channelType === BACKEND_CHANNEL_TYPE.EMAIL ? (
<EmailSettings
senderType={senderType}
setSenderType={setSenderType}
Expand Down Expand Up @@ -496,15 +506,14 @@ export function CreateChannel(props: CreateChannelsProps) {
const config = createConfigObject();
const request = props.edit
? servicesContext.notificationService.updateConfig(
id!,
config
)
id!,
config
)
: servicesContext.notificationService.createConfig(config);
await request
.then((response) => {
coreContext.notifications.toasts.addSuccess(
`Channel ${name} successfully ${
props.edit ? 'updated' : 'created'
`Channel ${name} successfully ${props.edit ? 'updated' : 'created'
}.`
);
setTimeout(() => (location.hash = prevURL), SERVER_DELAY);
Expand All @@ -514,9 +523,8 @@ export function CreateChannel(props: CreateChannelsProps) {
coreContext.notifications.toasts.addError(
error?.body || error,
{
title: `Failed to ${
props.edit ? 'update' : 'create'
} channel.`,
title: `Failed to ${props.edit ? 'update' : 'create'
} channel.`,
}
);
});
Expand Down
20 changes: 13 additions & 7 deletions public/pages/Emails/CreateRecipientGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,25 @@ export function CreateRecipientGroup(props: CreateRecipientGroupProps) {
};

useEffect(() => {
setBreadcrumbs([
const { edit } = props;
const breadcrumbs = [
BREADCRUMBS.NOTIFICATIONS,
BREADCRUMBS.EMAIL_GROUPS,
props.edit
? BREADCRUMBS.EDIT_RECIPIENT_GROUP
: BREADCRUMBS.CREATE_RECIPIENT_GROUP,
]);
];
if (edit) {
if (getUseUpdatedUx()) {
breadcrumbs.push(BREADCRUMBS.EDIT_RECIPIENT_GROUP_DETAILS(name))
}
breadcrumbs.push(BREADCRUMBS.EDIT_RECIPIENT_GROUP)
} else {
breadcrumbs.push(BREADCRUMBS.CREATE_RECIPIENT_GROUP)
}
window.scrollTo(0, 0);

setBreadcrumbs(breadcrumbs);
if (props.edit) {
getRecipientGroup();
}
}, []);
}, [name, getUseUpdatedUx()]);

const getRecipientGroup = async () => {
const id = props.match.params?.id;
Expand Down
12 changes: 10 additions & 2 deletions public/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export const BREADCRUMBS = Object.freeze({
CHANNELS: { text: 'Channels', href: `#${ROUTES.CHANNELS}` },
CHANNEL_DETAILS: { text: 'Channels', href: `#${ROUTES.CHANNEL_DETAILS}` },
CREATE_CHANNEL: { text: 'Create channel', href: `#${ROUTES.CREATE_CHANNEL}` },
EDIT_CHANNEL: { text: 'Edit channel' },
EDIT_CHANNEL: { text: 'Edit channel', href: `#${ROUTES.EDIT_CHANNEL}` },
EDIT_CHANNEL_DETAILS: (name: string) => ({
text: name,
href: `#${ROUTES.EDIT_CHANNEL}`,
}),
EMAIL_SENDERS: { text: 'Email senders', href: `#${ROUTES.EMAIL_SENDERS}` },
EMAIL_GROUPS: { text: 'Email recipient groups', href: `#${ROUTES.EMAIL_GROUPS}` },
CREATE_SENDER: {
Expand All @@ -51,7 +55,11 @@ export const BREADCRUMBS = Object.freeze({
text: 'Create recipient group',
href: `#${ROUTES.CREATE_RECIPIENT_GROUP}`,
},
EDIT_RECIPIENT_GROUP: { text: 'Edit recipient group' },
EDIT_RECIPIENT_GROUP: { text: 'Edit recipient group', href: `#${ROUTES.EDIT_RECIPIENT_GROUP}`},
EDIT_RECIPIENT_GROUP_DETAILS: (name: string) => ({
text: name,
href: `#${ROUTES.EDIT_RECIPIENT_GROUP}`,
}),
});

export const ENCRYPTION_TYPE = Object.freeze({
Expand Down

0 comments on commit 0ec08ca

Please sign in to comment.