Examples
Table
This shows a table with three columns:
- The first column shows a conditional use of Nunjucks to show the name taken from the
spec.mesh
field if it exists, otherwise it shows the name taken from themetadata
field; - the second column shows a reference link (to the owner of the component);
- the third column shows a simple description string
- type: table
path: components
children:
- type: string
label: Name
value: '{{ spec.mesh.name if spec.mesh.name else metadata.name }}'
width: 30%
- type: link
label: Name
path: owner
width: 20%
- type: string
label: Description
path: metadata.description
width: 50%
Card
Simple Card
This shows a card with just a name, version and description
- type: card
title: General Information
children:
- type: container
children:
- label: Name
type: string
path: name
- label: Version
type: string
path: version
- label: Description
type: string
path: description
New Root inside a Card
This shows a card where to simplify the definition, a new root is defined. To achieve this behavior, it uses the new_root
component to simplify the paths of its children (so that you can write upTime
instead of dataContract.SLA.upTime
)
- type: card
title: Data Contract
children:
- type: sub_card
title: SLA
children:
- type: container
children:
- type: new_root
path: dataContract.SLA
children:
- label: upTime
type: string
path: upTime
- label: timeliness
type: string
path: timeliness
- label: interval of change
type: string
path: intervalOfChange
- label: Terms and Conditions
type: string
path: dataContract.termsAndConditions
colSpan: 4
Complete Example
This excerpt here, is extracted from the Marketplace component page:
view:
children:
- type: grid_list
children:
- type: include
id: marketplace_component_general
- type: grid_sequence
path: _componentsByKind
showWhenExists: components
showWhen:
value: '{{ components | some("consumable", true) }}'
equals: 'true'
children:
- type: card
title: '{{ label }}'
children:
- type: table
showRowWhen:
value: '{{consumable}}'
notEquals: false
click: showSubcomponent
path: components
children:
- type: string
value: '{{ name }}'
label: Name
- type: string
value: '{{ description }}'
label: Description
- type: string
value: '{{ technology }}'
label: Technology
- type: marketplace_tech_card
configs:
- buildInfo
- info
- type: card
title: Data Contract
showWhenExists:
- dataContract.SLA
- dataContract.schema[0]
children:
- type: sub_card
title: SLA
showWhenExists: dataContract.SLA
children:
- type: container
children:
- type: new_root
path: dataContract.SLA
children:
- label: upTime
type: string
path: upTime
showWhenExists: upTime
- label: timeliness
type: string
path: timeliness
showWhenExists: timeliness
- label: interval of change
type: string
path: intervalOfChange
showWhenExists: intervalOfChange
- label: Terms and Conditions
type: string
path: dataContract.termsAndConditions
showWhenExists: dataContract.termsAndConditions
colSpan: 4
- type: schema_list
path: dataContract.schema
children:
- type: grid_sequence
path: ''
children:
- type: card
title: '{{ name }}'
children:
- type: table
path: columns
treeview: children
hideEmptyColumns: true
children:
- type: string
path: dataType
width: 15%
label: Type
- type: string
path: name
width: 30%
label: Name
- type: string
path: description
width: 40%
label: Description
- type: tags
path: tags
width: 10%
label: Tags
- type: row_link
label: Semantic Link
path: _semanticlink
align: right
width: 5%
click: showSemanticLink
- type: vspace
- showWhenExists: dataSharingAgreements
type: card
title: Data Sharing Agreement
children:
- type: container
children:
- type: automatic_fields_list
path: dataSharingAgreements
defaults:
_default:
colSpan: '2'
- type: data_preview
title: Data Preview
In the example above, we can notice:
- first of all a
grid_list
, which contains a list of all the page's cards; - then, the first child is an
include
component, which includes themarketplace_component_general
custom view; this shows the general information of the component, without the need to redefine it here. - then, we want to display the sub-components of the component, if the component have them, and if at least one of them is consumable. Since the sub-components might be of different kinds, we want to display them grouped by their kind. To achieve this:
- we use a
grid_sequence
component, which iterates over the_componentsByKind
array. TheshowWhenExists
property makes sure that the card is shown only if thecomponents
array is not empty, while theshowWhen
property makes sure that the card is shown only if at least one of the sub-components is consumable. - for each element of
_componentsByKind
, we define acard
with the kind as title, and then atable
with all the sub-components of that kind. note that we show the row only if the sub-component is consumable, by using theshowRowWhen
property. - for each component in the table we show the name, description and technology of the sub-component as
string
components. - the
table
defines a click action to show the sub-component detailsshowSubcomponent
.
- we use a
- then, we show the
marketplace_tech_card
custom view, which iterates thebuildInfo
and theinfo
fields of the component's descriptor; this a custom view that iterates all the sub-fields of the inputconfigs
array, and shows them automatically if they comply to the rules. - then, we show the
Data Contract
card, which contains the SLA and the schema of the component, if they exist. We ensure this by using theshowWhenExists
property. Note that theshowWhenExists
property checks the conditions with anOR
operator, so the card is shown only if the SLA or the schema are defined- the SLA is shown as a
sub_card
, with the titleSLA
, and then acontainer
where we define all the SLA fields that we want to display. We use thenew_root
component to simplify the paths of the children, so that we can writeupTime
instead ofdataContract.SLA.upTime
. We also use theshowWhenExists
property to show the field only if it is defined. - to show the schema, we need to first wrap it in a
schema_list
; this is needed since the schema could be a single definition, or an array of schemas: using theschema_list
, which converts thedataContract.schema
to an array, we can easily iterate over it. We iterate using agrid_sequence
, and for each element we define acard
with the schema name as title. Then, we define atable
with the all the schema columns we want to display (note that the last column is arow_link
to show the semantic link of the column, with theshowSemanticLink
action). Thetable
has thetreeview
property set tochildren
: this means that if a row element has achildren
field containing sub-rows, the table will show them as a tree. We also set thehideEmptyColumns
property totrue
, so that the table will not show columns with no data. To add some space between the schemas, we add a finalvspace
component.
- the SLA is shown as a
- then, we show the
Data Sharing Agreement
card, which contains the data sharing agreements of the component, if they exist. We ensure this by using theshowWhenExists
property. The data sharing agreements are shown using anautomatic_fields_list
component, which automatically iterates over thedataSharingAgreements
field, and shows all of its fields. By setting thedefaults
property, we can define default properties for all the fields: in this case we set thecolSpan
property to2
for all the fields. - finally, we show the
Data Preview
card, which contains the data preview of the component. This component can't be configured: it checks if thesampleData
field is defined, and if it is, it shows the data preview as a table.