Bug 1212340 - Move the Leave feedback option from the conversation window settings menu to the panel settings menu. r=Standard8

This commit is contained in:
Manuel Casas 2015-10-15 11:42:22 +01:00
Родитель 8910f19666
Коммит e60145f89b
9 изменённых файлов: 70 добавлений и 53 удалений

Просмотреть файл

@ -225,6 +225,16 @@ loop.panel = (function(_, mozL10n) {
this.hideDropdownMenu();
},
/**
* Load on the browser the feedback url from prefs
*/
handleSubmitFeedback: function(event) {
event.preventDefault();
var helloFeedbackUrl = this.props.mozLoop.getLoopPref("feedback.formURL");
this.props.mozLoop.openURL(helloFeedbackUrl);
this.closeWindow();
},
_isSignedIn: function() {
return !!this.props.mozLoop.userProfile;
},
@ -262,6 +272,9 @@ loop.panel = (function(_, mozL10n) {
onClick: this.handleClickSettingsEntry}),
React.createElement(SettingsDropdownEntry, {label: mozL10n.get("tour_label"),
onClick: this.openGettingStartedTour}),
React.createElement(SettingsDropdownEntry, {extraCSSClass: "entry-settings-feedback",
label: mozL10n.get("settings_menu_item_feedback"),
onClick: this.handleSubmitFeedback}),
React.createElement(SettingsDropdownEntry, {displayed: this.props.mozLoop.fxAEnabled,
extraCSSClass: accountEntryCSSClass,
label: this._isSignedIn() ?

Просмотреть файл

@ -225,6 +225,16 @@ loop.panel = (function(_, mozL10n) {
this.hideDropdownMenu();
},
/**
* Load on the browser the feedback url from prefs
*/
handleSubmitFeedback: function(event) {
event.preventDefault();
var helloFeedbackUrl = this.props.mozLoop.getLoopPref("feedback.formURL");
this.props.mozLoop.openURL(helloFeedbackUrl);
this.closeWindow();
},
_isSignedIn: function() {
return !!this.props.mozLoop.userProfile;
},
@ -262,6 +272,9 @@ loop.panel = (function(_, mozL10n) {
onClick={this.handleClickSettingsEntry} />
<SettingsDropdownEntry label={mozL10n.get("tour_label")}
onClick={this.openGettingStartedTour} />
<SettingsDropdownEntry extraCSSClass="entry-settings-feedback"
label={mozL10n.get("settings_menu_item_feedback")}
onClick={this.handleSubmitFeedback} />
<SettingsDropdownEntry displayed={this.props.mozLoop.fxAEnabled}
extraCSSClass={accountEntryCSSClass}
label={this._isSignedIn() ?

Просмотреть файл

@ -135,7 +135,6 @@ loop.roomViews = (function(mozL10n) {
render: function() {
var settingsMenuItems = [
{ id: "feedback" },
{ id: "help" }
];
@ -794,7 +793,6 @@ loop.roomViews = (function(mozL10n) {
visible: true,
onClick: this.handleEditContextClick
},
{ id: "feedback" },
{ id: "help" }
];
return (

Просмотреть файл

@ -135,7 +135,6 @@ loop.roomViews = (function(mozL10n) {
render: function() {
var settingsMenuItems = [
{ id: "feedback" },
{ id: "help" }
];
@ -794,7 +793,6 @@ loop.roomViews = (function(mozL10n) {
visible: true,
onClick: this.handleEditContextClick
},
{ id: "feedback" },
{ id: "help" }
];
return (

Просмотреть файл

@ -300,27 +300,12 @@ loop.shared.views = (function(_, mozL10n) {
this.props.mozLoop.openURL(helloSupportUrl);
},
/**
* Load on the browser the feedback url from prefs
*/
handleSubmitFeedback: function(event) {
event.preventDefault();
var helloFeedbackUrl = this.props.mozLoop.getLoopPref("feedback.formURL");
this.props.mozLoop.openURL(helloFeedbackUrl);
},
/**
* Recover the needed info for generating an specific menu Item
*/
getItemInfo: function(menuItem) {
var cx = React.addons.classSet;
switch (menuItem.id) {
case "feedback":
return {
cssClasses: "dropdown-menu-item",
handler: this.handleSubmitFeedback,
label: mozL10n.get("feedback_request_button")
};
case "help":
return {
cssClasses: "dropdown-menu-item",

Просмотреть файл

@ -300,27 +300,12 @@ loop.shared.views = (function(_, mozL10n) {
this.props.mozLoop.openURL(helloSupportUrl);
},
/**
* Load on the browser the feedback url from prefs
*/
handleSubmitFeedback: function(event) {
event.preventDefault();
var helloFeedbackUrl = this.props.mozLoop.getLoopPref("feedback.formURL");
this.props.mozLoop.openURL(helloFeedbackUrl);
},
/**
* Recover the needed info for generating an specific menu Item
*/
getItemInfo: function(menuItem) {
var cx = React.addons.classSet;
switch (menuItem.id) {
case "feedback":
return {
cssClasses: "dropdown-menu-item",
handler: this.handleSubmitFeedback,
label: mozL10n.get("feedback_request_button")
};
case "help":
return {
cssClasses: "dropdown-menu-item",

Просмотреть файл

@ -434,6 +434,47 @@ describe("loop.panel", function() {
});
});
describe("Submit feedback", function() {
var view, feedbackUrl;
function mountTestComponent() {
return TestUtils.renderIntoDocument(
React.createElement(loop.panel.SettingsDropdown, {
mozLoop: fakeMozLoop
}));
}
beforeEach(function() {
feedbackUrl = "https://example.com";
fakeMozLoop.getLoopPref = function(pref) {
if (pref === "feedback.formURL") {
return feedbackUrl;
}
return "unseen";
};
});
it("should open a tab to the feedback page", function() {
view = mountTestComponent();
TestUtils.Simulate
.click(view.getDOMNode().querySelector(".entry-settings-feedback"));
sinon.assert.calledOnce(fakeMozLoop.openURL);
sinon.assert.calledWithExactly(fakeMozLoop.openURL, feedbackUrl);
});
it("should close the panel", function() {
view = mountTestComponent();
TestUtils.Simulate
.click(view.getDOMNode().querySelector(".entry-settings-feedback"));
sinon.assert.calledOnce(fakeWindow.close);
});
});
describe("#render", function() {
it("should not render a ToSView when gettingStarted.seen is true", function() {
navigator.mozLoop.getLoopPref = function() {

Просмотреть файл

@ -287,7 +287,6 @@ describe("loop.shared.views", function() {
describe("SettingsControlButton", function() {
var fakeMozLoop;
var support_url = "https://support.com";
var feedback_url = "https://feedback.com";
beforeEach(function() {
fakeMozLoop = {
@ -297,8 +296,6 @@ describe("loop.shared.views", function() {
switch (prefName) {
case "support_url":
return support_url;
case "feedback.formURL":
return feedback_url;
default:
return prefName;
}
@ -316,7 +313,7 @@ describe("loop.shared.views", function() {
}
it("should render a visible button", function() {
var settingsMenuItems = [{ id: "feedback" }];
var settingsMenuItems = [{ id: "help" }];
var comp = mountTestComponent({ menuItems: settingsMenuItems} );
var node = comp.getDOMNode().querySelector(".btn-settings");
@ -348,7 +345,7 @@ describe("loop.shared.views", function() {
});
it("should show the settings dropdown on click", function() {
var settingsMenuItems = [{ id: "feedback" }];
var settingsMenuItems = [{ id: "help" }];
var comp = mountTestComponent({ menuItems: settingsMenuItems} );
expect(comp.state.showMenu).eql(false);
@ -428,22 +425,8 @@ describe("loop.shared.views", function() {
sinon.assert.calledOnce(settingsMenuItems[0].onClick);
});
it("should open a tab to the feedback url when the feedback menu item is clicked", function() {
var settingsMenuItems = [
{ id: "feedback" },
{ id: "help" }
];
var comp = mountTestComponent({ menuItems: settingsMenuItems} );
TestUtils.Simulate.click(comp.getDOMNode().querySelector(".settings-menu > li:first-child"));
sinon.assert.calledOnce(fakeMozLoop.openURL);
sinon.assert.calledWithExactly(fakeMozLoop.openURL, feedback_url);
});
it("should open a tab to the support url when the support menu item is clicked", function() {
var settingsMenuItems = [
{ id: "feedback" },
{ id: "help" }
];
var comp = mountTestComponent({ menuItems: settingsMenuItems} );

Просмотреть файл

@ -86,6 +86,7 @@ settings_menu_item_signout=Sign Out
settings_menu_item_signin=Sign In
settings_menu_item_turnnotificationson=Turn Notifications On
settings_menu_item_turnnotificationsoff=Turn Notifications Off
settings_menu_item_feedback=Submit Feedback
settings_menu_button_tooltip=Settings
# Contact Strings (Panel)