base
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
export * from "./list-root";
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
import { NotificationCardListRoot } from "./notification-card/root";
|
||||
|
||||
export type TNotificationListRoot = {
|
||||
workspaceSlug: string;
|
||||
workspaceId: string;
|
||||
};
|
||||
|
||||
export function NotificationListRoot(props: TNotificationListRoot) {
|
||||
return <NotificationCardListRoot {...props} />;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
import { replaceUnderscoreIfSnakeCase } from "@plane/utils";
|
||||
import type { TNotificationContentMap } from "@/components/workspace-notifications/sidebar/notification-card/content";
|
||||
|
||||
// Additional notification content map for CE (empty - EE extends this)
|
||||
export const ADDITIONAL_NOTIFICATION_CONTENT_MAP: TNotificationContentMap = {};
|
||||
|
||||
// Fallback action renderer for fields not in the map
|
||||
export const renderAdditionalAction = (notificationField: string, verb: string | undefined) => {
|
||||
const baseAction = !["comment", "archived_at"].includes(notificationField) ? verb : "";
|
||||
return `${baseAction} ${replaceUnderscoreIfSnakeCase(notificationField)}`;
|
||||
};
|
||||
|
||||
// Fallback value renderer for fields not in the map
|
||||
export const renderAdditionalValue = (
|
||||
_notificationField: string | undefined,
|
||||
newValue: string | undefined,
|
||||
_oldValue: string | undefined
|
||||
) => newValue;
|
||||
|
||||
export const shouldShowConnector = (notificationField: string | undefined) =>
|
||||
!["comment", "archived_at", "None", "assignees", "labels", "start_date", "target_date", "parent"].includes(
|
||||
notificationField || ""
|
||||
);
|
||||
|
||||
export const shouldRender = (notificationField: string | undefined, verb: string | undefined) => verb !== "deleted";
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
import { observer } from "mobx-react";
|
||||
// plane imports
|
||||
import { ENotificationLoader, ENotificationQueryParamType } from "@plane/constants";
|
||||
import { useTranslation } from "@plane/i18n";
|
||||
// components
|
||||
import { NotificationItem } from "@/components/workspace-notifications/sidebar/notification-card/item";
|
||||
// hooks
|
||||
import { useWorkspaceNotifications } from "@/hooks/store/notifications";
|
||||
|
||||
type TNotificationCardListRoot = {
|
||||
workspaceSlug: string;
|
||||
workspaceId: string;
|
||||
};
|
||||
|
||||
export const NotificationCardListRoot = observer(function NotificationCardListRoot(props: TNotificationCardListRoot) {
|
||||
const { workspaceSlug, workspaceId } = props;
|
||||
// hooks
|
||||
const { loader, paginationInfo, getNotifications, notificationIdsByWorkspaceId } = useWorkspaceNotifications();
|
||||
const notificationIds = notificationIdsByWorkspaceId(workspaceId);
|
||||
const { t } = useTranslation();
|
||||
|
||||
const getNextNotifications = async () => {
|
||||
try {
|
||||
await getNotifications(workspaceSlug, ENotificationLoader.PAGINATION_LOADER, ENotificationQueryParamType.NEXT);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
if (!workspaceSlug || !workspaceId || !notificationIds) return <></>;
|
||||
return (
|
||||
<div>
|
||||
{notificationIds.map((notificationId: string) => (
|
||||
<NotificationItem key={notificationId} workspaceSlug={workspaceSlug} notificationId={notificationId} />
|
||||
))}
|
||||
|
||||
{/* fetch next page notifications */}
|
||||
{paginationInfo && paginationInfo?.next_page_results && (
|
||||
<>
|
||||
{loader === ENotificationLoader.PAGINATION_LOADER ? (
|
||||
<div className="flex items-center justify-center py-4 text-13 font-medium">
|
||||
<div className="text-accent-secondary">{t("loading")}...</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex items-center justify-center py-4 text-13 font-medium" onClick={getNextNotifications}>
|
||||
<div className="cursor-pointer text-accent-secondary transition-all hover:text-accent-primary">
|
||||
{t("load_more")}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user