Skip to content

Commit f2df717

Browse files
ranbenaarikfr
authored andcommitted
HelpTrigger (getredash#3431)
* Moved to HelpTrigger * Moved share dialog “Learn more” to HelpTrigger
1 parent d6827e3 commit f2df717

3 files changed

Lines changed: 39 additions & 19 deletions

File tree

client/app/components/ParameterMappingInput.jsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,12 @@ import { ParameterValueInput } from '@/components/ParameterValueInput';
1818
import { ParameterMappingType } from '@/services/widget';
1919
import { clientConfig } from '@/services/auth';
2020
import { Query, Parameter } from '@/services/query';
21+
import HelpTrigger from '@/services/HelpTrigger';
2122

2223
import './ParameterMappingInput.less';
2324

2425
const { Option } = Select;
2526

26-
const HELP_URL = [
27-
'https://redash.io/help/user-guide/querying/query-parameters?source=dialog#Value-Source-Options',
28-
'Guide: Value Source Options',
29-
];
30-
3127
export const MappingType = {
3228
DashboardAddNew: 'dashboard-add-new',
3329
DashboardMapToExisting: 'dashboard-map-to-existing',
@@ -339,18 +335,11 @@ class MappingEditor extends React.Component {
339335

340336
renderContent() {
341337
const { mapping, inputError } = this.state;
342-
const [helpUrl, tooltip] = HELP_URL;
343338

344339
return (
345340
<div className="parameter-mapping-editor">
346341
<header>
347-
Edit Source and Value
348-
{/* eslint-disable-next-line react/jsx-no-target-blank */}
349-
<a href={helpUrl} target="_blank" rel="noopener">
350-
<Tooltip title={tooltip}>
351-
<Icon type="question-circle" />
352-
</Tooltip>
353-
</a>
342+
Edit Source and Value <HelpTrigger type="VALUE_SOURCE_OPTIONS" />
354343
</header>
355344
<ParameterMappingInput
356345
mapping={mapping}

client/app/pages/dashboards/ShareDashboardDialog.jsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import PropTypes from 'prop-types';
44
import Switch from 'antd/lib/switch';
55
import Modal from 'antd/lib/modal';
66
import Form from 'antd/lib/form';
7-
import Tooltip from 'antd/lib/tooltip';
87
import { $http, toastr } from '@/services/ng';
98
import { wrap as wrapDialog, DialogPropType } from '@/components/DialogWrapper';
109
import InputWithCopy from '@/components/InputWithCopy';
10+
import HelpTrigger from '@/services/HelpTrigger';
1111

1212
const API_SHARE_URL = 'api/dashboards/{id}/share';
13-
const HELP_URL = 'https://redash.io/help/user-guide/dashboards/sharing-dashboards?source=dialog';
1413

1514
class ShareDashboardDialog extends React.Component {
1615
static propTypes = {
@@ -38,10 +37,7 @@ class ShareDashboardDialog extends React.Component {
3837
Share Dashboard
3938
<div className="modal-header-desc">
4039
Allow public access to this dashboard with a secret address.{' '}
41-
<Tooltip title="Guide: Sharing and Embedding Dashboards">
42-
{ /* eslint-disable-next-line react/jsx-no-target-blank */}
43-
<a href={HELP_URL} target="_blank" rel="noopener">Learn more</a>
44-
</Tooltip>
40+
<HelpTrigger type="SHARE_DASHBOARD" />
4541
</div>
4642
</React.Fragment>
4743
);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import Tooltip from 'antd/lib/tooltip';
4+
import Icon from 'antd/lib/icon';
5+
6+
const BASE_URL = 'https://redash.io/help/user-guide/';
7+
const TYPES = {
8+
VALUE_SOURCE_OPTIONS: [
9+
'querying/query-parameters#Value-Source-Options',
10+
'Value Source Options',
11+
],
12+
SHARE_DASHBOARD: [
13+
'dashboards/sharing-dashboards',
14+
'Sharing and Embedding Dashboards',
15+
],
16+
};
17+
18+
export default class HelpTrigger extends React.PureComponent {
19+
static propTypes = {
20+
type: PropTypes.oneOf(Object.keys(TYPES)).isRequired,
21+
}
22+
23+
render() {
24+
const [path, tooltip] = TYPES[this.props.type];
25+
const href = BASE_URL + path;
26+
return (
27+
<Tooltip title={`Guide: ${tooltip}`}>
28+
{/* eslint-disable-next-line react/jsx-no-target-blank */}
29+
<a href={href} target="_blank" rel="noopener">
30+
<Icon type="question-circle" />
31+
</a>
32+
</Tooltip>
33+
);
34+
}
35+
}

0 commit comments

Comments
 (0)