Skip to content

Commit bf80777

Browse files
authored
feat(y.metrika): send counters id clicked by user (#376)
1 parent 05cfef8 commit bf80777

File tree

20 files changed

+499
-43
lines changed

20 files changed

+499
-43
lines changed

lib/static/components/details.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@ export default class Details extends Component {
99
static propTypes = {
1010
title: PropTypes.oneOfType([PropTypes.element, PropTypes.string]).isRequired,
1111
content: PropTypes.oneOfType([PropTypes.func, PropTypes.string, PropTypes.element, PropTypes.array]).isRequired,
12-
extendClassNames: PropTypes.oneOfType([PropTypes.array, PropTypes.string])
12+
extendClassNames: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),
13+
onClick: PropTypes.func
1314
};
1415

1516
state = {isOpened: false};
1617

1718
handleClick = () => {
1819
this.setState({isOpened: !this.state.isOpened});
20+
21+
if (this.props.onClick) {
22+
this.props.onClick();
23+
}
1924
}
2025

2126
render() {

lib/static/components/section/body/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Body extends Component {
4646

4747
onRetrySwitcherChange = (index) => {
4848
this.setState({retry: index});
49-
this._changeTestRetry({retryIndex: index});
49+
this._changeTestRetry({retryIndex: index, isUserClick: true});
5050
}
5151

5252
onTestRetry = () => {
@@ -55,14 +55,14 @@ class Body extends Component {
5555
this.props.actions.retryTest({testName, browserName});
5656
}
5757

58-
_changeTestRetry({retryIndex}) {
58+
_changeTestRetry({retryIndex, isUserClick = false}) {
5959
const {browserId, browserRetryIndex} = this.props;
6060

6161
if (retryIndex === browserRetryIndex) {
6262
return;
6363
}
6464

65-
this.props.actions.changeTestRetry({browserId, retryIndex});
65+
this.props.actions.changeTestRetry({browserId, retryIndex, isUserClick});
6666
}
6767

6868
_addRetrySwitcher = () => {

lib/static/components/section/body/meta-info.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import path from 'path';
22
import url from 'url';
33
import React, {Component} from 'react';
44
import {connect} from 'react-redux';
5+
import {bindActionCreators} from 'redux';
56
import PropTypes from 'prop-types';
67
import {map, mapValues, isObject, omitBy, isEmpty} from 'lodash';
8+
import * as actions from '../../../modules/actions';
79
import Details from '../../details';
810
import {isUrl} from '../../../modules/utils';
911

@@ -68,15 +70,21 @@ class MetaInfo extends Component {
6870
return metaToElements(formattedMetaInfo, metaInfoBaseUrls);
6971
}
7072

73+
onToggleMetaInfo = () => {
74+
this.props.actions.toggleMetaInfo();
75+
}
76+
7177
render() {
7278
return <Details
7379
title='Meta'
7480
content={this._renderMetaInfo}
7581
extendClassNames='details_type_text'
82+
onClick={this.onToggleMetaInfo}
7683
/>;
7784
}
7885
}
7986

8087
export default connect(
81-
({config: {metaInfoBaseUrls}, apiValues}) => ({metaInfoBaseUrls, apiValues})
88+
({config: {metaInfoBaseUrls}, apiValues}) => ({metaInfoBaseUrls, apiValues}),
89+
(dispatch) => ({actions: bindActionCreators(actions, dispatch)})
8290
)(MetaInfo);

lib/static/components/section/section-browser.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import React, {Component, Fragment} from 'react';
22
import {last} from 'lodash';
33
import {connect} from 'react-redux';
4+
import {bindActionCreators} from 'redux';
45
import Parser from 'html-react-parser';
56
import PropTypes from 'prop-types';
7+
import * as actions from '../../modules/actions';
68
import SectionWrapper from './section-wrapper';
79
import BrowserTitle from './title/browser';
810
import BrowserSkippedTitle from './title/browser-skipped';
@@ -48,6 +50,8 @@ class SectionBrowser extends Component {
4850

4951
_onToggleSection = () => {
5052
this.setState({opened: !this.state.opened});
53+
54+
this.props.actions.toggleBrowserSection(this.props.browserId);
5155
}
5256

5357
_getStates(props = this.props) {
@@ -144,4 +148,5 @@ export default connect(
144148
};
145149
};
146150
},
151+
(dispatch) => ({actions: bindActionCreators(actions, dispatch)})
147152
)(SectionWrapper(SectionBrowser));

lib/static/components/section/section-common.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import React, {Component} from 'react';
22
import {connect} from 'react-redux';
3+
import {bindActionCreators} from 'redux';
34
import PropTypes from 'prop-types';
45
import LazilyRender from '@gemini-testing/react-lazily-render';
6+
import * as actions from '../../modules/actions';
57
import SectionWrapper from './section-wrapper';
68
import SectionBrowser from './section-browser';
79
import {isFailStatus, isErroredStatus} from '../../../common-utils';
@@ -56,11 +58,13 @@ class SectionCommon extends Component {
5658

5759
_onToggleSection = () => {
5860
this.setState({opened: !this.state.opened});
59-
const {eventToUpdate} = this.props;
61+
const {eventToUpdate, suiteId} = this.props;
6062

6163
if (eventToUpdate) {
6264
window.dispatchEvent(new Event(eventToUpdate));
6365
}
66+
67+
this.props.actions.toggleSuiteSection(suiteId);
6468
}
6569

6670
_drawSection() {
@@ -155,6 +159,7 @@ const SectionCommonWrapper = connect(
155159
};
156160
};
157161
},
162+
(dispatch) => ({actions: bindActionCreators(actions, dispatch)})
158163
)(SectionWrapper(SectionCommon));
159164

160165
export default SectionCommonWrapper;

lib/static/components/section/title/browser.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import React, {Component} from 'react';
33
import ClipboardButton from 'react-clipboard.js';
44
import PropTypes from 'prop-types';
55
import {connect} from 'react-redux';
6+
import {bindActionCreators} from 'redux';
67
import {get} from 'lodash';
8+
import * as actions from '../../../modules/actions';
79
import {appendQuery} from '../../../modules/query-params';
810
import viewModes from '../../../../constants/view-modes';
911

@@ -40,6 +42,18 @@ class BrowserTitle extends Component {
4042
});
4143
}
4244

45+
onViewInBrowser = (e) => {
46+
e.stopPropagation();
47+
48+
this.props.actions.viewInBrowser();
49+
}
50+
51+
onCopyTestLink = (e) => {
52+
e.stopPropagation();
53+
54+
this.props.actions.copyTestLink();
55+
}
56+
4357
render() {
4458
const {title, suiteUrl, handler, parsedHost} = this.props;
4559

@@ -49,13 +63,13 @@ class BrowserTitle extends Component {
4963
<a
5064
className="button section__icon section__icon_view-local"
5165
href={this._buildUrl(suiteUrl, parsedHost)}
52-
onClick={(e) => e.stopPropagation()}
66+
onClick={this.onViewInBrowser}
5367
title="view in browser"
5468
target="_blank">
5569
</a>
5670
<ClipboardButton
5771
className="button section__icon section__icon_share"
58-
onClick={(e) => e.stopPropagation()}
72+
onClick={this.onCopyTestLink}
5973
button-title="copy test link"
6074
option-text={() => this._getTestUrl()}>
6175
</ClipboardButton>
@@ -76,5 +90,6 @@ export default connect(
7690
suiteUrl: lastResult.suiteUrl,
7791
parsedHost: view.parsedHost
7892
};
79-
}
93+
},
94+
(dispatch) => ({actions: bindActionCreators(actions, dispatch)})
8095
)(BrowserTitle);

