Skip to content
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

Merged
merged 1 commit into from
Jul 1, 2024

Conversation

nxtCoder19
Copy link
Contributor

@nxtCoder19 nxtCoder19 commented Jun 28, 2024

- Add archive state of managed services when cluster is deleted
- refactor name of managed services, managed resource to integrated
  services and integrated resource
@nxtCoder19 nxtCoder19 requested review from tulsiojha and removed request for karthik1729 and abdheshnayak June 28, 2024 12:06
Copy link

sourcery-ai bot commented Jun 28, 2024

Reviewer's Guide by Sourcery

This 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

Files Changes
src/apps/console/routes/_main+/$account+/env+/$environment+/managed-resources/handle-managed-resource-v2.tsx
src/apps/console/routes/_main+/$account+/msvc+/$msv+/managed-resources/handle-managed-resource.tsx
Added account validation and refactored dataSecret function.
src/apps/console/routes/_main+/$account+/managed-services/backend-services-resources-V2.tsx
src/apps/console/routes/_main+/$account+/environments/environment-resources-v2.tsx
Added 'delete' action and updated components to handle archived items.
src/apps/console/routes/_main+/_layout/_layout.tsx
src/apps/console/routes/_main+/$account+/env+/$environment+/_layout.tsx
Uncommented and updated 'Managed Services' and 'Managed resources' tabs to 'Integrated Services' and 'Integrated resources'.
src/generated/gql/server.ts
src/generated/gql/sdl.graphql
Removed GlobalVpnKloudliteClusterLocalDeviceIn and GlobalVpnKloudliteGatewayDeviceIn types and added isArchived field.
src/apps/console/routes/_main+/$account+/managed-services/route.tsx
src/apps/console/routes/_main+/$account+/msvc+/$msv+/new-managed-resource/_index.tsx
src/apps/console/routes/_main+/$account+/new-managed-service/_index.tsx
src/apps/console/routes/_main+/$account+/msvc+/$msv+/_layout.tsx
Renamed 'managed service' to 'integrated service' throughout the files.
gql-queries-generator/doc/queries.graphql
src/apps/console/server/gql/queries/cluster-managed-services-queries.ts
Added isArchived field to relevant GraphQL queries.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link

@sourcery-ai sourcery-ai bot left a 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

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

Comment on lines +254 to +263
const dataSecret = () => {
if (isLoading) {
return <LoadingPlaceHolder />;
}
if (error) {
return <p>Error: {error}</p>;
}
if (!data?.data) {
return <p>No secret found</p>;
}
Copy link

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>;
Copy link

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.

Suggested change
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();
Copy link

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.

Suggested change
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);
Copy link

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:

  1. Increased Number of Imports: The new code adds more imports (useParams, toast from a different path, and ensureAccountClientSide), increasing the cognitive load to understand where each import is coming from and why it is needed.

  2. Additional Functionality: The new code adds a call to ensureAccountClientSide(params) and a new function dataSecret(), which increases the complexity by adding more logic that needs to be understood and maintained.

  3. Redundant Code: The dataSecret() function duplicates the logic that was previously inline within the MultiStep.Step component, making the code longer and splitting the logic into multiple places, which makes it harder to follow.

  4. 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.

  5. 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.

@nxtCoder19 nxtCoder19 merged commit fdc8e10 into release-v1.0.5 Jul 1, 2024
4 checks passed
@nxtCoder19 nxtCoder19 deleted the impl/archive-msvc branch July 1, 2024 05:45
abdheshnayak pushed a commit that referenced this pull request Oct 28, 2024
Archive managed services when cluster is deleted
tulsiojha pushed a commit that referenced this pull request Nov 1, 2024
Archive managed services when cluster is deleted
abdheshnayak pushed a commit that referenced this pull request Nov 5, 2024
Archive managed services when cluster is deleted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement archive managed services
1 participant