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

WEB: Previous account cluster list are showing while account switching #280

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

nxtCoder19
Copy link
Contributor

@nxtCoder19 nxtCoder19 commented Aug 26, 2024

Resolves #279

Summary by Sourcery

Add a new feature to clone environments using a GraphQL mutation and enhance the environment and cluster management components and queries for better state handling and CLI support.

New Features:

  • Introduce a new GraphQL mutation core_cloneEnvironment to clone environments with specified parameters such as cluster name, source and destination environment names, display name, and routing mode.

Enhancements:

  • Refactor the ManagedServiceLayout and HandleEnvironment components to improve state management and effect dependencies, ensuring that cluster lists are updated correctly.
  • Update the cliQueries to include new queries and mutations for managing environments and clusters, enhancing the CLI capabilities.

- fix cluster listing while creating environments and integrated
  services after switching account
Copy link

sourcery-ai bot commented Aug 26, 2024

Reviewer's Guide by Sourcery

This pull request implements changes related to cloning environments and updating various components in the Kloudlite console application. The changes include adding a new mutation for cloning environments, updating the environment handling component, and modifying the managed service layout.

File-Level Changes

Change Details Files
Added new mutation for cloning environments
  • Implemented 'authCli_cloneEnvironment' mutation in GraphQL queries
  • Added 'cli_cloneEnvironment' function to CLI queries
  • Updated environment-queries.ts to include the new clone environment mutation
src/generated/gql/server.ts
src/apps/auth/server/gql/cli-queries.ts
src/apps/console/server/gql/queries/environment-queries.ts
Updated environment handling component
  • Modified useEffect hook to update cluster selection based on cluster list changes
  • Refactored cluster selection logic in HandleEnvironment component
  • Updated imports and component structure
src/apps/console/page-components/handle-environment.tsx
Modified managed service layout
  • Updated useEffect hook to handle cluster selection
  • Refactored cluster list handling logic
  • Added new imports and updated existing ones
src/apps/console/routes/_main+/$account+/new-managed-service/_index.tsx
Updated environment-related components and routes
  • Modified imports in environments route
  • Updated useEffect hook in environments route to handle cluster list changes
  • Added new component for cloning environments
src/apps/console/routes/_main+/$account+/environments/route.tsx
src/apps/console/routes/_main+/$account+/environments/clone-environment.tsx

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • 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 found some issues that need to be addressed.

Blocking issues:

  • Avoid hardcoding private keys in the code. (link)
  • Avoid hardcoding public keys in the code. (link)
Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🔴 Security: 2 blocking issues
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 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.

}
}
`,
{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Inconsistent error handling in transformer functions

The transformer function in cli_listByokClusters directly returns the data, while cli_cloneEnvironment doesn't have a transformer. This inconsistency could lead to unexpected behavior or difficulties in error handling. Consider standardizing the approach across both functions.

@@ -563,7 +563,7 @@ const ManagedServiceLayout = () => {

useEffect(() => {
getClusters();
}, []);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Dependency array in useEffect includes clusterList

The useEffect hook now includes clusterList in its dependency array. This could cause the effect to run more often than intended. Consider if this change is necessary and if it might introduce any performance issues.

),
},
}));
}
}, [values.selectedTemplate]);

useEffect(() => {
if (clusterList.length > 0) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: More defensive cluster name setting logic

The new version of setting clusterName is more defensive, handling the case where clusterList is empty. Can you explain the reasoning behind this change? Are there specific scenarios or issues this is addressing?

id: string;
ipAddr: string;
markedForDeletion?: boolean;
privateKey: string;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 issue (security): Avoid hardcoding private keys in the code.

Storing private keys directly in the code can lead to security vulnerabilities. Consider using environment variables or a secure vault to manage sensitive information.

ipAddr: string;
markedForDeletion?: boolean;
privateKey: string;
publicKey: string;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 issue (security): Avoid hardcoding public keys in the code.

While public keys are not as sensitive as private keys, it's still a good practice to manage them securely, especially if they are part of a key pair.

@nxtCoder19 nxtCoder19 requested a review from nxtcoder36 August 26, 2024 06:17
@nxtCoder19 nxtCoder19 merged commit 53b1bcb into release-v1.0.5 Aug 26, 2024
5 checks passed
@nxtCoder19 nxtCoder19 deleted the fix/switch-acc-issue branch August 26, 2024 06:20
abdheshnayak pushed a commit that referenced this pull request Oct 28, 2024
WEB: Previous account cluster list are showing while account switching
tulsiojha pushed a commit that referenced this pull request Nov 1, 2024
WEB: Previous account cluster list are showing while account switching
abdheshnayak pushed a commit that referenced this pull request Nov 5, 2024
WEB: Previous account cluster list are showing while account switching
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.

WEB: Previous account cluster list are showing while account switching
2 participants