Skip to content

Commit

Permalink
fix: added help text link support
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvanshus-crest committed May 11, 2021
1 parent 69eb050 commit 6c94df9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ui/src/main/webapp/components/BaseFormView.jsx
Expand Up @@ -888,6 +888,7 @@ class BaseFormView extends PureComponent {
serviceName={this.props.serviceName}
mode={this.props.mode}
disabled={temState.disabled}
markDownMessage={temState.markDownMessage}
dependencyValues={temState.dependencyValues || null}
/>
);
Expand Down Expand Up @@ -957,6 +958,7 @@ class BaseFormView extends PureComponent {
serviceName={this.props.serviceName}
mode={this.props.mode}
disabled={temState.disabled}
markDownMessage={temState.markDownMessage}
dependencyValues={temState.dependencyValues || null}
/>
);
Expand Down
17 changes: 16 additions & 1 deletion ui/src/main/webapp/components/ControlWrapper.jsx
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import ControlGroup from '@splunk/react-ui/ControlGroup';
import styled from 'styled-components';

import MarkDownMessage from './MarkDownMessage';
import CONTROL_TYPE_MAP from '../constants/ControlTypeMap';

const CustomElement = styled.div`
Expand All @@ -21,6 +22,7 @@ const ControlGroupWrapper = styled(ControlGroup).attrs((props) => ({
}
&:nth-child(3) {
margin-left: 270px !important;
width: 320px;
}
}
`;
Expand All @@ -40,6 +42,7 @@ class ControlWrapper extends React.PureComponent {
render() {
const { field, options, type, label, tooltip, help, encrypted = false } = this.props.entity;
const { handleChange, addCustomValidator, utilCustomFunctions } = this.props.utilityFuncts;
const { text, link, color } = this.props.markDownMessage || {};
let rowView;
if (this.props.entity.type === 'custom') {
const data = {
Expand Down Expand Up @@ -73,11 +76,22 @@ class ControlWrapper extends React.PureComponent {
: `No View Found for ${type} type`;
}

let helpText = (
<>
<MarkDownMessage
text={ text || '' }
link={ link || '' }
color={ color || ''}
/>
{help}
</>
)

return (
this.props.display && (
<ControlGroupWrapper
label={label}
help={help}
help={helpText}
tooltip={tooltip}
error={this.props.error}
dataName={field}
Expand All @@ -97,6 +111,7 @@ ControlWrapper.propTypes = {
error: PropTypes.bool,
entity: PropTypes.object,
disabled: PropTypes.bool,
markDownMessage: PropTypes.object,
serviceName: PropTypes.string,
dependencyValues: PropTypes.object,
};
Expand Down
32 changes: 32 additions & 0 deletions ui/src/main/webapp/components/MarkDownMessage.jsx
@@ -0,0 +1,32 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import Link from '@splunk/react-ui/Link';


const MarkdownWrapper = styled.div`
color: ${props => props.color};
`;

function MarkDownMessage(props) {
return (
<>
{props.link !== '' ?
<Link to={props.link} >
{props.text}
</Link>
:
<MarkdownWrapper color={props.color}>{props.text}</MarkdownWrapper>
}
</>
);
}


MarkDownMessage.propTypes = {
text: PropTypes.string,
link: PropTypes.string,
color: PropTypes.string
};

export default MarkDownMessage;

0 comments on commit 6c94df9

Please sign in to comment.