Skip to content

AGENT-1181: Refactor kubeconfig download to new design of credentials download#2905

Merged
openshift-merge-bot[bot] merged 3 commits intoopenshift-assisted:masterfrom
ElayAharoni:refactor-kubeconfig-download-to-new-design-of-credentials-download
Apr 10, 2025
Merged

AGENT-1181: Refactor kubeconfig download to new design of credentials download#2905
openshift-merge-bot[bot] merged 3 commits intoopenshift-assisted:masterfrom
ElayAharoni:refactor-kubeconfig-download-to-new-design-of-credentials-download

Conversation

@ElayAharoni
Copy link
Contributor

@ElayAharoni ElayAharoni commented Apr 9, 2025

https://issues.redhat.com/browse/AGENT-1181

refactored the kubeconfig download page to the new designed credentials download.
added functionality to show the credentials and some alerts and error when necessary.
also added download for both kubeadmin-password and kubeconfig file.

added video of the behavior when there is an error, and when there are no.

https://www.loom.com/share/be95459a53a144a0b7fe49c2c8ae7799?sid=d0431c59-63ae-4bed-89a5-b0c70662e1e6

Summary by CodeRabbit

  • New Features

    • Improved in-app messaging with updated prompts and error notifications during cluster installation.
    • Enhanced credentials display using a read-only interactive field for a clearer user view.
    • Upgraded the installation wizard with a responsive loading indicator on the next step and a revised credentials download process.
    • Introduced a new component for downloading cluster credentials within the cluster wizard.
  • Documentation

    • Added a resource link for detailed information on managing cluster configurations.

Signed-off-by: Elay Aharoni <elayaha@gmail.com>
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 9, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 9, 2025

@ElayAharoni: This pull request references AGENT-1181 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the sub-task to target the "4.19.0" version, but no target version was set.

Details

In response to this:

https://issues.redhat.com/browse/AGENT-1181

refactored the kubeconfig download page to the new designed credentials download.
added functionality to show the credentials and some alerts and error when necessary.
also added download for both kubeadmin-password and kubeconfig file.

added video of the behavior when there is an error, and when there are no.

https://www.loom.com/share/be95459a53a144a0b7fe49c2c8ae7799?sid=d0431c59-63ae-4bed-89a5-b0c70662e1e6

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested review from ammont82 and batzionb April 9, 2025 09:11
@coderabbitai
Copy link

coderabbitai bot commented Apr 9, 2025

Walkthrough

This update introduces several modifications to support a new credentials download process in the cluster installation flow. New localization entries have been added for error messages and user instructions. UI components now show a read-only username field using a text input and display loading states on wizard buttons. The cluster wizard flow has been updated to replace kubeconfig-download steps with a new credentials-download process, and a dedicated React component has been added to handle credentials fetching, download, and error notifications. Additionally, a new documentation link has been provided.

Changes

File(s) Change Summary
libs/locales/lib/en/translation.json Added localization entries for error messages, user prompts, and instructions related to credentials download during cluster installation.
libs/ui-lib/lib/common/components/clusterDetail/ClusterCredentials.tsx Updated UI component to convert plain text username to a read-only text input.
libs/ui-lib/lib/common/components/ui/WizardFooter.tsx Added an optional isNextButtonLoading prop to show loading state on wizard buttons.
libs/ui-lib/lib/common/config/docs_links.ts Added a new constant for documentation link regarding Kubeconfig management.
libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizard.tsx, libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContextProvider.tsx Updated the wizard flow by replacing the kubeconfig-download step with a credentials-download step in both rendering and context step IDs.
libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx Introduced a new React functional component to handle the credentials download workflow including API calls, error handling, and UI state management.
libs/ui-lib/lib/ocm/components/clusterWizard/constants.ts Modified the wizard step names by replacing the key/value for kubeconfig-download with credentials-download.
libs/ui-lib/lib/ocm/components/clusterWizard/wizardTransition.ts Renamed wizard steps and corresponding validation maps from kubeconfig-download to credentials-download within type definitions and step ordering.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CDComponent as CredentialsDownload
    participant API as ClustersAPI
    participant Alert as AlertHandler

    User->>CDComponent: Click "Download Credentials"
    CDComponent->>API: getCredentials(cluster)
    API-->>CDComponent: Return credentials data / error
    alt Successful fetch
        CDComponent->>User: Provide downloaded credentials
    else Error occurred
        CDComponent->>Alert: Trigger error alert
    end
