Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature improve source filtering #166

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/src/js/newsboard/components/ScanNews.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class ScanNews extends Component {
componentWillMount() {
const mainHeaderStrings = Locale.applicationStrings().messages.mainHeaderStrings;
this.props.dispatch(setCurrentHeaderTab(mainHeaderStrings.newsBoard));
this.props.dispatch(filterTabSwitch("web"));
}

displayFilters() {
Expand Down
13 changes: 12 additions & 1 deletion client/src/js/newsboard/filter/DisplayFilters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ export class DisplayFilters extends Component {
selectedSources = { "web": new Set(web), "facebook": new Set(facebook), "twitter": new Set(twitter) };
}

selectAllSources() {
selectedSources = { "web": new Set(), "facebook": new Set(), "twitter": new Set() };
Object.entries(this.props.sources).map(([key, value]) => {
value.forEach(elem => {
selectedSources[key].add(elem.url);
});
});
}

_renderSources(sourceType, searchKey) {
const configuredSourceDOM = (source) =>
(<li className="filter-source" key={source._id}>
Expand Down Expand Up @@ -156,7 +165,9 @@ export class DisplayFilters extends Component {
</div>
}

<ConfiguredSources searchKeyword={this.props.searchKeyword} currentTab={this.props.currentTab} renderSources={this._renderSources}/>
<ConfiguredSources searchKeyword={this.props.searchKeyword} currentTab={this.props.currentTab} renderSources={this._renderSources}
selectAllSources={this.selectAllSources()}
/>

<div className="controls">
<button id="cancelBtn" className="cancel-btn primary" onClick={this.cancelFilter}>{this.filterStrings.cancelButton}</button>
Expand Down
2 changes: 1 addition & 1 deletion client/src/js/newsboard/reducers/DisplayFeedReducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function selectedArticle(state = {}, action = {}) {
}
}

export const newsBoardCurrentSourceTab = (state = newsBoardSourceTypes.trending, action = {}) => {
export const newsBoardCurrentSourceTab = (state = newsBoardSourceTypes.web, action = {}) => {
switch(action.type) {
case NEWS_BOARD_CURRENT_TAB: {
return action.currentTab;
Expand Down
2 changes: 1 addition & 1 deletion client/test/newsboard/reducers/DisplayFeedReducersSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe("DisplayFeedReducer", () => {
});

it("should return web as current tab when newsBoardCurrentSourceTab called without any action type", () => {
expect(newsBoardCurrentSourceTab()).to.deep.equal("trending");
expect(newsBoardCurrentSourceTab()).to.deep.equal("web");
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ _fti = {couch_httpd_proxy, handle_proxy_req, <<"http://localhost:5985">>}
[cors]
origins = http://localhost:5000
credentials = true
port = 5986
port = 5984
methods = GET, PUT, POST, HEAD, DELETE
[httpd]
port = 5986
port = 5984