-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Use a shadcn dialog for the announcement #3604
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
Merged
Merged
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "roo-cline": patch | ||
| --- | ||
|
|
||
| Update announcement to use a @shadcn/ui dialog |
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 |
|---|---|---|
| @@ -1,113 +1,94 @@ | ||
| import { VSCodeButton, VSCodeLink } from "@vscode/webview-ui-toolkit/react" | ||
| import { memo } from "react" | ||
| import { useAppTranslation } from "@/i18n/TranslationContext" | ||
| import { useState, memo } from "react" | ||
| import { Trans } from "react-i18next" | ||
| import { VSCodeLink } from "@vscode/webview-ui-toolkit/react" | ||
|
|
||
| import { useAppTranslation } from "@src/i18n/TranslationContext" | ||
| import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@src/components/ui" | ||
|
|
||
| interface AnnouncementProps { | ||
| hideAnnouncement: () => void | ||
| } | ||
| /* | ||
| You must update the latestAnnouncementId in ClineProvider for new announcements to show to users. This new id will be compared with whats in state for the 'last announcement shown', and if it's different then the announcement will render. As soon as an announcement is shown, the id will be updated in state. This ensures that announcements are not shown more than once, even if the user doesn't close it themselves. | ||
| */ | ||
| const Announcement = ({ hideAnnouncement }: AnnouncementProps) => { | ||
| const { t } = useAppTranslation() | ||
|
|
||
| const discordLink = ( | ||
| <VSCodeLink | ||
| href="https://discord.gg/roocode" | ||
| onClick={(e) => { | ||
| e.preventDefault() | ||
| window.postMessage( | ||
| { type: "action", action: "openExternal", data: { url: "https://discord.gg/roocode" } }, | ||
| "*", | ||
| ) | ||
| }}> | ||
| Discord | ||
| </VSCodeLink> | ||
| ) | ||
| /** | ||
| * You must update the `latestAnnouncementId` in ClineProvider for new | ||
| * announcements to show to users. This new id will be compared with what's in | ||
| * state for the 'last announcement shown', and if it's different then the | ||
| * announcement will render. As soon as an announcement is shown, the id will be | ||
| * updated in state. This ensures that announcements are not shown more than | ||
| * once, even if the user doesn't close it themselves. | ||
| */ | ||
|
|
||
| const redditLink = ( | ||
| <VSCodeLink | ||
| href="https://reddit.com/r/RooCode" | ||
| onClick={(e) => { | ||
| e.preventDefault() | ||
| window.postMessage( | ||
| { type: "action", action: "openExternal", data: { url: "https://reddit.com/r/RooCode" } }, | ||
| "*", | ||
| ) | ||
| }}> | ||
| </VSCodeLink> | ||
| ) | ||
| const Announcement = ({ hideAnnouncement }: AnnouncementProps) => { | ||
| const { t } = useAppTranslation() | ||
| const [open, setOpen] = useState(true) | ||
|
|
||
| return ( | ||
| <div className="flex flex-col justify-center absolute top-0 bottom-0 left-0 right-0 z-50 p-10 bg-black/50"> | ||
| <div | ||
| style={{ | ||
| backgroundColor: "var(--vscode-editor-background)", | ||
| borderRadius: "3px", | ||
| padding: "12px 16px", | ||
| margin: "5px 15px 5px 15px", | ||
| position: "relative", | ||
| flexShrink: 0, | ||
| }}> | ||
| <VSCodeButton | ||
| appearance="icon" | ||
| onClick={hideAnnouncement} | ||
| title={t("chat:announcement.hideButton")} | ||
| style={{ position: "absolute", top: "8px", right: "8px" }}> | ||
| <span className="codicon codicon-close"></span> | ||
| </VSCodeButton> | ||
| <h2 style={{ margin: "0 0 8px" }}>{t("chat:announcement.title")}</h2> | ||
|
|
||
| <p style={{ margin: "5px 0px" }}>{t("chat:announcement.description")}</p> | ||
|
|
||
| <h3 style={{ margin: "12px 0 5px", fontSize: "14px" }}>{t("chat:announcement.whatsNew")}</h3> | ||
| <ul style={{ margin: "5px 0" }}> | ||
| <li> | ||
| •{" "} | ||
| <Trans | ||
| i18nKey="chat:announcement.feature1" | ||
| components={{ | ||
| bold: <b />, | ||
| code: <code />, | ||
| }} | ||
| /> | ||
| </li> | ||
| <li> | ||
| •{" "} | ||
| <Trans | ||
| i18nKey="chat:announcement.feature2" | ||
| components={{ | ||
| bold: <b />, | ||
| code: <code />, | ||
| }} | ||
| /> | ||
| </li> | ||
| <li> | ||
| •{" "} | ||
| <Trans | ||
| i18nKey="chat:announcement.feature3" | ||
| components={{ | ||
| bold: <b />, | ||
| code: <code />, | ||
| }} | ||
| /> | ||
| </li> | ||
| </ul> | ||
| <Dialog | ||
| open={open} | ||
| onOpenChange={(open) => { | ||
| setOpen(open) | ||
|
|
||
| <p style={{ margin: "10px 0px 0px" }}> | ||
| if (!open) { | ||
| hideAnnouncement() | ||
| } | ||
| }}> | ||
| <DialogContent className="max-w-96"> | ||
| <DialogHeader> | ||
| <DialogTitle>{t("chat:announcement.title")}</DialogTitle> | ||
| <DialogDescription>{t("chat:announcement.description")}</DialogDescription> | ||
| </DialogHeader> | ||
| <div> | ||
| <h3>{t("chat:announcement.whatsNew")}</h3> | ||
| <ul className="space-y-2"> | ||
| <li> | ||
| •{" "} | ||
| <Trans i18nKey="chat:announcement.feature1" components={{ bold: <b />, code: <code /> }} /> | ||
| </li> | ||
| <li> | ||
| •{" "} | ||
| <Trans i18nKey="chat:announcement.feature2" components={{ bold: <b />, code: <code /> }} /> | ||
| </li> | ||
| <li> | ||
| •{" "} | ||
| <Trans i18nKey="chat:announcement.feature3" components={{ bold: <b />, code: <code /> }} /> | ||
| </li> | ||
| </ul> | ||
| <Trans | ||
| i18nKey="chat:announcement.detailsDiscussLinks" | ||
| components={{ | ||
| discordLink: discordLink, | ||
| redditLink: redditLink, | ||
| }} | ||
| components={{ discordLink: <DiscordLink />, redditLink: <RedditLink /> }} | ||
| /> | ||
| </p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </DialogContent> | ||
| </Dialog> | ||
| ) | ||
| } | ||
|
|
||
| const DiscordLink = () => ( | ||
| <VSCodeLink | ||
| href="https://discord.gg/roocode" | ||
| onClick={(e) => { | ||
| e.preventDefault() | ||
| window.postMessage( | ||
| { type: "action", action: "openExternal", data: { url: "https://discord.gg/roocode" } }, | ||
| "*", | ||
| ) | ||
| }}> | ||
| Discord | ||
| </VSCodeLink> | ||
| ) | ||
|
|
||
| const RedditLink = () => ( | ||
| <VSCodeLink | ||
| href="https://reddit.com/r/RooCode" | ||
| onClick={(e) => { | ||
| e.preventDefault() | ||
| window.postMessage( | ||
| { type: "action", action: "openExternal", data: { url: "https://reddit.com/r/RooCode" } }, | ||
| "*", | ||
| ) | ||
| }}> | ||
| </VSCodeLink> | ||
| ) | ||
|
|
||
| export default memo(Announcement) |
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
Oops, something went wrong.
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.
Ignore this - I'm using it for @roo-code/types.