$schema: http://json-schema.org/draft-07/schema
description: Schema defining structure of list configuration
type: array
items:
  $ref: "#/$defs/component"
$defs:
  children:
    type: array
    items:
      $ref: "#/$defs/component"
  placeholder:
    type: string
    description: Empty text placeholder (defaults to "-")
  copyable:
    type: boolean
    description: Display a "Copy to clipboard" button next to the widget.
  component:
    type: object
    properties:
      name:
        description: Name of component used for dispaying translations
        type: string
      source:
        description: Jsonata script used to fetch the data
        examples:
          - status.phase
          - metadata.labels
        type: string
        widget: Jsonata
      widget:
        description: Name of a widget that should be used for displaying data defined by path
        examples:
          - Badge
          - CodeViewer
        type: string
        enum:
          - Alert
          - Badge
          - CodeViewer
          - Columns
          - ControlledBy
          - EventList
          - ExternalLink
          - JoinedArray
          - Labels
          - Panel
          - Plain
          - ResourceLink
          - ResourceList
          - ResourceRefs
          - Table
          - Tabs
          - Text
      visibility:
        type: string
        widget: Jsonata
    allOf:
      - $ref: "#/$widgets/Alert"
      - $ref: "#/$widgets/Badge"
      - $ref: "#/$widgets/CodeViewer"
      - $ref: "#/$widgets/Columns"
      - $ref: "#/$widgets/ControlledBy"
      - $ref: "#/$widgets/EventList"
      - $ref: "#/$widgets/ExternalLink"
      - $ref: "#/$widgets/JoinedArray"
      - $ref: "#/$widgets/Labels"
      - $ref: "#/$widgets/Panel"
      - $ref: "#/$widgets/Plain"
      - $ref: "#/$widgets/ResourceLink"
      - $ref: "#/$widgets/ResourceList"
      - $ref: "#/$widgets/ResourceRefs"
      - $ref: "#/$widgets/Table"
      - $ref: "#/$widgets/Tabs"
      - $ref: "#/$widgets/Text"
$widgets:
  Alert:
    if:
      properties:
        widget:
          const: Alert
    then:
      required:
        - source
      properties:
        severity:
          description: Specifies the severity of the alert.
          type: string
          enum: [information, warning, error, success]
        disableMargin:
          description: Disable the margin outside the alert body.
          type: boolean
  Badge:
    if:
      properties:
        widget:
          const: Badge
    then:
      required:
        - source
      properties:
        placeholder:
          $ref: "#/$defs/placeholder"
        highlights:
          type: object
          widget: FormGroup
          properties:
            informative:
              type: [string, array]
              widget: MultiType
              widgets:
                string: Jsonata
                array: SimpleList
              items:
                type: string
            positive:
              type: [string, array]
              widget: MultiType
              widgets:
                string: Jsonata
                array: SimpleList
              items:
                type: string
            warning:
              type: [string, array]
              widget: MultiType
              widgets:
                string: Jsonata
                array: SimpleList
              items:
                type: string
            critical:
              type: [string, array]
              widget: MultiType
              widgets:
                string: Jsonata
                array: SimpleList
              items:
                type: string
        description:
          type: string
        copyable:
          $ref: "#/$defs/copyable"
  CodeViewer:
    if:
      properties:
        widget:
          const: CodeViewer
    then:
      required:
        - source
      properties:
        language:
          type: string
          widget: Jsonata
  Columns:
    if:
      properties:
        widget:
          const: Columns
    then:
      properties:
        children:
          $ref: "#/$defs/children"
        inline:
          type: boolean
  ControlledBy:
    if:
      properties:
        widget:
          const: ControlledBy
    then:
      required:
        - source
      properties:
        placeholder:
          $ref: "#/$defs/placeholder"
        kindOnly:
          type: boolean
  EventList:
    if:
      properties:
        widget:
          const: EventList
    then:
      properties:
        filter:
          type: string
          widget: Jsonata
        defaultType:
          type: string
          enum: [all, information, warning]
        hideInvolvedObjects:
          type: boolean
  ExternalLink:
    if:
      properties:
        widget:
          const: ExternalLink
    then:
      required:
        - source
      properties:
        link:
          type: string
          widget: Jsonata
        copyable:
          $ref: "#/$defs/copyable"
  JoinedArray:
    if:
      properties:
        widget:
          const: JoinedArray
    then:
      required:
        - source
      properties:
        separator:
          type: string
        children:
          $ref: "#/$defs/children"
        copyable:
          $ref: "#/$defs/copyable"
  Labels:
    if:
      properties:
        widget:
          const: Labels
    then:
      properties:
        placeholder:
          $ref: "#/$defs/placeholder"
        copyable:
          $ref: "#/$defs/copyable"
  Panel:
    if:
      properties:
        widget:
          const: Panel
    then:
      properties:
        header:
          type: string
        disablePadding:
          type: boolean
        description:
          type: string
        children:
          $ref: "#/$defs/children"
  Plain:
    if:
      properties:
        widget:
          const: Plain
    then:
      properties:
        children:
          $ref: "#/$defs/children"
  ResourceLink:
    if:
      properties:
        widget:
          const: ResourceLink
    then:
      required:
        - source
      properties:
        resource:
          type: object
          properties:
            name:
              type: string
              widget: Jsonata
            namespace:
              type: string
              widget: Jsonata
            kind:
              type: string
              widget: Jsonata
  ResourceList:
    if:
      properties:
        widget:
          const: ResourceList
    then:
      required:
        - source
      properties:
        sort:
          type: array
          items:
            type: object
            required:
              - source
            properties:
              source:
                type: string
                widget: Jsonata
              default:
                type: boolean
              compareFunction:
                type: string
                widget: Jsonata
        search:
          type: array
          items:
            type: object
            required:
              - source
            properties:
              source:
                type: string
                widget: Jsonata
              default:
                type: boolean
              compareFunction:
                type: string
                widget: Jsonata
        children:
          $ref: "#/$defs/children"
  ResourceRefs:
    if:
      properties:
        widget:
          const: ResourceRefs
    then:
      required:
        - source
        - kind
      properties:
        kind:
          type: string
  Table:
    if:
      properties:
        widget:
          const: Table
    then:
      required:
        - source
      properties:
        disablePadding:
          type: boolean
        showHeader:
          type: boolean
        sort:
          type: [boolean, object]
          widget: MultiType
          properties:
            default:
              type: boolean
            compareFunction:
              type: string
              widget: Jsonata
        search:
          type: [boolean, object]
          widget: MultiType
          properties:
            searchFunction:
              type: string
              widget: Jsonata
        children:
          $ref: "#/$defs/children"
        collapsibleTitle:
          type: string
        collapsible:
          $ref: "#/$defs/children"
  Tabs:
    if:
      properties:
        widget:
          const: Tabs
    then:
      properties:
        children:
          $ref: "#/$defs/children"
  Text:
    if:
      properties:
        widget:
          const: Text
    then:
      required:
        - source
      properties:
        placeholder:
          $ref: "#/$defs/placeholder"
        copyable:
          $ref: "#/$defs/copyable"

