-
Notifications
You must be signed in to change notification settings - Fork 10.7k
/
actions.js
161 lines (152 loc) · 3.55 KB
/
actions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import TYPES from './action-types';
/**
* Initialize the state
*
* @param {Object} queue initial queue
*/
export function setCesSurveyQueue( queue ) {
return {
type: TYPES.SET_CES_SURVEY_QUEUE,
queue,
};
}
/**
* Add a new CES track to the state.
*
* @param {Object} args All arguments.
* @param {string} args.action action name for the survey
* @param {string} args.title title for the snackback
* @param {string} args.description description for feedback modal.
* @param {string} args.noticeLabel noticeLabel for notice.
* @param {string} args.firstQuestion first question for modal survey
* @param {string} args.secondQuestion second question for modal survey
* @param {string} args.icon optional icon for notice.
* @param {string} args.pageNow value of window.pagenow
* @param {string} args.adminPage value of window.adminpage
* @param {string} args.onsubmitLabel label for the snackback onsubmit
* @param {Object} args.props object for optional props
*/
export function addCesSurvey( {
action,
title,
description,
noticeLabel,
firstQuestion,
secondQuestion,
icon,
pageNow = window.pagenow,
adminPage = window.adminpage,
onsubmitLabel = undefined,
props = {},
} ) {
return {
type: TYPES.ADD_CES_SURVEY,
action,
title,
description,
noticeLabel,
firstQuestion,
secondQuestion,
icon,
pageNow,
adminPage,
onsubmit_label: onsubmitLabel,
props,
};
}
/**
* Add show CES modal.
*
* @param {Object} surveyProps props for CES survey, similar to addCesSurvey.
* @param {Object} props object for optional props
* @param {Object} onSubmitNoticeProps object for on submit notice props.
*/
export function showCesModal(
surveyProps = {},
props = {},
onSubmitNoticeProps = {}
) {
return {
type: TYPES.SHOW_CES_MODAL,
surveyProps,
onsubmit_label: surveyProps.onsubmitLabel || '',
props,
onSubmitNoticeProps,
};
}
/**
* Hide CES Modal.
*/
export function hideCesModal() {
return {
type: TYPES.HIDE_CES_MODAL,
};
}
/**
* Add a new CES survey track for the pages in Analytics menu
*/
export function addCesSurveyForAnalytics() {
return addCesSurvey( {
action: 'analytics_filtered',
title: __(
'How easy was it to filter your store analytics?',
'woocommerce'
),
firstQuestion: __(
'The filters in the analytics screen are easy to use.',
'woocommerce'
),
secondQuestion: __(
`The filters' functionality meets my needs.`,
'woocommerce'
),
pageNow: 'woocommerce_page_wc-admin',
adminPage: 'woocommerce_page_wc-admin',
} );
}
/**
* Add a new CES survey track on searching customers.
*/
export function addCesSurveyForCustomerSearch() {
return addCesSurvey( {
action: 'ces_search',
title: __( 'How easy was it to use search?', 'woocommerce' ),
firstQuestion: __(
'The search feature in WooCommerce is easy to use.',
'woocommerce'
),
secondQuestion: __(
`The search's functionality meets my needs.`,
'woocommerce'
),
pageNow: 'woocommerce_page_wc-admin',
adminPage: 'woocommerce_page_wc-admin',
onsubmit_label: undefined,
props: {
search_area: 'customer',
},
} );
}
/**
* Add show product MVP Feedback modal.
*/
export function showProductMVPFeedbackModal() {
return {
type: TYPES.SHOW_PRODUCT_MVP_FEEDBACK_MODAL,
};
}
/**
* Hide product MVP Feedback modal.
*/
export function hideProductMVPFeedbackModal() {
return {
type: TYPES.HIDE_PRODUCT_MVP_FEEDBACK_MODAL,
};
}