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

Commit

Permalink
Add markdown support and preserve line breaks in config item title
Browse files Browse the repository at this point in the history
  • Loading branch information
sgalsaleh committed Feb 13, 2020
1 parent 5d4ba5e commit fa1ec4b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
2 changes: 1 addition & 1 deletion web/init/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@replicatedhq/ship-init",
"version": "1.6.14",
"version": "1.6.15",
"description": "Shared component that contains the Ship Init app",
"author": "Replicated, Inc.",
"license": "Apache-2.0",
Expand Down
6 changes: 4 additions & 2 deletions web/init/src/components/config_only/ConfigOnly.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@ export default class ConfigOnly extends React.Component {
// TODO: Refactor to pass errors down instead of manipulating
// the DOM
const el = document.getElementById(`${err.fieldName}-errblock`);
el.innerHTML = err.message;
el.classList.add("visible");
if (el) {
el.innerHTML = err.message;
el.classList.add("visible");
}
})
}

Expand Down
35 changes: 27 additions & 8 deletions web/init/src/components/config_render/ConfigItemTitle.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
import Markdown from "react-remarkable";

export default class ConfigItemTitle extends React.Component {

Expand All @@ -11,16 +12,34 @@ export default class ConfigItemTitle extends React.Component {
when
} = this.props;

var isHidden = hidden || when === "false";
var isHidden = hidden || when === "false" || (!title && !required && !recommended);

if (isHidden) {
return null;
}

return (
<h4 className={`sub-header-color field-section-sub-header ${isHidden ? "hidden" : ""}`}>{title} {
required ?
<span className="field-label required">Required</span> :
recommended ?
<span className="field-label recommended">Recommended</span> :
null}
<span className="u-marginLeft--10 config-errblock" id={`${this.props.name}-errblock`}></span>
<h4 className="sub-header-color field-section-sub-header" style={title ? { marginBottom: -18 } : {}}>
{title &&
<div className="u-display--inlineBlock u-verticalAlign--top u-marginRight--small">
<Markdown
options={{
linkTarget: "_blank",
linkify: true,
}}
>
{title}
</Markdown>
</div>
}
<div className="u-display--inlineBlock u-verticalAlign--top">
{required ?
<span className="field-label required">Required</span> :
recommended ?
<span className="field-label recommended">Recommended</span> :
null}
<span className="u-marginLeft--small config-errblock" id={`${this.props.name}-errblock`}></span>
</div>
</h4>
);
}
Expand Down
1 change: 1 addition & 0 deletions web/init/src/scss/utilities/ship-init-base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ a {
font-size: 14px;
line-height: 18px;
font-weight: 500;
white-space: pre-line;
}
.field.hidden {
display: none;
Expand Down
1 change: 1 addition & 0 deletions web/init/src/scss/utilities/utilities.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
.u-display--block { display: block; }
.u-display--inlineBlock { display: inline-block; }
.u-visibility--hidden { visibility: hidden; }
.u-verticalAlign--top { vertical-align: top; }

/* Border classes */

Expand Down

0 comments on commit fa1ec4b

Please sign in to comment.