Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Reconciles unmarshal and base code differences #2669

Merged
merged 3 commits into from
Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelogs/unreleased/2669-liamrathke
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes issues preventing complex custom resource viewer graphs from being displayed in TypeScript-based plugins
16 changes: 8 additions & 8 deletions pkg/view/component/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const (
TypeAccordion = "accordion"
// TypeAnnotations is an annotations component.
TypeAnnotations = "annotations"
// TypeButton is a Button component.
TypeButton = "button"
// TypeButtonGroup is a button group component.
TypeButtonGroup = "buttonGroup"
// TypeCard is a card component.
Expand Down Expand Up @@ -42,6 +44,8 @@ const (
TypeGraphviz = "graphviz"
// TypeGridActions is a grid actions component.
TypeGridActions = "gridActions"
// TypeIcon is a Icon component.
TypeIcon = "icon"
// TypeIFrame is an iframe component.
TypeIFrame = "iframe"
// TypeJSONEditor is a JSON Editor component.
Expand Down Expand Up @@ -74,6 +78,8 @@ const (
TypeSelectFile = "selectFile"
// TypeSelectors is a selectors component.
TypeSelectors = "selectors"
// TypeSignpost is a SignPost component.
TypeSignpost = "signpost"
// TypeSingleStat is a single stat component.
TypeSingleStat = "singleStat"
// TypeStepper is a stepper component.
Expand All @@ -82,6 +88,8 @@ const (
TypeSummary = "summary"
// TypeTable is a table component.
TypeTable = "table"
// TypeTabsView is a Tab component.
TypeTabsView = "tabsView"
// TypeTerminal is a terminal component.
TypeTerminal = "terminal"
// TypeText is a text component.
Expand All @@ -92,14 +100,6 @@ const (
TypeTimestamp = "timestamp"
// TypeYAML is a YAML component.
TypeYAML = "yaml"
// TypeIcon is a Icon component.
TypeIcon = "icon"
// TypeSignpost is a SignPost component.
TypeSignpost = "signpost"
// TypeButton is a Button component.
TypeButton = "button"
// TypeTabsView is a Tab component.
TypeTabsView = "tabsView"
)

// Base is an abstract base for components..
Expand Down
76 changes: 53 additions & 23 deletions pkg/view/component/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,21 @@ func unmarshal(to TypedObject) (Component, error) {
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal error config")
o = t
case TypeExpressionSelector:
t := &ExpressionSelector{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal expressionSelector config")
o = t
case TypeExpandableRowDetail:
t := &ExpandableRowDetail{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal expandable row detail config")
o = t
case TypeExtension:
t := &Extension{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal expandable row detail config")
liamrathke marked this conversation as resolved.
Show resolved Hide resolved
o = t
case TypeExpressionSelector:
t := &ExpressionSelector{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal expressionSelector config")
o = t
case TypeFlexLayout:
t := &FlexLayout{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
Expand All @@ -106,6 +111,11 @@ func unmarshal(to TypedObject) (Component, error) {
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal gridActions config")
o = t
case TypeIcon:
t := &Icon{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal icon config")
o = t
case TypeIFrame:
t := &IFrame{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
Expand All @@ -126,11 +136,6 @@ func unmarshal(to TypedObject) (Component, error) {
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal labelSelector config")
o = t
case TypeLoading:
t := &Loading{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal loading config")
o = t
case TypeLink:
t := &Link{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
Expand All @@ -146,11 +151,31 @@ func unmarshal(to TypedObject) (Component, error) {
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal logs config")
o = t
case TypeLoading:
t := &Loading{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal loading config")
o = t
case TypeModal:
t := &Modal{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal modal config")
o = t
case TypePodStatus:
t := &PodStatus{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal pod status config")
o = t
case TypePort:
t := &Port{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal loading config")
liamrathke marked this conversation as resolved.
Show resolved Hide resolved
o = t
case TypePorts:
t := &Ports{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal loading config")
liamrathke marked this conversation as resolved.
Show resolved Hide resolved
o = t
case TypeQuadrant:
t := &Quadrant{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
Expand All @@ -171,6 +196,11 @@ func unmarshal(to TypedObject) (Component, error) {
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal selectors config")
o = t
case TypeSignpost:
t := &Signpost{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal signpost config")
o = t
case TypeSingleStat:
t := &SingleStat{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
Expand All @@ -191,6 +221,16 @@ func unmarshal(to TypedObject) (Component, error) {
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal table config")
o = t
case TypeTabsView:
t := &TabsView{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal tabs config")
o = t
case TypeTerminal:
t := &Terminal{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal tabs config")
liamrathke marked this conversation as resolved.
Show resolved Hide resolved
o = t
case TypeText:
t := &Text{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
Expand All @@ -206,20 +246,10 @@ func unmarshal(to TypedObject) (Component, error) {
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal timestamp config")
o = t
case TypeIcon:
t := &Icon{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal icon config")
o = t
case TypeSignpost:
t := &Signpost{Base: Base{Metadata: to.Metadata}}
case TypeYAML:
t := &YAML{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal signpost config")
o = t
case TypeTabsView:
t := &TabsView{Base: Base{Metadata: to.Metadata}}
err = errors.Wrapf(json.Unmarshal(to.Config, &t.Config),
"unmarshal tabs config")
"unmarshal timestamp config")
liamrathke marked this conversation as resolved.
Show resolved Hide resolved
o = t
default:
return nil, errors.Errorf("unknown view component %q", to.Metadata.Type)
Expand Down