migtools / crane-ui-plugin

OpenShift Dynamic Plugin for Crane UI
1 stars 11 forks source link

"Application Imports" management page - initial implementation #88

Closed mturley closed 2 years ago

mturley commented 2 years ago

Implements https://issues.redhat.com/projects/MTRHO/issues/MTRHO-11

Replacement for https://github.com/konveyor/crane-ui-plugin/pull/76 to re-target main from my fork. Thanks so much for your work on this @seanforyou23, I'll get it over the finish line now šŸ˜„

This PR adds a new page to the console called "Application Imports" (for now; all of this terminology is temporary). This page provides:

Under the hood, this PR introduces a new concept called "Pipeline groups" which does not necessarily need to be exposed to the user. A "pipeline group", or a single "application import", is made up of all of the Pipelines and PipelineRuns that were generated by one usage of the import wizard. A group will always have one cutover pipeline (the primary resource), and may have 0 or 1 stage pipelines, and at least 1 PipelineRun for each pipeline. The following annotations are attached to every Pipeline and PipelineRun generated by the wizard, to facilitate this:

The useWatchCranePipelineGroups hook at src/api/queries/pipelines.ts assembles these groups from socket-watched arrays of all Pipelines and PipelineRuns in the namespace. Each of them is returned as a CranePipelineGroup object which have conveniently indexed properties, and this is the single object passed around all the components of this page.

export interface CranePipelineGroup {
  name: string;
  pipelines: {
    stage: CranePipeline | null;
    cutover: CranePipeline;
  };
  pipelineRuns: {
    stage: CranePipelineRun[];
    cutover: CranePipelineRun[];
    all: CranePipelineRun[];
    nonPending: CranePipelineRun[];
    latestNonPending: CranePipelineRun | null;
  };
}

You can also see here that the CranePipeline and CranePipelineRun types have been added. These are just supersets of the PipelineKind and PipelineRunKind types with our new action and group annotations on them for typechecking and autocomplete purposes.

The page requires a project/namespace to be selected before reaching it (eventually we will be able to streamline this like the Add page and Pipelines pages do in the developer console, but that requires new features in the plugin SDK. See https://github.com/openshift/console/pull/11823). If you reach the page without a selected project it will direct you to the Projects page.

If you reach the page before reaching the wizard, an EmptyState screen will direct you to the wizard. There is also a "start a new import" button in the corner to more easily reach the wizard later.

This PR duplicates a small amount of code from the Console Pipelines UI, the pipelineRunStatus function in the src/reused/pipelines-plugin/src/utils/pipeline-filter-reducer.ts file (source copied from https://github.com/openshift/console/blob/master/frontend/packages/pipelines-plugin/src/utils/pipeline-filter-reducer.ts). This allows us to determine the status of a PipelineRun to show in our UI, and like the pipeline visualization and types we have also duplicated in src/reused/* we should be sure to keep it up to date and eventually see if we can remove it and consume this code directly from the console some other way.

This PR does not include some additional enhancements including updating secrets and small polish items like confirmation dialogs. I'll open issues for those shortly.

Screens

Empty state when the wizard has not been used yet Screen Shot 2022-07-14 at 2 02 57 PM

No tabs present when there is only one pipeline group (stage and cutover buttons are visible because this one is a stateful migration with PVCs selected) Screen Shot 2022-07-14 at 2 03 32 PM

Tabs shown when there are more than one group (no stage button visible because this one is a stateless migration with no PVCs) Screen Shot 2022-07-14 at 2 04 03 PM

History after running some Stage / Cutover PipelineRuns (failing in my test case, but status will match status shown on PipelineRuns page)

Screen Shot 2022-07-14 at 4 33 57 PM
openshift-ci[bot] commented 2 years ago

Skipping CI for Draft Pull Request. If you want CI signal for your change, please convert it to an actual PR. You can still manually trigger a test run with /test all

mturley commented 2 years ago

/retest

openshift-ci[bot] commented 2 years ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ibolton336, mturley

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

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/konveyor/crane-ui-plugin/blob/main/OWNERS)~~ [ibolton336,mturley] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment