Documentation

Class: RepoContents

Description: The RepoContents component displays the contents of a repository, allowing users to select files and launch a pipeline. It utilizes several sub-components to provide functionality for browsing, selecting, and managing files within the repository.

Methods


Method: runPipeline

Description: The runPipeline method is responsible for initiating a pipeline execution based on the user's selection of files.

Parameters:

  • file (any): The file object to be used for pipeline execution. If not provided, the selected files from selection will be used.
  • id (any): The ID of the repository. If not provided, the repo.id will be used.
  • fork (any): The branch to be used for pipeline execution. If not provided, the current branch.name will be used.

Returns:

  • void: This method does not return any value.

Throws:

  • Error: If an error occurs during the pipeline launch process, an error will be thrown and handled accordingly.

Example:

const file = { /* file object */ };
const repoId = 12345;
const branchName = "main";

runPipeline(file, repoId, branchName); 

Important Considerations:

  • The method assumes that the launchQuickstart function is available for executing pipelines.
  • The _errors.recentlyCommitted() function is used to display an error message if the pipeline launch fails due to recent commits.

Method: select

Description: The select method manages the selection of files within the repository.

Parameters:

  • e (Event): The event triggered by the selection action.
  • files (any[]): An optional array of file objects. If not provided, it will update the selection based on the bulk toggle action of the file tree.

Returns:

  • void: This method does not return any value.

Example:

const event = { /* event object */ };
const files = [{ /* file object */ }, { /* file object */ }]; 

select(event, files);

Important Considerations:

  • The method uses filesRef.current.bulkToggle to handle bulk selection and filesRef.current.sync to synchronize the selection state.

Method: _reset

Description: The _reset method resets the state of the RepoContents component, clearing the repository selection and any error messages.

Parameters:

  • None

Returns:

  • void: This method does not return any value.

Example:

_reset();

Important Considerations:

  • The method uses setRepo(null) and setError(null) to reset the repository selection and error state respectively.

Method: _close

Description: The _close method handles closing the RepoContents component, resetting the state and invoking the onClose callback.

Parameters:

  • None

Returns:

  • void: This method does not return any value.

Example:

_close();

Important Considerations:

  • The method first calls _reset to clear the state and then calls onClose() to notify the parent component about the closure.

Class: _errors

Description: The _errors object defines a set of error messages that are displayed in the RepoContents component under specific circumstances.

Methods


Method: noFiles

Description: The noFiles method returns a JSX element indicating that the repository contains no files.

Parameters:

  • None

Returns:

  • JSX.Element: A JSX element displaying the error message.

Example:

const errorMessage = _errors.noFiles(); 

Method: noSupported

Description: The noSupported method returns a JSX element indicating that the repository contains no supported files.

Parameters:

  • None

Returns:

  • JSX.Element: A JSX element displaying the error message.

Example:

const errorMessage = _errors.noSupported();

Method: recentlyCommitted

Description: The recentlyCommitted method returns a JSX element indicating that an error occurred while pushing to recently committed files.

Parameters:

  • None

Returns:

  • JSX.Element: A JSX element displaying the error message.

Example:

const errorMessage = _errors.recentlyCommitted();

Important Considerations:

  • The error messages are defined as JSX elements, allowing them to be easily integrated into the component's UI.

Note: The provided code snippet only describes the RepoContents component and its related methods. For complete documentation, you would need to analyze and document each imported component and function used within the codebase.