lib/static/components/section/title/simple.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ class SectionTitle extends Component {
2121
})).isRequired
2222
}
2323

24+
onCopySuiteName = (e) => {
25+
e.stopPropagation();
26+
27+
this.props.actions.copySuiteName(this.props.suiteId);
28+
}
29+
2430
onSuiteRetry = (e) => {
2531
e.stopPropagation();
2632

@@ -42,7 +48,7 @@ class SectionTitle extends Component {
4248
_drawCopyButton() {
4349
return (
4450
<ClipboardButton
45-
onClick={(e) => e.stopPropagation()}
51+
onClick={this.onCopySuiteName}
4652
className="button section__icon section__icon_copy-to-clipboard"
4753
button-title="copy to clipboard"
4854
data-clipboard-text={this.props.suiteId}>

lib/static/components/state/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ class State extends Component {
9292
});
9393
}
9494

95-
onToggleStateResult = ({opened}) => {
95+
onToggleStateResult = ({opened, isUserClick = false}) => {
9696
const {imageId, image, imageOpened} = this.props;
9797

9898
if (!image.stateName || imageOpened === opened) {
9999
return;
100100
}
101101

102-
this.props.actions.toggleStateResult({imageId, opened});
102+
this.props.actions.toggleStateResult({imageId, opened, isUserClick});
103103
}
104104

105105
onTestAccept = () => {
@@ -158,7 +158,7 @@ class State extends Component {
158158

159159
_toggleState = () => {
160160
this.setState({opened: !this.state.opened});
161-
this.onToggleStateResult({opened: !this.state.opened});
161+
this.onToggleStateResult({opened: !this.state.opened, isUserClick: true});
162162
}
163163

164164
_getStateTitle() {

lib/static/components/state/state-error.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
import React, {Component, Fragment} from 'react';
44
import {connect} from 'react-redux';
5+
import {bindActionCreators} from 'redux';
56
import PropTypes from 'prop-types';
67
import {isEmpty, map, isFunction} from 'lodash';
78
import ReactHtmlParser from 'react-html-parser';
9+
import * as actions from '../../modules/actions';
810
import Screenshot from './screenshot';
911
import {isNoRefImageError} from '../../modules/utils';
1012
import ErrorDetails from './error-details';
@@ -43,7 +45,16 @@ class StateError extends Component {
4345

4446
return isNoRefImageError(error)
4547
? <Screenshot image={image.actualImg} />
46-
: <Details title="Page screenshot" content={() => <Screenshot image={image.actualImg} noLazyLoad={true} />} extendClassNames="details_type_image" />;
48+
: <Details
49+
title="Page screenshot"
50+
content={() => <Screenshot image={image.actualImg} noLazyLoad={true} />}
51+
extendClassNames="details_type_image"
52+
onClick={this.onTogglePageScreenshot}
53+
/>;
54+
}
55+
56+
onTogglePageScreenshot = () => {
57+
this.props.actions.togglePageScreenshot();
4758
}
4859

4960
_errorToElements(error) {
@@ -107,7 +118,8 @@ export default connect(
107118
const errorDetails = image.stateName ? null : result.errorDetails;
108119

109120
return {error, errorDetails, errorPatterns};
110-
}
121+
},
122+
(dispatch) => ({actions: bindActionCreators(actions, dispatch)})
111123
)(StateError);
112124

113125
function parseHtmlString(str = '') {

lib/static/modules/action-names.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,12 @@ export default {
3737
PROCESS_BEGIN: 'PROCESS_BEGIN',
3838
PROCESS_END: 'PROCESS_END',
3939
RUN_CUSTOM_GUI_ACTION: 'RUN_CUSTOM_GUI_ACTION',
40-
BROWSERS_SELECTED: 'BROWSERS_SELECTED'
40+
BROWSERS_SELECTED: 'BROWSERS_SELECTED',
41+
COPY_SUITE_NAME: 'COPY_SUITE_NAME',
42+
VIEW_IN_BROWSER: 'VIEW_IN_BROWSER',
43+
COPY_TEST_LINK: 'COPY_TEST_LINK',
44+
TOGGLE_SUITE_SECTION: 'TOGGLE_SUITE_SECTION',
45+
TOGGLE_BROWSER_SECTION: 'TOGGLE_BROWSER_SECTION',
46+
TOGGLE_META_INFO: 'TOGGLE_META_INFO',
47+
TOGGLE_PAGE_SCREENSHOT: 'TOGGLE_PAGE_SCREENSHOT'
4148
};

0 commit comments

Comments
 (0)