Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HelpTrigger in header #3457

Merged
merged 6 commits into from
Feb 18, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions client/app/assets/less/redash/redash-newstyle.less
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ body {
}
}

.navbar-link-ANGULAR_REMOVE_ME,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very interesting use of ANGULAR_REMOVE_ME 🙂

.navbar-default .navbar-nav > li > a {
color: #000;
font-weight: 500;
Expand All @@ -688,6 +689,12 @@ body {
//border-radius: 0;
}

.navbar-link-ANGULAR_REMOVE_ME {
line-height: 18px;
padding: 16px 15px;
display: block;
}

.navbar-default .navbar-nav > .open > a, .navbar-default .navbar-nav > .open > a:hover, .navbar-default .navbar-nav > .open > a:focus {
background-color: fade(@redash-gray, 15%);
color: #111;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
import { react2angular } from 'react2angular';
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import Tooltip from 'antd/lib/tooltip';
import Icon from 'antd/lib/icon';
import Drawer from 'antd/lib/drawer';
import { BigMessage } from '@/components/BigMessage';

import './HelpTrigger.less';

const DOMAIN = 'https://redash.io';
const HELP_PATH = '/help/user-guide/';
const HELP_PATH = '/help';
const IFRAME_TIMEOUT = 5000;
const TYPES = {
HOME: [
'',
'Help',
],
VALUE_SOURCE_OPTIONS: [
'querying/query-parameters#Value-Source-Options',
'Value Source Options',
'/user-guide/querying/query-parameters#Value-Source-Options',
'Guide: Value Source Options',
],
SHARE_DASHBOARD: [
'dashboards/sharing-dashboards',
'Sharing and Embedding Dashboards',
'/user-guide/dashboards/sharing-dashboards',
'Guide: Sharing and Embedding Dashboards',
],
};

export default class HelpTrigger extends React.PureComponent {
export class HelpTrigger extends React.Component {
static propTypes = {
type: PropTypes.oneOf(Object.keys(TYPES)).isRequired,
className: PropTypes.string,
}

static defaultProps = {
className: null,
};

iframeRef = null

iframeLoadingTimeout = null
Expand Down Expand Up @@ -71,12 +80,13 @@ export default class HelpTrigger extends React.PureComponent {

render() {
const [, tooltip] = TYPES[this.props.type];
const className = cx('help-trigger', this.props.className);

return (
<React.Fragment>
<Tooltip title={`Guide: ${tooltip}`}>
<a href="javascript: void(0)" onClick={this.openDrawer}>
<Icon type="question-circle" />
<Tooltip title={tooltip}>
<a href="javascript: void(0)" onClick={this.openDrawer} className={className}>
<i className="fa fa-question-circle" />
</a>
</Tooltip>
<Drawer
Expand Down Expand Up @@ -117,3 +127,9 @@ export default class HelpTrigger extends React.PureComponent {
);
}
}

export default function init(ngModule) {
ngModule.component('helpTrigger', react2angular(HelpTrigger));
}

init.init = true;
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.help-trigger {
font-size: 15px;
}

.help-drawer {
.ant-drawer-body {
padding: 0;
Expand Down
2 changes: 1 addition & 1 deletion client/app/components/ParameterMappingInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { ParameterValueInput } from '@/components/ParameterValueInput';
import { ParameterMappingType } from '@/services/widget';
import { clientConfig } from '@/services/auth';
import { Query, Parameter } from '@/services/query';
import HelpTrigger from '@/services/HelpTrigger';
import { HelpTrigger } from '@/components/HelpTrigger';

import './ParameterMappingInput.less';

Expand Down
3 changes: 3 additions & 0 deletions client/app/components/app-header/app-header.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@

<!-- Profile -->
<ul class="nav navbar-nav navbar-right">
<li>
<help-trigger type="'HOME'" class-name="'navbar-link-ANGULAR_REMOVE_ME'"></help-trigger>
</li>
<li ng-show="$ctrl.currentUser.isAdmin">
<a href="data_sources" title="Settings"><i class="fa fa-sliders" aria-hidden="true"></i></a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion client/app/pages/dashboards/ShareDashboardDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Alert from 'antd/lib/alert';
import { $http, toastr } from '@/services/ng';
import { wrap as wrapDialog, DialogPropType } from '@/components/DialogWrapper';
import InputWithCopy from '@/components/InputWithCopy';
import HelpTrigger from '@/services/HelpTrigger';
import { HelpTrigger } from '@/components/HelpTrigger';

const API_SHARE_URL = 'api/dashboards/{id}/share';

Expand Down