Documentation

Class: RepoList

Description: The RepoList component is a React component responsible for displaying a list of repositories and allowing the user to select one. It fetches repositories from the API, handles loading states, and displays an alert if no repositories are available or if the selected repository has no files.

Implements:

  • React Component

Methods


Method: RepoList

Description: This is the constructor method for the RepoList component. It receives props containing the user object (containing user information), the onSelect callback to be called when a repository is selected, the onClose callback to be called when the component is closed, and any additional props (...props).

Parameters:

  • user (Object): The user object, which may contain information such as their status.
  • onSelect (Function): A callback function to be invoked when a repository is selected.
    • Parameters:
      • repo (Object): The selected repository object.
  • onClose (Function): A callback function to be invoked when the component is closed.
  • ...props (Object): Additional props passed to the component.

Returns:

  • ReactElement: The rendered JSX for the RepoList component.

Example:

<RepoList user={currentUser} onSelect={handleRepoSelect} onClose={handleClose} />

==========

Class: _alerts

Description: The _alerts object defines a collection of alert messages displayed within the RepoList component.

Methods


Method: noRepo

Description: The noRepo function creates an alert message to be displayed when no repositories are found or when a user has not yet connected their repositories.

Parameters:

  • close (Function): A callback function to be called when the user clicks the alert message.

Returns:

  • ReactElement: The rendered JSX for the alert message.

Example:

const alertMessage = _alerts.noRepo(handleClose);

Method: noFiles

Description: The noFiles function creates an alert message to be displayed when the selected repository does not contain any files.

Parameters:

  • None

Returns:

  • ReactElement: The rendered JSX for the alert message.

Example:

const alertMessage = _alerts.noFiles();

==========

Class: open

Description: The open function is responsible for handling the selection of a repository from the list. It updates the loading state, fetches remote repository details, reorders branches to bring the default branch to the top, and updates the alert message if needed.

Parameters:

  • repo (Object): The repository object selected by the user.

Returns:

  • void

Example:

const handleRepoSelect = (repo) => {
  open(repo);
};