-
Notifications
You must be signed in to change notification settings - Fork 1
Upgraded the token modal with a clear warning that the token displays only once and added a “Copy to Clipboard” button with a confirmation notification. #15
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
Conversation
WalkthroughThe pull request introduces formatting adjustments and minor text modifications in two TSX components and a CSS file. The Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant AP as Access Page
participant F as Fetch Function
participant D as DateTime Converter
participant CL as Clipboard API
participant N as Notification
U->>AP: View generated token
AP->>F: Fetch tokens data
F->>D: Convert token dates using DateTime.fromISO
D-->>F: Return converted dates
F-->>AP: Provide transformed tokens
U->>AP: Click "Copy to Clipboard"
AP->>CL: Copy token
CL-->>AP: Confirm copy
AP->>N: Display success notification
Poem
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/app/(repo)/[user]/[repo]/pr/page.tsx (1)
56-57
: Label terminology correction.Changed "PReviews" to "Reviews" for consistency and clarity. However, note that menu items in lines 60-62 still contain "PReviews" in their text.
Consider updating the menu items to match the button label:
<Menu.Dropdown> - <Menu.Item>PReviews1</Menu.Item> - <Menu.Item>PReviews2</Menu.Item> - <Menu.Item>PReviews3</Menu.Item> + <Menu.Item>Reviews1</Menu.Item> + <Menu.Item>Reviews2</Menu.Item> + <Menu.Item>Reviews3</Menu.Item> </Menu.Dropdown>src/app/settings/access/page.tsx (1)
184-185
: Fix typo in font size property.There's a typo in the font size value that could cause styling issues.
- fontSize: 'o.875rem', + fontSize: '0.875rem',
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/app/(repo)/[user]/[repo]/pr/page.tsx
(3 hunks)src/app/settings/access/page.tsx
(4 hunks)src/style/setting.css
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/app/(repo)/[user]/[repo]/pr/page.tsx (2)
src/app/(repo)/[user]/[repo]/issues/new/page.tsx (1)
Page
(9-91)src/app/(repo)/[user]/[repo]/issues/page.tsx (1)
Page
(7-33)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Build Frontend
🔇 Additional comments (8)
src/style/setting.css (2)
93-95
: Style enhancement for delete buttons.The styling changes to
.access-list-delete
improve the visual hierarchy by making delete buttons more prominent with a red background and white text. The addition ofalign-items: center
helps ensure content is properly aligned.
103-107
: Good addition of warning class for user alerts.The new
.warning
class provides consistent styling for important messages across the application. This class is used effectively in the token display modal to highlight the one-time token visibility warning.src/app/(repo)/[user]/[repo]/pr/page.tsx (3)
6-7
: Improved code formatting for better readability.The spacing adjustments in the function signature and return statement align with standard JavaScript/TypeScript coding conventions and match the formatting used in other components like
issues/new/page.tsx
.Also applies to: 81-82
32-33
: Better text spacing in UI element.Adding space before the icon improves readability and alignment with standard UI practices.
64-76
: Improved menu structure formatting.The "Sort" menu is now properly formatted with consistent indentation, making the code more readable and maintainable.
src/app/settings/access/page.tsx (3)
3-6
: Consistent import formatting.Spacing after import braces follows standard style conventions and improves readability.
39-45
: Improved token data handling.Converting ISO date strings to DateTime objects is an excellent improvement that ensures:
- Proper date handling and manipulation
- Consistent date formatting for display
- Type safety with the TokenModel interface
This change will prevent potential issues with date handling and improve code maintainability.
174-199
: Enhanced token display experience.The improved token modal provides better UX by:
- Adding a clear warning about token visibility
- Offering a convenient copy-to-clipboard button
- Providing feedback via notifications
The implementation also properly uses the new
.warning
class defined in the CSS.
src/app/settings/access/page.tsx
Outdated
}); | ||
}} | ||
> | ||
Copy to Clipboard |
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.
can you switch in icon? form react-icon
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.
Actionable comments posted: 0
♻️ Duplicate comments (1)
src/app/settings/access/page.tsx (1)
175-223
: Consider using CSS classes instead of inline styles.The token display UI has been significantly improved with a warning message and copy functionality. However, there are extensive inline styles that would be better maintained as CSS classes in your stylesheet.
Also, consider using an icon for the copy button as suggested in a previous review.
Example refactoring:
- <div style={{ display: 'flex', alignItems: 'center' }}> - <div - style={{ - backgroundColor: '#f0f0f0', - padding: '0.25rem', - border: '1px solid #ccc', - borderRadius: '4px', - fontFamily: 'monospace', - flexGrow: 1, - marginRight: '0.5rem', - whiteSpace: 'nowrap', - overflow: 'hidden', - textOverflow: 'ellipsis', - }} - > + <div className="token-container"> + <div className="token-display"> {GeneratedToken} </div>Add the following CSS classes to your stylesheet:
.token-container { display: flex; align-items: center; } .token-display { background-color: #f0f0f0; padding: 0.25rem; border: 1px solid #ccc; border-radius: 4px; font-family: monospace; flex-grow: 1; margin-right: 0.5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }And for the button, consider using an icon from a library like react-icons:
+import { FaCopy, FaCheck } from 'react-icons/fa'; // Then in the button: - {isCopied ? 'Copied!' : 'Copy'} + {isCopied ? <><FaCheck /> Copied!</> : <><FaCopy /> Copy</>}
🧹 Nitpick comments (1)
src/app/settings/access/page.tsx (1)
94-94
: Use English comments for better maintainability.There's a Chinese comment "重置复制状态" (reset copy status). For international collaboration, it's better to use English comments throughout the codebase.
- setIsCopied(false); // 重置复制状态 + setIsCopied(false); // Reset copy status
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/app/settings/access/page.tsx
(5 hunks)
🔇 Additional comments (6)
src/app/settings/access/page.tsx (6)
3-6
: Import statements look good.The spacing in import statements has been improved for better readability and consistency.
25-26
: Good addition of typed state variables.Adding the explicit type
string | null
forGeneratedToken
and introducing theisCopied
state variable improves type safety and enables the copy-to-clipboard functionality.
39-44
: Token data processing looks good.The implementation properly transforms the token data from raw API response to typed
TokenModel
objects with correctly formatted DateTime objects.
173-173
: Good improvement in modal close logic.The modal close handler now also resets the
isCopied
state, which prevents potential state issues if the modal is reopened.
177-177
: Good use of warning text for the one-time token display.The warning message clearly informs users about the one-time nature of token display, which is a critical security best practice.
207-217
: Well-implemented clipboard functionality with user feedback.The copy-to-clipboard implementation is robust with:
- Proper state management to prevent multiple copies
- Clipboard API usage
- User notification when the token is copied
This significantly improves the user experience.
PR Type
INSERT_PR_TYPE
PR Checklist
eslint .
).Overview
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Style
[skip ci]