Loading
sequenceDiagram
    participant WizardContext as ClusterWizardContextProvider
    participant Wizard as ClusterWizard
    participant Factory as ComponentFactory

    WizardContext->>Wizard: Provide step identifiers (include "credentials-download")
    Wizard->>Factory: Render component for "credentials-download"
    Factory-->>Wizard: Return CredentialsDownload component
Loading

Poem

I'm a bunny in the code, hopping all around,
New credentials now download, with steps so sound.
Text inputs and alerts, they're leading the way,
Cluster wizards dancing, making errors sway.
With every little change, I smile and bound –
🐰 Coding magic in leaps, so merry and profound!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 18b9681 and 8512552.

📒 Files selected for processing (1)
  • libs/locales/lib/en/translation.json (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • libs/locales/lib/en/translation.json
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: tests
  • GitHub Check: translation-files
  • GitHub Check: format
  • GitHub Check: circular-deps
  • GitHub Check: unit-tests
  • GitHub Check: lint

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@openshift-ci openshift-ci bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 9, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 9, 2025

@ElayAharoni: This pull request references AGENT-1181 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the sub-task to target the "4.19.0" version, but no target version was set.

Details

In response to this:

https://issues.redhat.com/browse/AGENT-1181

refactored the kubeconfig download page to the new designed credentials download.
added functionality to show the credentials and some alerts and error when necessary.
also added download for both kubeadmin-password and kubeconfig file.

added video of the behavior when there is an error, and when there are no.

https://www.loom.com/share/be95459a53a144a0b7fe49c2c8ae7799?sid=d0431c59-63ae-4bed-89a5-b0c70662e1e6

Summary by CodeRabbit

  • New Features

  • Improved in-app messaging with updated prompts and error notifications during cluster installation.

  • Enhanced credentials display using a read-only interactive field for a clearer user view.

  • Upgraded the installation wizard with a responsive loading indicator on the next step and a revised credentials download process.

  • Documentation

  • Added a resource link for detailed information on managing cluster configurations.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link

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

🧹 Nitpick comments (5)
libs/ui-lib/lib/common/components/clusterDetail/ClusterCredentials.tsx (1)

108-111: Consider translating the "Username" string

The "Username" label should be translated using the translation function for consistency with other text elements in this component, such as "Password" which uses t('ai:Password').

<DetailItem
-  title="Username"
+  title={t('ai:Username')}
  value={<TextInput value={credentials.username} readOnlyVariant="default" />}
/>
libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (3)

124-131: Consider adding retry mechanism for credential fetching

In case of credential fetching failures, it might be helpful to provide a retry button or mechanism to allow users to attempt to fetch credentials again without having to refresh the entire page.

You could add a simple retry button when an error occurs:

<Grid style={{ justifyItems: 'start' }}>
  <ClusterCredentials
    cluster={cluster}
    credentials={credentials}
    credentialsError={credentialsError}
    error={credentialsError !== ''}
  />
+ {credentialsError && (
+   <Button 
+     variant="secondary" 
+     onClick={fetchCredentials} 
+     style={{ marginTop: '10px' }}
+   >
+     {t('ai:Retry fetching credentials')}
+   </Button>
+ )}
</Grid>

52-66: Consider more descriptive error messaging

The current error handling provides basic feedback, but consider enhancing error messages to guide users on possible solutions.

handleApiError(e, (e) => {
  addAlert({
    title: t(`Could not download ${fileName} file`),
-   message: getApiErrorMessage(e),
+   message: t('ai:${getApiErrorMessage(e)}. Please check your network connection and try again. If the problem persists, contact support.'),
  });
});

74-83: Consider adding more descriptive UI feedback during transitions

The timeout used for the loading state is good, but users might benefit from a more explicit success message before navigation.

setTimeout(() => {
  setIsDownloading(false);

  if (!hasError) {
+   addAlert({
+     title: t('ai:Credentials successfully downloaded'),
+     message: t('ai:You can now proceed to the next step'),
+     variant: AlertVariant.success,
+   });
    clusterWizardContext.moveNext();
  }
}, 500);
libs/locales/lib/en/translation.json (1)

415-415: User Prompt Grammar Improvement

The new prompt key "ai:I understand that I need to download credentials files prior of proceeding with the cluster installation." is added to inform users about the required action. For clarity and grammatical accuracy, consider changing "prior of proceeding" to "prior to proceeding".

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5dc791f and dd1695a.

📒 Files selected for processing (9)
  • libs/locales/lib/en/translation.json (4 hunks)
  • libs/ui-lib/lib/common/components/clusterDetail/ClusterCredentials.tsx (2 hunks)
  • libs/ui-lib/lib/common/components/ui/WizardFooter.tsx (3 hunks)
  • libs/ui-lib/lib/common/config/docs_links.ts (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizard.tsx (2 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContextProvider.tsx (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/constants.ts (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/wizardTransition.ts (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (5)
libs/types/assisted-installer-service.d.ts (2)
  • Cluster (110-398)
  • Credentials (756-760)
libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContext.tsx (1)
  • useClusterWizardContext (25-31)
libs/ui-lib/lib/common/hooks/index.ts (1)
  • useTranslation (3-3)
libs/ui-lib/lib/ocm/services/apis/index.ts (1)
  • ClustersAPI (5-5)
libs/ui-lib/lib/common/config/docs_links.ts (1)
  • KUBECONFIG_INFO_LINK (186-187)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: tests
  • GitHub Check: translation-files
  • GitHub Check: circular-deps
  • GitHub Check: lint
  • GitHub Check: format
  • GitHub Check: unit-tests
🔇 Additional comments (20)
libs/ui-lib/lib/common/config/docs_links.ts (1)

185-187: LGTM: New documentation link for Kubeconfig management

The addition of the KUBECONFIG_INFO_LINK constant provides a useful documentation reference for users to learn about managing CLI profiles in OpenShift. This aligns well with the PR objective of refactoring the kubeconfig download process.

libs/ui-lib/lib/common/components/clusterDetail/ClusterCredentials.tsx (1)

2-9: LGTM: Added TextInput component import

The import of the TextInput component from @patternfly/react-core is required for the UI enhancements in this file.

libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContextProvider.tsx (1)

72-72: LGTM: Updated wizard step name to "credentials-download"

The step name has been updated from 'kubeconfig-download' to 'credentials-download', which aligns with the new design and terminology focus on credentials rather than just kubeconfig.

libs/ui-lib/lib/ocm/components/clusterWizard/constants.ts (1)

14-14: LGTM: Renamed step to "Download credentials"

The wizard step name has been updated from "Download Kubeconfig" to "Download credentials", maintaining consistency with the PR's objective and other related file changes.

libs/ui-lib/lib/common/components/ui/WizardFooter.tsx (3)

29-29: LGTM: Good addition of loading state support

Adding the isNextButtonLoading property enhances the UI feedback during asynchronous operations.


55-55: LGTM: Proper prop destructuring

The new property is correctly destructured from the props.


73-73: LGTM: Well-implemented loading state

The isLoading prop is correctly applied to the Button component to provide visual feedback during async operations.

libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizard.tsx (2)

19-19: LGTM: Component import updated

Import statement properly updated to use the new CredentialsDownload component.


48-49: LGTM: Step handler updated

The case statement is correctly updated to handle the 'credentials-download' step and render the new CredentialsDownload component with the required props.

libs/ui-lib/lib/ocm/components/clusterWizard/wizardTransition.ts (4)

32-32: LGTM: Type definition updated

The ClusterWizardStepsType is properly updated to use 'credentials-download' instead of 'kubeconfig-download'.


44-44: LGTM: Wizard steps order updated

The wizardStepsOrder array correctly includes 'credentials-download' in place of 'kubeconfig-download'.


250-250: LGTM: Validation map renamed

Variable naming correctly updated to reflect the new terminology.


265-265: LGTM: Validation map entry updated

The wizardStepsValidationsMap correctly uses 'credentials-download' as the key for the validation map.

libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (4)

22-46: LGTM: Well-structured component initialization and credentials fetching

The component is well-organized with proper state management and a cleanly implemented credentials fetching function. Good error handling is in place to provide user feedback.


85-94: LGTM: Well-implemented footer

The ClusterWizardFooter correctly uses the new isNextButtonLoading prop to display loading state during download operations. The button is appropriately disabled based on the checkbox state and download progress.


100-114: LGTM: Informative alert message

Good implementation of an alert that provides important context to users about securely storing credentials, with a helpful link to learn more about Kubeconfig.


115-123: LGTM: User confirmation checkbox

Good UX practice to require user acknowledgment before downloading sensitive credentials.

libs/locales/lib/en/translation.json (3)

330-330: Consistent Error Message Entry

The new translation key "ai:Failed to load Credentials Download step" is added in a manner consistent with other error messages. The text is clear and directly communicates the failure state when the credentials download step cannot be loaded.


493-493: 'Learn more about Kubeconfig' Entry Verification

The translation key "ai:Learn more about Kubeconfig" is introduced with the same display text. This addition is consistent with the design changes and effectively supports the new credentials download functionality by offering users additional information.


517-517: Credentials Storage Instruction

The new translation key "ai:Make sure you download and store your credentials files in a safe place" is clearly added to remind users to secure their credentials. The wording is consistent with similar instructional messages across the file.

@ElayAharoni ElayAharoni force-pushed the refactor-kubeconfig-download-to-new-design-of-credentials-download branch from dd1695a to 574763f Compare April 9, 2025 09:16
@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 9, 2025

@ElayAharoni: This pull request references AGENT-1181 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the sub-task to target the "4.19.0" version, but no target version was set.

Details

In response to this:

https://issues.redhat.com/browse/AGENT-1181

refactored the kubeconfig download page to the new designed credentials download.
added functionality to show the credentials and some alerts and error when necessary.
also added download for both kubeadmin-password and kubeconfig file.

added video of the behavior when there is an error, and when there are no.

https://www.loom.com/share/be95459a53a144a0b7fe49c2c8ae7799?sid=d0431c59-63ae-4bed-89a5-b0c70662e1e6

Summary by CodeRabbit

  • New Features

  • Improved in-app messaging with updated prompts and error notifications during cluster installation.

  • Enhanced credentials display using a read-only interactive field for a clearer user view.

  • Upgraded the installation wizard with a responsive loading indicator on the next step and a revised credentials download process.

  • Introduced a new component for downloading cluster credentials within the cluster wizard.

  • Documentation

  • Added a resource link for detailed information on managing cluster configurations.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link

@coderabbitai coderabbitai bot left a 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 (3)
libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (3)

68-83: Consider optimizing the download process

The current implementation downloads files sequentially and uses setTimeout for navigation. Consider these improvements:

  1. Download files in parallel using Promise.all for better performance
  2. Remove the setTimeout and navigate directly after handling the download results
const handleDownloadClick = async () => {
  setIsDownloading(true);

- const configSuccess = await downloadSingleFile('kubeconfig');
- const passwordSuccess = await downloadSingleFile('kubeadmin-password');
+ const [configSuccess, passwordSuccess] = await Promise.all([
+   downloadSingleFile('kubeconfig'),
+   downloadSingleFile('kubeadmin-password')
+ ]);

  const hasError = !configSuccess || !passwordSuccess;
  setIsDownloading(false);

- setTimeout(() => {
-   setIsDownloading(false);
-
-   if (!hasError) {
-     clusterWizardContext.moveNext();
-   }
- }, 500);
+ if (!hasError) {
+   clusterWizardContext.moveNext();
+ }
};

116-123: Consider using functional updates for checkbox state

For better practice when updating state based on previous state, consider using the functional form of setState.

- onChange={() => setIsChecked(!isChecked)}
+ onChange={() => setIsChecked(prev => !prev)}

22-29: Consider adding loading state for initial credentials fetch

The component doesn't show a loading state while initially fetching credentials. Consider adding a loading state to improve user experience during the initial data fetch.

const CredentialsDownload: React.FC<{ cluster: Cluster }> = ({ cluster }) => {
  const [isChecked, setIsChecked] = React.useState<boolean>(false);
  const clusterWizardContext = useClusterWizardContext();
  const [credentials, setCredentials] = React.useState<Credentials>();
  const [credentialsError, setCredentialsError] = React.useState('');
  const [isDownloading, setIsDownloading] = React.useState(false);
+ const [isLoading, setIsLoading] = React.useState(false);
  const { addAlert } = useAlerts();
  const { t } = useTranslation();

Then update the fetchCredentials function:

const fetchCredentials = React.useCallback(() => {
  const fetch = async () => {
    setCredentialsError('');
+   setIsLoading(true);
    if (!cluster.id) {
+     setIsLoading(false);
      return;
    }
    try {
      const response = await ClustersAPI.getCredentials(cluster.id);
      const data = { username: response.data.username, password: response.data.password };
      setCredentials(data);
    } catch (err) {
      setCredentialsError(`Failed to fetch credentials, ${getErrorMessage(err)}`);
    } finally {
+     setIsLoading(false);
    }
  };
  void fetch();
}, [cluster]);

And pass this to the ClusterCredentials component:

<ClusterCredentials
  cluster={cluster}
  credentials={credentials}
  credentialsError={credentialsError}
  error={credentialsError !== ''}
+ isLoading={isLoading}
/>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dd1695a and 574763f.

📒 Files selected for processing (9)
  • libs/locales/lib/en/translation.json (4 hunks)
  • libs/ui-lib/lib/common/components/clusterDetail/ClusterCredentials.tsx (2 hunks)
  • libs/ui-lib/lib/common/components/ui/WizardFooter.tsx (3 hunks)
  • libs/ui-lib/lib/common/config/docs_links.ts (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizard.tsx (2 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContextProvider.tsx (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/constants.ts (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/wizardTransition.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • libs/ui-lib/lib/common/config/docs_links.ts
  • libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContextProvider.tsx
  • libs/ui-lib/lib/common/components/clusterDetail/ClusterCredentials.tsx
  • libs/ui-lib/lib/common/components/ui/WizardFooter.tsx
  • libs/ui-lib/lib/ocm/components/clusterWizard/constants.ts
  • libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizard.tsx
  • libs/ui-lib/lib/ocm/components/clusterWizard/wizardTransition.ts
  • libs/locales/lib/en/translation.json
🧰 Additional context used
🧬 Code Graph Analysis (1)
libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (5)
libs/types/assisted-installer-service.d.ts (2)
  • Cluster (110-398)
  • Credentials (756-760)
libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContext.tsx (1)
  • useClusterWizardContext (25-31)
libs/ui-lib/lib/common/hooks/index.ts (1)
  • useTranslation (3-3)
libs/ui-lib/lib/ocm/services/apis/index.ts (1)
  • ClustersAPI (5-5)
libs/ui-lib/lib/common/config/docs_links.ts (1)
  • KUBECONFIG_INFO_LINK (186-187)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: tests
  • GitHub Check: unit-tests
  • GitHub Check: format
  • GitHub Check: lint
🔇 Additional comments (6)
libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (6)

31-46: Well implemented credential fetching

The fetchCredentials function is well structured with proper error handling and state management. Good use of useCallback with the correct dependency array to optimize performance.


48-50: Clean effect hook implementation

The useEffect hook correctly calls fetchCredentials when the component mounts and when the cluster dependency changes.


52-66: Good error handling in downloadSingleFile

The downloadSingleFile function properly handles API errors and provides appropriate user feedback through alerts.


85-94: Good implementation of the wizard footer

The footer component correctly handles navigation, button states, and loading indicators.


100-114: Good user guidance with alert and documentation link

The alert effectively communicates the importance of securely storing credentials and provides a helpful link to additional documentation.


124-131: Clean implementation of credentials display

Good use of the ClusterCredentials component to display the fetched credentials with proper error state handling.

@ElayAharoni ElayAharoni requested a review from rawagner April 9, 2025 09:46
@ElayAharoni ElayAharoni force-pushed the refactor-kubeconfig-download-to-new-design-of-credentials-download branch from f0edb15 to e3b62ec Compare April 9, 2025 11:35
@ElayAharoni ElayAharoni requested a review from rawagner April 9, 2025 11:35
Copy link

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

♻️ Duplicate comments (2)
libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (2)

98-98: Localize the “Download credentials” title.
This heading is not wrapped with your useTranslation hook. Wrap the string in t('') for full i18n coverage.


114-114: Avoid Custom Styling in favor of PatternFly layouts.
This duplicates previous feedback about using PatternFly's layout components (e.g., <Stack hasGutter> or built-in spacing tokens). Inline margin styles can often be replaced with the recommended PF approach.

🧹 Nitpick comments (2)
libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (2)

24-27: Consider using explicit default values for your React states.
Defining default values (e.g., React.useState<Credentials | undefined>(undefined)) can provide clearer intent and reduce potential undefined checks. This is a minor improvement for clarity.


66-82: Revisit the 500ms timeout.
Using a setTimeout to reset isDownloading might lead to UI inconsistencies in edge cases or overly delay the user's next action if the download completes quickly. Consider removing this artificial delay or using a more adaptive approach (e.g., reset state immediately after downloads complete).

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f0edb15 and e3b62ec.

📒 Files selected for processing (9)
  • libs/locales/lib/en/translation.json (6 hunks)
  • libs/ui-lib/lib/common/components/clusterDetail/ClusterCredentials.tsx (2 hunks)
  • libs/ui-lib/lib/common/components/ui/WizardFooter.tsx (3 hunks)
  • libs/ui-lib/lib/common/config/docs_links.ts (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizard.tsx (2 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContextProvider.tsx (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/constants.ts (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/wizardTransition.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • libs/ui-lib/lib/common/config/docs_links.ts
  • libs/ui-lib/lib/common/components/clusterDetail/ClusterCredentials.tsx
  • libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContextProvider.tsx
  • libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizard.tsx
  • libs/ui-lib/lib/common/components/ui/WizardFooter.tsx
  • libs/ui-lib/lib/ocm/components/clusterWizard/constants.ts
  • libs/ui-lib/lib/ocm/components/clusterWizard/wizardTransition.ts
  • libs/locales/lib/en/translation.json
🧰 Additional context used
🧬 Code Graph Analysis (1)
libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (7)
libs/types/assisted-installer-service.d.ts (2)
  • Cluster (110-398)
  • Credentials (756-760)
libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContext.tsx (1)
  • useClusterWizardContext (25-31)
libs/ui-lib/lib/common/hooks/index.ts (1)
  • useTranslation (3-3)
libs/ui-lib/lib/ocm/services/apis/index.ts (1)
  • ClustersAPI (5-5)
libs/ui-lib/lib/common/api/utils.ts (2)
  • handleApiError (19-51)
  • getApiErrorMessage (53-58)
libs/ui-lib/lib/common/utils.ts (2)
  • getErrorMessage (13-21)
  • downloadFile (92-108)
libs/ui-lib/lib/common/config/docs_links.ts (1)
  • KUBECONFIG_INFO_LINK (186-187)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: tests
  • GitHub Check: translation-files
  • GitHub Check: circular-deps
  • GitHub Check: format
  • GitHub Check: unit-tests
  • GitHub Check: lint
🔇 Additional comments (1)
libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (1)

50-64: Looks good!
The downloadSingleFile method correctly uses async/await to fetch credential files and handles errors with handleApiError. Overall, this section appears solid.

@ElayAharoni ElayAharoni force-pushed the refactor-kubeconfig-download-to-new-design-of-credentials-download branch from e3b62ec to 066bccb Compare April 9, 2025 11:42
Copy link

@coderabbitai coderabbitai bot left a 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 (2)
libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (2)

114-115: Avoid inline styling

As mentioned in previous review comments, custom inline styling should be avoided when possible. Use PatternFly spacing utilities or components that provide margin/padding options.

-          <Checkbox
-            style={{ marginBottom: '50px' }}
-            id="credentials-download-agreement"
+          <Checkbox
+            className="pf-v5-u-mb-xl"
+            id="credentials-download-agreement"

122-122: Replace inline styling with PatternFly utilities

Inline styling should be replaced with PatternFly layout components or utility classes.

-          <Grid style={{ justifyItems: 'start' }}>
+          <Grid hasGutter className="pf-v5-u-justify-content-flex-start">
🧹 Nitpick comments (3)
libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (3)

58-59: Internationalize error message title correctly

The error message title should use the i18n framework with the 'ai:' namespace prefix, similar to other translated strings in the file.

-        title: t(`Could not download ${fileName} file`),
+        title: t('ai:Could not download {{fileName}} file', { fileName }),

98-98: Missing internationalization for header text

The header text "Download credentials" should be internationalized using the translation function with the 'ai:' namespace prefix, similar to other translated strings in the component.

-          <ClusterWizardStepHeader>Download credentials</ClusterWizardStepHeader>
+          <ClusterWizardStepHeader>{t('ai:Download credentials')}</ClusterWizardStepHeader>

66-81: Consider adding success feedback

The handleDownloadClick function handles downloads and error cases, but doesn't provide positive feedback when downloads succeed. Consider adding a success alert to improve user experience.

   const handleDownloadClick = async () => {
     setIsDownloading(true);
 
     const configSuccess = await downloadSingleFile('kubeconfig');
     const passwordSuccess = await downloadSingleFile('kubeadmin-password');
 
     const hasError = !configSuccess || !passwordSuccess;
 
     setTimeout(() => {
       setIsDownloading(false);
 
       if (!hasError) {
+        addAlert({
+          title: t('ai:Credentials downloaded successfully'),
+          variant: AlertVariant.success,
+        });
         clusterWizardContext.moveNext();
       }
     }, 500);
   };
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e3b62ec and 066bccb.

📒 Files selected for processing (9)
  • libs/locales/lib/en/translation.json (6 hunks)
  • libs/ui-lib/lib/common/components/clusterDetail/ClusterCredentials.tsx (2 hunks)
  • libs/ui-lib/lib/common/components/ui/WizardFooter.tsx (3 hunks)
  • libs/ui-lib/lib/common/config/docs_links.ts (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizard.tsx (2 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContextProvider.tsx (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/constants.ts (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/wizardTransition.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • libs/ui-lib/lib/common/config/docs_links.ts
  • libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContextProvider.tsx
  • libs/ui-lib/lib/common/components/clusterDetail/ClusterCredentials.tsx
  • libs/ui-lib/lib/common/components/ui/WizardFooter.tsx
  • libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizard.tsx
  • libs/ui-lib/lib/ocm/components/clusterWizard/constants.ts
  • libs/ui-lib/lib/ocm/components/clusterWizard/wizardTransition.ts
  • libs/locales/lib/en/translation.json
🧰 Additional context used
🧬 Code Graph Analysis (1)
libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (7)
libs/types/assisted-installer-service.d.ts (2)
  • Cluster (110-398)
  • Credentials (756-760)
libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContext.tsx (1)
  • useClusterWizardContext (25-31)
libs/ui-lib/lib/common/hooks/index.ts (1)
  • useTranslation (3-3)
libs/ui-lib/lib/ocm/services/apis/index.ts (1)
  • ClustersAPI (5-5)
libs/ui-lib/lib/common/api/utils.ts (1)
  • getApiErrorMessage (53-58)
libs/ui-lib/lib/common/utils.ts (2)
  • getErrorMessage (13-21)
  • downloadFile (92-108)
libs/ui-lib/lib/common/config/docs_links.ts (1)
  • KUBECONFIG_INFO_LINK (186-187)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: circular-deps
  • GitHub Check: tests
  • GitHub Check: lint
  • GitHub Check: format
🔇 Additional comments (5)
libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (5)

31-48: Correct implementation of data fetching

Good job implementing the feedback to combine useCallback and useEffect. The current implementation correctly fetches credentials when the component mounts or when the cluster ID changes.


69-70: Fixed filename issue

The incorrect kubeconfig filename has been fixed as suggested in the previous review.


97-97: Good use of PatternFly layout

Well done using the Stack hasGutter component as suggested in the previous review instead of custom styling.


127-127: Fixed error condition check

The error condition has been correctly updated to use a proper truthy check with !!credentialsError as suggested in the previous review.


50-64:

Details

✅ Verification successful

Check for consistent error handling approach

The downloadSingleFile function uses handleApiError correctly, but you should ensure the error messages follow the same pattern across the application. Consider extracting common error handling to a utility function if this pattern is repeated elsewhere.


🏁 Script executed:

#!/bin/bash
# Check if similar error handling patterns exist in other files
rg -A 3 "handleApiError" --glob "*.tsx" | grep -v "CredentialsDownload.tsx"

Length of output: 25539


Consistent Error Handling Verified

The downloadSingleFile function’s error handling using handleApiError aligns with the patterns observed across the codebase. Searches in similar modules (e.g., in ResetSingleClusterModal.tsx, ClusterDetails.tsx, and others) confirm that the approach—invoking handleApiError with an inline callback that calls addAlert using a title and getApiErrorMessage(e)—is applied consistently.

  • The same error handling pattern is reused in multiple files.
  • Consider extracting this common logic to a utility function if you predict further repetition, but note that the error messages are tailored per context, so any refactoring should preserve the necessary specificity.

Signed-off-by: Elay Aharoni <elayaha@gmail.com>
@ElayAharoni ElayAharoni force-pushed the refactor-kubeconfig-download-to-new-design-of-credentials-download branch from 066bccb to 18b9681 Compare April 9, 2025 13:31
Copy link

@coderabbitai coderabbitai bot left a 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)
libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (1)

126-126: Correct error condition check implementation.

You've successfully implemented the suggested fix to use !!credentialsError instead of credentialsError !== '' for the error condition check. This correctly handles both undefined and empty string cases.

🧹 Nitpick comments (2)
libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (2)

66-81: Consider extracting the timeout duration to a named constant.

The 500ms timeout in the handleDownloadClick function works well for providing UI feedback, but hardcoded values reduce code maintainability. Consider extracting this to a named constant at the top of the file or component.

+ const DOWNLOAD_FEEDBACK_DELAY_MS = 500;
  
  const handleDownloadClick = async () => {
    // ...
    setTimeout(() => {
      setIsDownloading(false);

      if (!hasError) {
        clusterWizardContext.moveNext();
      }
-   }, 500);
+   }, DOWNLOAD_FEEDBACK_DELAY_MS);
  };

94-132: Consider replacing inline style with PatternFly components.

Great job using <Stack hasGutter> as suggested in previous comments. However, there's still an inline style on the Grid component. Consider using PatternFly layout components or modifiers instead of custom styling when possible.

- <Grid hasGutter style={{ justifyItems: 'start' }}>
+ <Grid hasGutter className="pf-m-align-left">

or if you want the grid items to start-align:

- <Grid hasGutter style={{ justifyItems: 'start' }}>
+ <Grid hasGutter alignItems="flex-start">
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 066bccb and 18b9681.

📒 Files selected for processing (9)
  • libs/locales/lib/en/translation.json (7 hunks)
  • libs/ui-lib/lib/common/components/clusterDetail/ClusterCredentials.tsx (2 hunks)
  • libs/ui-lib/lib/common/components/ui/WizardFooter.tsx (3 hunks)
  • libs/ui-lib/lib/common/config/docs_links.ts (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizard.tsx (2 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContextProvider.tsx (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/constants.ts (1 hunks)
  • libs/ui-lib/lib/ocm/components/clusterWizard/wizardTransition.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • libs/ui-lib/lib/common/components/clusterDetail/ClusterCredentials.tsx
  • libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizard.tsx
  • libs/ui-lib/lib/common/config/docs_links.ts
  • libs/ui-lib/lib/ocm/components/clusterWizard/constants.ts
  • libs/ui-lib/lib/common/components/ui/WizardFooter.tsx
  • libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContextProvider.tsx
  • libs/ui-lib/lib/ocm/components/clusterWizard/wizardTransition.ts
  • libs/locales/lib/en/translation.json
🧰 Additional context used
🧬 Code Graph Analysis (1)
libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (7)
libs/types/assisted-installer-service.d.ts (2)
  • Cluster (110-398)
  • Credentials (756-760)
libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContext.tsx (1)
  • useClusterWizardContext (25-31)
libs/ui-lib/lib/common/hooks/index.ts (1)
  • useTranslation (3-3)
libs/ui-lib/lib/ocm/services/apis/index.ts (1)
  • ClustersAPI (5-5)
libs/ui-lib/lib/common/api/utils.ts (1)
  • getApiErrorMessage (53-58)
libs/ui-lib/lib/common/utils.ts (2)
  • getErrorMessage (13-21)
  • downloadFile (92-108)
libs/ui-lib/lib/common/config/docs_links.ts (1)
  • KUBECONFIG_INFO_LINK (186-187)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: tests
  • GitHub Check: translation-files
  • GitHub Check: format
  • GitHub Check: lint
🔇 Additional comments (4)
libs/ui-lib/lib/ocm/components/clusterWizard/CredentialsDownload.tsx (4)

50-64: Well-structured downloadSingleFile function with proper error handling.

The function properly handles downloading credential files, shows appropriate error messages using the alert system, and returns a success/failure status that's used by the parent function. Good use of the handleApiError utility as requested in previous comments.


31-48: Clean implementation of credentials fetching.

Good job incorporating the previous feedback to consolidate the logic into a single useEffect hook. The credentials fetching logic properly resets errors, handles the API call, and manages state updates in a clean way.


22-29: State management looks good with proper types.

The component's state is well-organized with appropriate types. Nice job implementing the previous feedback to use undefined as the default for credentialsError instead of an empty string.


83-92: Well-implemented footer with appropriate button states.

The footer component correctly manages the disabled state of the download button based on checkbox status and download progress. The loading state is also properly handled during downloads.

@openshift-ci openshift-ci bot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 10, 2025
@rawagner
Copy link
Member

/approve
/lgtm

@openshift-ci
Copy link

openshift-ci bot commented Apr 10, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ElayAharoni, rawagner

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit b47bbab into openshift-assisted:master Apr 10, 2025
11 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jun 9, 2025
ammont82 pushed a commit to ammont82/assisted-installer-ui that referenced this pull request Sep 12, 2025
… download (openshift-assisted#2905)

* refactor kubeconfig download to credentials download

Signed-off-by: Elay Aharoni <elayaha@gmail.com>

* Download credentials page

Signed-off-by: Elay Aharoni <elayaha@gmail.com>

---------

Signed-off-by: Elay Aharoni <elayaha@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants