2.2.47 • Published 3 years ago

@redhat-cloud-services/frontend-components-sources v2.2.47

Weekly downloads
480
License
Apache-2.0
Repository
github
Last release
3 years ago

Table of Contents

Sources

npm version

This package exports Add Source Wizard and Add Source button, as other components, which wizard uses.

Install

npm install @redhat-cloud-services/frontend-components-sources

Please import styles in your scss files, where are you using AddSource Wizard or CardSelect

@import '~@redhat-cloud-services/frontend-components-sources/index.css';

Using

As a primary button

import { AddSourceButton } from '@redhat-cloud-services/frontend-components-sources';


<AddSourceButton />

As a Wizard

import { AddSourceWizard } from '@redhat-cloud-services/frontend-components-sources';


<AddSourceWizard isOpen={this.state.isOpen} onClose={ () => this.setIsOpen(false)}/>

Props

PropTypeDefaultDescription
isOpenboolfalseYou need to control yourselves if the wizard is open or not. (Not needed for the button version)
afterSuccessfunctionnullThis function will be executed after successful creation of a source. In Sources-UI this method is used for updating the list of sources.
onClosefunctionnullThis function will be executed after closing the wizard. Eg. set isOpen to false. In case of closing wizard before submitting, form values are passed as the first argument. If source has been successfully created, the source is passed as the second argument.
successfulMessagenode'Your source has been successfully added.'A message shown on the last page of the wizard. Can be customized when accessing from different app (eg. 'Source was added to Cost Management')
sourceTypesarraynullSourceTypes array. This prop can be used on pages, which have already loaded the source types, so there is no need to load them in this component.
applicationTypesarraynullapplicationTypes array. This prop can be used on pages, which have already loaded the application types, so there is no need to load them in this component.
initialValuesobject{}Object with initialValues of the form.
disableAppSelectionboolfalseFlag to disable appSelection.
hideSourcesButtonboolfalsehide 'Take me to sources' button.
returnButtonTitlenode'Go back to sources'Title of the button shown after success submit. Put your own application name if you neeed.
selectedTypestringundefinedA name of source type preselected - this will remove the source type selection. (Only for Cloud types.)
initialWizardStateobjectundefinedAn initial state passed to the wizard component. See here.
submitCallbackfunctionundefinedAn function that is always called when the submit finishes. (state) => ... In case of success, the state is a following object: {createdSource, sourceTypes, isSubmitted: true}, in case of any unhandled error: {values, sourceTypes, isErrored, wizardState, error }

If you need to set up and support only one application you can provide filtered applicationTypes with the only one application, set up disableAppSelection to false and initialValues to:

{
    application: {
        application_type_id: 'YOUR_APP_ID'
    }
}

Modification of the wizard

Please, if you need to update the wizard, take a look on a guide first.

Format for sourceType schema

schema = {
  :authentication => {
    :name_of_the_authentication_type => {
      :meta => {
        name: 'Token' # Will be shown in the authentication selection step
      },
      :fields => {
        # DDF Fields, will be shown in the authentication selection step
        {
          :component    => "text-field",
          :name         => "authentication.authtype",
          :hideField    => true,
          :initialValue => "username_password",
          :stepKey      => 'openshift-token-additional-field'
        },
      },
    }
  },
  :endpoint => {
    :title => 'Title', # If the endpoint will be on a separate step
    :hidden => true, # If true, the endpoint step will be hidden, use if all components have `:hideField => true`
    :fields => {
      # DDF Fields
      {:component => "checkbox", :name => "endpoint.verify_ssl", :label => "Verify SSL"},
      ...
    }
  }
}

Hardcoded component schema

In hardcodedSchema, there is an object which defines additional UI enhancements of the flow for combinations of sourceTypes and appTypes. The format has following structure: source-type-name.authenication.auth-type.app-name. For generic steps use as the app-name generic. Each of these objects has following keys:

keydescription
additionalFieldsThese fields are appended to the authType selection page.
name of field (ex. authentication.passwordThis defines additional props for the field (can be used for enhancing of API fields).
additionalStepsDefines additional steps.
skipSelectionIf there is only one authType, this flag will cause to skip the selection page.
skipEndpointIf it is set to true, all endpoint.* and authentications.* values will be ignored and no endpoint step will be shown to user.
useApplicationAuthIf it is set to true, the authentication record will be linked to a application, not endpoint. Use if you want to avoid using topology for checking source status.

Additional components

This package also uses and exports other components:

CardSelect

Use in schema as component: 'card-select' after you add it to your component mapper of your data driven form renderer. If you want to use this component outside React final form, please provide custom meta and input props. (See React Final Form)

Props

This components accepts all formGroup props (label, helperText, isDisabled, isRequired, ...)

PropTypeDescription
optionsarrayArray of options with keys value, label, isDisabled
DefaultIconelement, node, funcDefault icon (default is ServerIcon)
iconMapper*funcYou can use your own mapper (value, DefaultIcon) => ...
multi/isMultiboolAllows to select more items
mutatorfunc(option, formOptions) => option, func which mutates options

* In the future it could be replaced by data obtained from API

SourceWizardSummary

Adds a summary of formValues to the form.

Props

PropTypeDescription
sourceTypesarraySourceTypes array with schemas.
applicationTypesarrayapplicationTypes array with schemas.
showAppboolDefault: true, shows the application selection in the summary
showAuthTypeboolDefault: true, shows the authtype selection in the summary

Others

This package exports some other components and functions, which are used in Sources-UI. They are not intended to be used anywhere else.

2.2.47

3 years ago

2.2.46

3 years ago

2.2.45

3 years ago

2.2.44

3 years ago

2.2.43

3 years ago

2.2.42

3 years ago

2.2.39

3 years ago

2.2.40

3 years ago

2.2.41

3 years ago

2.2.38

3 years ago

2.2.37

3 years ago

2.2.35

3 years ago

2.2.36

3 years ago

2.2.34

3 years ago

2.2.33

3 years ago

2.2.32

3 years ago

2.2.31

3 years ago

2.2.30

3 years ago

2.2.28

3 years ago

2.2.29

3 years ago

2.2.26

3 years ago

2.2.27

3 years ago

2.2.24

3 years ago

2.2.25

3 years ago

2.2.23

3 years ago

2.2.22

3 years ago

2.2.21

3 years ago

2.2.20

3 years ago

2.2.19

3 years ago

2.2.18

3 years ago

2.2.17

3 years ago

2.2.16

4 years ago

2.2.15

4 years ago

2.2.14

4 years ago

2.2.13

4 years ago

2.2.12

4 years ago

2.2.11

4 years ago

2.2.10

4 years ago

2.2.9

4 years ago

2.2.8

4 years ago

2.2.7

4 years ago

2.2.6

4 years ago

2.2.5

4 years ago

2.2.3

4 years ago

2.2.4

4 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.15

4 years ago

2.1.14

4 years ago

2.1.13

4 years ago

2.1.12

4 years ago

2.1.11

4 years ago

2.1.9

4 years ago

2.1.10

4 years ago

2.1.8

4 years ago

2.1.7

4 years ago

2.1.6

4 years ago

2.1.5

4 years ago

2.1.4

4 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.1.0-beta

4 years ago

2.0.8

4 years ago

2.0.7

4 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.6

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.34

4 years ago

2.0.0-beta

4 years ago

1.0.33

4 years ago

1.0.32

4 years ago

1.0.31

4 years ago

1.0.30

4 years ago

1.0.29

4 years ago

1.0.28

4 years ago

1.0.27

4 years ago

1.0.26

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.22

4 years ago

1.0.22-rc1

4 years ago

1.0.19

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.34-RC3

4 years ago

0.0.34-RC2

4 years ago

0.0.34-beta

4 years ago

0.0.34

4 years ago

0.0.33

4 years ago

0.0.32

4 years ago

0.0.31

4 years ago

0.0.30

4 years ago

0.0.28

4 years ago

0.0.29

4 years ago

0.0.27

4 years ago

0.0.25

4 years ago

0.0.26

4 years ago

0.0.24

4 years ago

0.0.23

4 years ago

0.0.22

4 years ago

0.0.21

4 years ago

0.0.20

4 years ago

0.0.19

4 years ago

0.0.18

4 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago