-
Notifications
You must be signed in to change notification settings - Fork 31
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
Analytics: Updated client creation and edit #2159
Conversation
WalkthroughWalkthroughThe pull request introduces new React components, Changes
Possibly related PRs
Poem
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Additional comments not posted (6)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 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 (
|
New next-platform changes available for preview here |
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
Outside diff range and nitpick comments (1)
platform/public/icons/Actions/DeleteIcon.js (1)
11-11
: Consider destructuring thefill
prop for cleaner usage.To improve the readability and conciseness of the code, consider destructuring the
fill
prop directly from theprops
object. This way, you can usefill
directly instead ofprops.fill
in thestroke
attribute.Here's how you can update the component:
-const DeleteIcon = (props) => { +const DeleteIcon = ({ fill, ...props }) => { return ( <svg xmlns='http://www.w3.org/2000/svg' width={24} height={24} viewBox='0 0 24 24' fill='none' {...props}> <path d='M9 3h6M3 6h18m-2 0l-.701 10.52c-.105 1.578-.158 2.367-.499 2.965a3 3 0 01-1.298 1.215c-.62.3-1.41.3-2.993.3h-3.018c-1.582 0-2.373 0-2.993-.3A3 3 0 016.2 19.485c-.34-.598-.394-1.387-.499-2.966L5 6m5 4.5v5m4-5v5' - stroke={props.fill || '#1C1D20'} + stroke={fill || '#1C1D20'} strokeWidth={1.5} strokeLinecap='round' strokeLinejoin='round' /> </svg> ); };This way, you can directly use the
fill
variable in thestroke
attribute, making the code cleaner and more readable.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- platform/public/icons/Actions/DeleteIcon.js (1 hunks)
- platform/public/icons/Actions/PlusIcon.js (1 hunks)
- platform/src/common/components/Settings/API/AddClientForm.jsx (7 hunks)
- platform/src/common/components/Settings/API/EditClientForm.jsx (4 hunks)
- platform/src/common/components/Settings/API/UserClientsTable.jsx (3 hunks)
- platform/src/lib/store/index.js (2 hunks)
Additional comments not posted (23)
platform/public/icons/Actions/PlusIcon.js (1)
1-23
: LGTM!The
PlusIcon
component looks good:
- It's a functional component that renders an SVG icon.
- It accepts props and spreads them on the SVG element, allowing for customization.
- The stroke color is determined by the
fill
prop, defaulting to white if not provided.- The component is reusable and properly exported as the default export.
Nice work!
platform/public/icons/Actions/DeleteIcon.js (1)
1-23
: LGTM!The
DeleteIcon
component looks good overall. It follows a clean and concise structure, properly handles props, and renders the delete icon using an SVG path. The naming and default export are also appropriate.platform/src/lib/store/index.js (1)
60-65
: LGTM!The changes to the middleware configuration look good. Using a function that returns the default middleware enhances flexibility and allows for potential future modifications without altering the core store setup. The overall structure of the store configuration remains intact.
The code changes are approved.
platform/src/common/components/Settings/API/AddClientForm.jsx (6)
3-7
: LGTM!The code changes are approved.
9-10
: LGTM!The code changes are approved.
21-30
: LGTM!The code changes are approved.
34-45
: LGTM!The code changes are approved.
Line range hint
59-84
: LGTM!The code changes are approved.
Line range hint
98-148
: LGTM!The code changes are approved.
platform/src/common/components/Settings/API/EditClientForm.jsx (12)
1-10
: LGTM!The new imports for
PlusIcon
andDeleteIcon
components are correctly added.
12-15
: LGTM!The changes to the
EditClientForm
component's props simplify the interface by using a singledata
prop. TheclientID
is correctly extracted from thedata
prop.
22-23
: LGTM!The
clientName
andipAddresses
state variables are correctly initialized.
26-39
: LGTM!The new
handleInitialData
function correctly sets the initial state values based on thedata
prop. TheuseEffect
hook ensures that the state is updated when thedata
prop changes.
41-51
: LGTM!The
handleInputValueChange
function correctly updates theipAddresses
state array based on the index of the IP address being edited.
53-59
: LGTM!The
handleRemoveInputValue
function correctly removes an IP address from theipAddresses
state array based on its index.
61-63
: LGTM!The new
handleAddIpAddress
function correctly appends an empty string to theipAddresses
state array.
84-86
: LGTM!The changes to the
handleSubmit
function correctly filter out empty IP addresses before sending the data to the API.
97-104
: LGTM!The updated error handling mechanism using the
setIsError
function with an object parameter streamlines the error handling and provides more detailed error information.
Line range hint
111-122
: LGTM!The new
useEffect
hook correctly clears the error state after a timeout of 2 seconds, improving the user experience.
Line range hint
129-177
: LGTM!The updated JSX correctly renders multiple IP address input fields based on the
ipAddresses
state array. ThePlusIcon
andDeleteIcon
components enhance the user experience for managing IP addresses.
183-183
: LGTM!Wrapping the
EditClientForm
component withReact.memo
is a good optimization to prevent unnecessary re-renders and improve performance.platform/src/common/components/Settings/API/UserClientsTable.jsx (2)
163-167
: LGTM!The
displayIPAddresses
function looks good. It correctly handles formatting the display of IP addresses, whetherclient.ip_addresses
is an array or not.
217-217
: LGTM!The usage of the
displayIPAddresses
function to format the display of IP addresses in the table looks good.
New next-platform changes available for preview here |
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: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- platform/src/common/components/Settings/API/AdminClientsTable.jsx (6 hunks)
Additional comments not posted (6)
platform/src/common/components/Settings/API/AdminClientsTable.jsx (6)
104-108
: LGTM!The
displayIPAddresses
function looks good. It correctly handles both array and non-array values forip_addresses
and provides a clean way to format the display of IP addresses.
116-116
: LGTM!Adding the
data-testid
attribute to thetable
element is a good practice for testing purposes. It provides a way to uniquely identify the element in the DOM, making it easier to write tests that interact with the table.
149-160
: LGTM!The code segment correctly renders the client data in the table cells. The usage of the
displayIPAddresses
function at line 160 ensures that the IP addresses are formatted correctly for display.
168-168
: LGTM!The code segment correctly renders the client activation status in the table cell. The conditional styling based on the
isActive
property provides a clear visual indication of the activation status.
Line range hint
174-206
: LGTM!The code segment correctly renders the activation and deactivation actions for each client in the table cell. The conditional rendering and click handling based on the
isActive
property ensures that the actions are only clickable when appropriate. Setting theconfirmClientActivation
orconfirmClientDeactivation
state and theselectedClient
state on click allows for further handling of the activation or deactivation process.
237-237
: LGTM!The code segment correctly renders the
DialogWrapper
component for confirming client activation. Setting theloading
prop to theisLoadingActivation
state ensures that the loading state is properly displayed while the activation request is in progress.
@@ -248,8 +245,7 @@ const AdminClientsTable = () => { | |||
onClose={() => setConfirmClientDeactivation(false)} | |||
handleClick={handleDeactivate} | |||
primaryButtonText={'Deactivate'} | |||
loading={isLoadingActivation} | |||
> | |||
loading={isLoadingActivation}> |
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.
Use a separate state variable for the deactivation loading state.
The code segment correctly renders the DialogWrapper
component for confirming client deactivation. However, setting the loading
prop to the isLoadingActivation
state seems incorrect. It should be set to a separate state variable specific to the deactivation process, such as isLoadingDeactivation
.
Consider introducing a new state variable, such as isLoadingDeactivation
, to track the loading state of the deactivation process separately from the activation process. Update the loading
prop of the deactivation DialogWrapper
to use this new state variable.
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 @OchiengPaul442 , please review this AI review comment and share feedback accordingly. Thanks!
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.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
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.
Thanks @OchiengPaul442 , I have just left a couple of code review comments for your attention. Thanks again, this is great! :)
@@ -105,22 +119,22 @@ const EditClientForm = ({ open, closeModal, cIP = '', cName = '', clientID }) => | |||
|
|||
return () => clearTimeout(timer); | |||
} | |||
}, [isError]); | |||
}, [isError.isError]); |
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.
Thanks @OchiengPaul442 :
- Is this variable "isError" always present?
- If not always available, we might want to handle this use case to minimise chances of runtime errors. There are couple of options which must be BACKWARD compatible with earlier version of node (JS).
Thanks!
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.
Hey @Baalmart ,
The state hook declaration you mentioned is used to manage the error state and display appropriate messages to the user when something goes wrong. This ensures that the error state is always present and updated accordingly whenever an error is detected.
You’re right about the compatibility. This state hook is specifically designed for use in a React frontend and won’t be compatible with a Node.js backend. However, it works perfectly fine for managing error states in a React component.
const [isError, setIsError] = useState({
isError: false,
message: '',
type: '',
});
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.
thanks @OchiengPaul442
New next-platform changes available for preview here |
Summary of Changes (What does this PR do?)
Status of maturity (all need to be checked before merging):
Screenshots (optional)
Summary by CodeRabbit
New Features
DeleteIcon
andPlusIcon
components for enhanced UI iconography.AddClientForm
to support multiple IP addresses, allowing users to dynamically add or remove fields.EditClientForm
to manage client data more flexibly with a consolidateddata
prop.displayIPAddresses
function inUserClientsTable
andAdminClientsTable
for improved IP address presentation.AdminClientsTable
.Bug Fixes
Style