-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(ui): Add notification system for rss feeds #7397
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
Open
sumit-tft
wants to merge
10
commits into
prowler-cloud:master
Choose a base branch
from
sumit-tft:feature/add-notification-system
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
27754b0
feat(ui): Add notification system for rss feeds
sumit-tft c3cfab3
srn Updated the logic to show the notification icon
sumit-tft 5803cdf
srn Fixed lint issue
sumit-tft d429be0
Merge branch 'upstream/master' into feature/add-notification-system
sumit-tft 921cc62
srn Lint fixes
sumit-tft 8ee9bfc
Merge branch 'upstream/master' into feature/add-notification-system
sumit-tft 5add4f7
Merge branch 'upstream/master' into feature/add-notification-system
sumit-tft cd11c0a
Merge branch 'upstream/master' into feature/add-notification-system
sumit-tft a4016b3
srn PR comments
sumit-tft 407c80a
srn Added missing nullable
sumit-tft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"use server"; | ||
|
||
import Parser from "rss-parser"; | ||
|
||
const RSS_FEED_URL = process.env.RSS_FEED_URL || ""; | ||
|
||
export const fetchFeeds = async (): Promise<any | any[]> => { | ||
if (RSS_FEED_URL?.trim()?.length > 0) { | ||
const parser = new Parser(); | ||
try { | ||
// TODO: Need to update return logic when actual URL is updated for RSS FEED | ||
const feed = await parser.parseURL(RSS_FEED_URL); | ||
return [ | ||
{ | ||
title: feed.title, | ||
description: feed.description, | ||
link: feed.link, | ||
lastBuildDate: new Date(feed.lastBuildDate).toLocaleString(), | ||
}, | ||
]; | ||
} catch (error) { | ||
// eslint-disable-next-line no-console | ||
console.error("Error fetching RSS feed:", error); | ||
return []; | ||
} | ||
} else { | ||
// eslint-disable-next-line no-console | ||
console.warn("RSS url not set"); | ||
return []; | ||
} | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./feeds"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
"use client"; | ||
|
||
import Link from "next/link"; | ||
import { useState } from "react"; | ||
|
||
import { BellIcon as Icon } from "@/components/icons"; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuTrigger, | ||
} from "@/components/ui/dropdown-menu/dropdown-menu"; | ||
import { cn } from "@/lib/utils"; | ||
|
||
import { Button } from "../ui/button/button"; | ||
|
||
interface Feed { | ||
title: string; | ||
link: string; | ||
description: string; | ||
lastBuildDate: string; | ||
} | ||
|
||
interface FeedsClientProps { | ||
initialFeeds?: Feed[]; | ||
} | ||
|
||
// TODO: Need to update FeedsClientProps with actual interface when actual RSS data finialized | ||
export const FeedsClient: React.FC<FeedsClientProps> = ({ | ||
initialFeeds = [], | ||
}) => { | ||
const [feed] = useState(initialFeeds); | ||
|
||
return ( | ||
<> | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button | ||
variant="outline" | ||
className={cn( | ||
"relative", | ||
"rounded-full", | ||
"bg-transparent", | ||
"p-2", | ||
"h-8", | ||
"w-8", | ||
)} | ||
> | ||
<Icon size={18} /> | ||
{/* TODO: Update this condition once the RSS data response structure is finalized */} | ||
{feed.length > 0 && ( | ||
<span className="absolute right-0 top-0 h-2 w-2 rounded-full bg-red-500 dark:bg-gray-400"></span> | ||
)} | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent align="end" forceMount> | ||
<h3 className="px-2 text-base font-medium">Feeds</h3> | ||
<div className="max-h-48 w-80 overflow-y-auto"> | ||
{feed.length === 0 ? ( | ||
<p className="py-4 text-center text-gray-500"> | ||
No feeds available | ||
</p> | ||
) : ( | ||
feed.map((item, index) => ( | ||
<DropdownMenuItem key={index} className="hover:cursor-pointer"> | ||
<Link | ||
href={item.link} | ||
target="_blank" | ||
className="flex flex-col" | ||
> | ||
<h3 className="text-small font-medium leading-none"> | ||
{item.title} | ||
</h3> | ||
<p className="text-sm text-gray-500">{item.description}</p> | ||
<span className="text-muted-foreground mt-1 text-xs text-gray-400"> | ||
{item.lastBuildDate} | ||
</span> | ||
</Link> | ||
</DropdownMenuItem> | ||
)) | ||
)} | ||
</div> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
</> | ||
); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { fetchFeeds } from "@/actions/feeds"; | ||
import { FeedsClient } from "@/components/feeds"; | ||
|
||
export const FeedsServer = async () => { | ||
const feeds = await fetchFeeds(); | ||
|
||
return <FeedsClient initialFeeds={feeds} />; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./feeds-client"; | ||
export * from "./feeds-server"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @sumit-tft , can we make sure the size matches the rest of the items?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, please let me know if any changes are required :)