address comments.

This commit is contained in:
ItzNotABug
2024-09-25 17:57:38 +05:30
parent 3d456c6ccc
commit ae8ee98677
3 changed files with 29 additions and 22 deletions
+23 -15
View File
@@ -19,22 +19,30 @@
let currentIndex = 0;
let openModalOnMobile = false;
$: pagePathName = $page.url.pathname;
function getPageScope(pathname: string) {
const isProjectPage = pathname.includes('project-[project]');
const isOrganizationPage = pathname.includes('organization-[organization]');
$: filteredModalAlerts = $bottomModalAlerts
.sort((a, b) => b.importance - a.importance)
.filter((alert) => {
const isProjectPage = pagePathName.includes('project-');
const isOrganizationPage = pagePathName.includes('organization-');
return { isProjectPage, isOrganizationPage };
}
return (
alert.show &&
shouldShowNotification(alert.id) &&
(alert.scope === 'everywhere' ||
(isProjectPage && alert.scope === 'project') ||
(isOrganizationPage && alert.scope === 'organization'))
);
});
function filterModalAlerts(alerts: BottomModalAlertItem[], pathname: string) {
const { isProjectPage, isOrganizationPage } = getPageScope(pathname);
return alerts
.sort((a, b) => b.importance - a.importance)
.filter((alert) => {
return (
alert.show &&
shouldShowNotification(alert.id) &&
(!alert.scope ||
(isProjectPage && alert.scope === 'project') ||
(isOrganizationPage && alert.scope === 'organization'))
);
});
}
$: filteredModalAlerts = filterModalAlerts($bottomModalAlerts, $page.route.id);
$: currentModalAlert = filteredModalAlerts[currentIndex] as BottomModalAlertItem;
@@ -161,7 +169,7 @@
})}
external={!!currentModalAlert.cta.external}
fullWidthMobile>
{shouldShowUpgrade ? 'Upgrade plan' : currentModalAlert.cta.text}
{currentModalAlert.cta.text}
</Button>
{#if currentModalAlert.learnMore}
+2 -2
View File
@@ -23,7 +23,7 @@ export type BottomModalAlertItem = {
importance?: number;
closed?: () => void;
scope?: 'organization' | 'project' | 'everywhere';
scope?: 'organization' | 'project';
notificationHideOptions?: NotificationCoolOffOptions;
};
@@ -42,11 +42,11 @@ export const showBottomModalAlert = (notification: BottomModalAlertItem) => {
show: true,
importance: 5,
isHtml: false,
scope: 'project',
...notification
};
bottomModalAlerts.update((all) => {
if (all.some((t) => t.id === notification.id)) return all;
return [...all, defaults as BottomModalAlertItem];
});
};
+4 -5
View File
@@ -10,19 +10,18 @@ const listOfPromotions: BottomModalAlertItem[] = [
dark: RolesDark,
light: RolesLight
},
title: 'Member roles now on Pro plans',
title: 'Roles are available now',
message:
'Enhance your workflow and security by assigning roles to members. <br/><b>Try it now for free until 1st January 2025.</b>',
'Enhance your workflow and security by assigning roles to members. <br/><b>Try for free until Jan 1st 2025 on paid plans.</b>',
isHtml: true,
scope: 'organization',
plan: 'pro',
cta: {
text: 'Try Now',
text: 'Try now',
link: ({ organization }) => `${base}/organization-${organization.$id}/members`
},
learnMore: {
text: 'Learn More',
text: 'Learn more',
link: () => 'https://appwrite.io/docs/advanced/platform/roles'
}
}