Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

Commit

Permalink
fix(topsites): Remove pinTitle from sites, currently not being used (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
piatra authored and Mardak committed Aug 4, 2017
1 parent fc9a4ac commit 3b2f4a3
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 21 deletions.
3 changes: 1 addition & 2 deletions system-addon/common/Reducers.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ function insertPinned(links, pinned) {
newLinks = newLinks.map(link => {
if (link && link.isPinned) {
delete link.isPinned;
delete link.pinTitle;
delete link.pinIndex;
}
return link;
Expand All @@ -78,7 +77,7 @@ function insertPinned(links, pinned) {
// Then insert them in their specified location
pinned.forEach((val, index) => {
if (!val) { return; }
let link = Object.assign({}, val, {isPinned: true, pinIndex: index, pinTitle: val.title});
let link = Object.assign({}, val, {isPinned: true, pinIndex: index});
if (index > newLinks.length) {
newLinks[index] = link;
} else {
Expand Down
2 changes: 1 addition & 1 deletion system-addon/content-src/components/TopSites/TopSites.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TopSite extends React.Component {
render() {
const {link, index, dispatch} = this.props;
const isContextMenuOpen = this.state.showContextMenu && this.state.activeTile === index;
const title = link.pinTitle || link.hostname;
const title = link.hostname;
const topSiteOuterClassName = `top-site-outer${isContextMenuOpen ? " active" : ""}`;
const {tippyTopIcon} = link;
let imageClassName;
Expand Down
7 changes: 1 addition & 6 deletions system-addon/test/unit/common/Reducers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe("Reducers", () => {
const oldState = {rows: [{url: "foo.com"}, {url: "bar.com"}]};
const action = {type: at.PINNED_SITES_UPDATED, data: [{url: "baz.com", title: "baz"}]};
const nextState = TopSites(oldState, action);
assert.deepEqual(nextState.rows, [{url: "baz.com", title: "baz", isPinned: true, pinIndex: 0, pinTitle: "baz"}, {url: "foo.com"}, {url: "bar.com"}]);
assert.deepEqual(nextState.rows, [{url: "baz.com", title: "baz", isPinned: true, pinIndex: 0}, {url: "foo.com"}, {url: "bar.com"}]);
});
it("should return at most TOP_SITES_SHOWMORE_LENGTH sites on PINNED_SITES_UPDATED", () => {
const oldState = {rows: [{url: "foo.com"}, {url: "bar.com"}]};
Expand Down Expand Up @@ -342,7 +342,6 @@ describe("Reducers", () => {
for (let index of [0, 1]) {
assert.equal(result[index].url, pinned[index].url);
assert.ok(result[index].isPinned);
assert.equal(result[index].pinTitle, pinned[index].title);
assert.equal(result[index].pinIndex, index);
}
assert.deepEqual(result.slice(2), links);
Expand All @@ -359,7 +358,6 @@ describe("Reducers", () => {
for (let index of [1, 4]) {
assert.equal(result[index].url, pinned[index].url);
assert.ok(result[index].isPinned);
assert.equal(result[index].pinTitle, pinned[index].title);
assert.equal(result[index].pinIndex, index);
}
result.splice(4, 1);
Expand All @@ -372,17 +370,14 @@ describe("Reducers", () => {
const result = insertPinned([], pinned);
assert.equal(result[11].url, pinned[11].url);
assert.isTrue(result[11].isPinned);
assert.equal(result[11].pinTitle, pinned[11].title);
assert.equal(result[11].pinIndex, 11);
});
it("should unpin previously pinned links no longer in the pinned list", () => {
const pinned = [];
links[2].isPinned = true;
links[2].pinTitle = "pinned site";
links[2].pinIndex = 2;
const result = insertPinned(links, pinned);
assert.notProperty(result[2], "isPinned");
assert.notProperty(result[2], "pinTitle");
assert.notProperty(result[2], "pinIndex");
});
it("should handle a link present in both the links and pinned list", () => {
Expand Down
10 changes: 0 additions & 10 deletions system-addon/test/unit/content-src/components/TopSites.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,9 @@ describe("<TopSite>", () => {

assert.equal(titleEl.text(), "foobar");
});
it("should render the pinTitle if set", () => {
link.isPinned = true;
link.pinnedIndex = 7;
link.pinTitle = "pinned";
const wrapper = shallow(<TopSite link={link} />);
const titleEl = wrapper.find(".title");

assert.equal(titleEl.text(), "pinned");
});
it("should render the pin icon for pinned links", () => {
link.isPinned = true;
link.pinnedIndex = 7;
link.pinTitle = "pinned";
const wrapper = shallow(<TopSite link={link} />);
assert.equal(wrapper.find(".icon-pin-small").length, 1);
});
Expand Down
4 changes: 2 additions & 2 deletions system-addon/test/unit/lib/TopSitesFeed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ describe("Top Sites Feed", () => {
assert.lengthOf(sites, 2);
});
it("should return sites that have a title", async () => {
// Simulate a pinned link with no pinTitle.
// Simulate a pinned link with no title.
fakeNewTabUtils.pinnedLinks.links = [{url: "https://github.com/mozilla/activity-stream"}];

const sites = await feed.getLinksWithDefaults();

for (const site of sites) {
assert.isDefined(site.pinTitle || site.hostname);
assert.isDefined(site.hostname);
}
});
it("should check against null entries", async () => {
Expand Down

0 comments on commit 3b2f4a3

Please sign in to comment.