зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1175441 - Clear the 'Let's talk about' tickbox in the Loop panel when the page selection changes. r=mikedeboer
This commit is contained in:
Родитель
125942e9c3
Коммит
403f637bad
|
@ -730,6 +730,7 @@ loop.panel = (function(_, mozL10n) {
|
|||
var description = metadata.title || metadata.description;
|
||||
var url = metadata.url;
|
||||
this.setState({
|
||||
checked: false,
|
||||
previewImage: previewImage,
|
||||
description: description,
|
||||
url: url
|
||||
|
@ -775,7 +776,8 @@ loop.panel = (function(_, mozL10n) {
|
|||
return (
|
||||
React.createElement("div", {className: "new-room-view"},
|
||||
React.createElement("div", {className: contextClasses},
|
||||
React.createElement(Checkbox, {label: mozL10n.get("context_inroom_label"),
|
||||
React.createElement(Checkbox, {checked: this.state.checked,
|
||||
label: mozL10n.get("context_inroom_label"),
|
||||
onChange: this.onCheckboxChange}),
|
||||
React.createElement(sharedViews.ContextUrlView, {
|
||||
allowClick: false,
|
||||
|
|
|
@ -730,6 +730,7 @@ loop.panel = (function(_, mozL10n) {
|
|||
var description = metadata.title || metadata.description;
|
||||
var url = metadata.url;
|
||||
this.setState({
|
||||
checked: false,
|
||||
previewImage: previewImage,
|
||||
description: description,
|
||||
url: url
|
||||
|
@ -775,7 +776,8 @@ loop.panel = (function(_, mozL10n) {
|
|||
return (
|
||||
<div className="new-room-view">
|
||||
<div className={contextClasses}>
|
||||
<Checkbox label={mozL10n.get("context_inroom_label")}
|
||||
<Checkbox checked={this.state.checked}
|
||||
label={mozL10n.get("context_inroom_label")}
|
||||
onChange={this.onCheckboxChange} />
|
||||
<sharedViews.ContextUrlView
|
||||
allowClick={false}
|
||||
|
|
|
@ -633,6 +633,15 @@ loop.shared.views = (function(_, l10n) {
|
|||
};
|
||||
},
|
||||
|
||||
componentWillReceiveProps: function(nextProps) {
|
||||
// Only change the state if the prop has changed, and if it is also
|
||||
// different from the state.
|
||||
if (this.props.checked !== nextProps.checked &&
|
||||
this.state.checked !== nextProps.checked) {
|
||||
this.setState({ checked: nextProps.checked });
|
||||
}
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
return {
|
||||
checked: this.props.checked,
|
||||
|
|
|
@ -633,6 +633,15 @@ loop.shared.views = (function(_, l10n) {
|
|||
};
|
||||
},
|
||||
|
||||
componentWillReceiveProps: function(nextProps) {
|
||||
// Only change the state if the prop has changed, and if it is also
|
||||
// different from the state.
|
||||
if (this.props.checked !== nextProps.checked &&
|
||||
this.state.checked !== nextProps.checked) {
|
||||
this.setState({ checked: nextProps.checked });
|
||||
}
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
return {
|
||||
checked: this.props.checked,
|
||||
|
|
|
@ -850,6 +850,25 @@ describe("loop.panel", function() {
|
|||
expect(contextContent).to.not.equal(null);
|
||||
});
|
||||
|
||||
it("should cancel the checkbox when a new URL is available", function() {
|
||||
fakeMozLoop.getSelectedTabMetadata = function (callback) {
|
||||
callback({
|
||||
url: "https://www.example.com",
|
||||
description: "fake description",
|
||||
previews: [""]
|
||||
});
|
||||
};
|
||||
|
||||
var view = createTestComponent();
|
||||
|
||||
view.setState({ checked: true });
|
||||
|
||||
// Simulate being visible
|
||||
view.onDocumentVisible();
|
||||
|
||||
expect(view.state.checked).eql(false);
|
||||
});
|
||||
|
||||
it("should show a default favicon when none is available", function() {
|
||||
fakeMozLoop.getSelectedTabMetadata = function (callback) {
|
||||
callback({
|
||||
|
|
|
@ -765,6 +765,26 @@ describe("loop.shared.views", function() {
|
|||
expect(node.classList.contains("disabled")).to.eql(true);
|
||||
expect(node.hasAttribute("disabled")).to.eql(true);
|
||||
});
|
||||
|
||||
it("should render the checkbox as checked when the prop is set", function() {
|
||||
view = mountTestComponent({
|
||||
checked: true
|
||||
});
|
||||
|
||||
var checkbox = view.getDOMNode().querySelector(".checkbox");
|
||||
expect(checkbox.classList.contains("checked")).eql(true);
|
||||
});
|
||||
|
||||
it("should alter the render state when the props are changed", function() {
|
||||
view = mountTestComponent({
|
||||
checked: true
|
||||
});
|
||||
|
||||
view.setProps({checked: false});
|
||||
|
||||
var checkbox = view.getDOMNode().querySelector(".checkbox");
|
||||
expect(checkbox.classList.contains("checked")).eql(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#_handleClick", function() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче