-
Notifications
You must be signed in to change notification settings - Fork 1
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
Archive managed services when cluster is deleted #236
Conversation
Reviewer's Guide by SourceryThis pull request implements the archiving of managed services when a cluster is deleted. The changes include renaming 'managed service' to 'integrated service' across various files, adding account validation utilities, refactoring functions to handle loading, error, and data states, and updating components to handle archived items. Additionally, GraphQL queries were updated to include an 'isArchived' field. File-Level Changes
Tips
|
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 @nxtCoder19 - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 3 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
const dataSecret = () => { | ||
if (isLoading) { | ||
return <LoadingPlaceHolder />; | ||
} | ||
if (error) { | ||
return <p>Error: {error}</p>; | ||
} | ||
if (!data?.data) { | ||
return <p>No secret found</p>; | ||
} |
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.
suggestion (performance): Consider memoizing dataSecret
function.
To avoid unnecessary re-renders, consider memoizing the dataSecret
function using useCallback
.
return <LoadingPlaceHolder />; | ||
} | ||
if (error) { | ||
return <p>Error: {error}</p>; |
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.
suggestion: Improve error handling.
Consider providing more user-friendly error messages or handling different types of errors separately.
return <p>Error: {error}</p>; | |
if (error) { | |
let errorMessage = 'An unexpected error occurred.'; | |
if (error.message) { | |
errorMessage = error.message; | |
} else if (typeof error === 'string') { | |
errorMessage = error; | |
} | |
return <p>Error: {errorMessage}</p>; | |
} |
const [visible, setVisible] = useState<BaseType | null>(null); | ||
const api = useConsoleApi(); | ||
const reloadPage = useReload(); |
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.
suggestion (performance): Check for unnecessary page reloads.
Ensure that the reloadPage
function is necessary and that it doesn't cause unnecessary page reloads, which can affect user experience.
const reloadPage = useReload(); | |
const reloadPage = useCallback(() => { | |
if (shouldReload()) { | |
useReload(); | |
} | |
}, []); |
@@ -227,6 +230,8 @@ export const ViewSecret = ({ | |||
const api = useConsoleApi(); | |||
const { environment } = useOutletContext<IEnvironmentContext>(); | |||
const [onYesClick, setOnYesClick] = useState(false); | |||
const params = useParams(); | |||
ensureAccountClientSide(params); |
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.
issue (complexity): Consider simplifying the code by consolidating imports and keeping logic inline where possible.
The new code introduces additional complexity due to several factors:
-
Increased Number of Imports: The new code adds more imports (
useParams
,toast
from a different path, andensureAccountClientSide
), increasing the cognitive load to understand where each import is coming from and why it is needed. -
Additional Functionality: The new code adds a call to
ensureAccountClientSide(params)
and a new functiondataSecret()
, which increases the complexity by adding more logic that needs to be understood and maintained. -
Redundant Code: The
dataSecret()
function duplicates the logic that was previously inline within theMultiStep.Step
component, making the code longer and splitting the logic into multiple places, which makes it harder to follow. -
Error Handling: The new code adds more error handling and loading states within the
dataSecret()
function, which were previously handled inline. This separation can make it harder to trace the flow of data and understand how errors are managed. -
Inconsistent Naming: The new code changes the terminology from "Managed Resource" to "Integrated Resource" and "Managed Service" to "Integrated Service". While this might be a necessary change, it adds to the complexity if not properly documented or communicated.
Consider simplifying the code by consolidating imports, keeping logic inline where possible, and maintaining consistent naming conventions. This will help reduce the overall complexity and make the code easier to maintain.
Archive managed services when cluster is deleted
Archive managed services when cluster is deleted
Archive managed services when cluster is deleted
Resolves kloudlite/kloudlite#256