Skip to content
Merged
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
2 changes: 2 additions & 0 deletions docs/adding-a-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This will outline what is required to add a page to the project. A basic knowled
[react](https://facebook.github.io/react/docs/getting-started.html) and
[redux](http://redux.js.org/) is assumed.

**Note:** This page is very out-of-date and does not reflect our practices anymore. We now use [redux-saga](https://github.com/redux-saga/redux-saga) for API requests. See `amo/components/Categories.js` for a more modern example of a component that makes API/async requests for data.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good idea


## Structure

A basic app structure will look like this:
Expand Down
13 changes: 0 additions & 13 deletions src/core/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
LOG_OUT_USER,
SET_AUTH_TOKEN,
SET_CLIENT_APP,
SET_CURRENT_USER,
SET_LANG,
SET_USER_AGENT,
} from 'core/constants';
Expand Down Expand Up @@ -82,15 +81,3 @@ export function loadEntities(entities: Array<Object>): LoadEntitiesAction {
payload: { entities },
};
}

export type SetCurrentUserAction = {|
payload: {| username: string |},
type: string,
|};

export function setCurrentUser(username: string): SetCurrentUserAction {
return {
type: SET_CURRENT_USER,
payload: { username },
};
}
1 change: 0 additions & 1 deletion src/core/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ export const SEARCH_LOADED = 'SEARCH_LOADED';
export const SEARCH_STARTED = 'SEARCH_STARTED';
export const SET_AUTH_TOKEN = 'SET_AUTH_TOKEN';
export const SET_CLIENT_APP = 'SET_CLIENT_APP';
export const SET_CURRENT_USER = 'SET_CURRENT_USER';
export const SET_ERROR = 'SET_ERROR';
export const SET_LANG = 'SET_LANG';
export const SET_USER_AGENT = 'SET_USER_AGENT';
Expand Down
3 changes: 0 additions & 3 deletions src/core/reducers/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import log from 'core/logger';
import {
LOG_OUT_USER,
SET_AUTH_TOKEN,
SET_CURRENT_USER,
} from 'core/constants';

function getUserIdFromAuthToken(token) {
Expand Down Expand Up @@ -37,8 +36,6 @@ export default function authentication(state = {}, action) {
// because the server is responsible for that.
userId: getUserIdFromAuthToken(payload.token),
};
case SET_CURRENT_USER:
return { ...state, username: payload.username };
case LOG_OUT_USER:
return {};
default:
Expand Down
11 changes: 0 additions & 11 deletions tests/client/core/reducers/test_authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ describe('authentication reducer', () => {
expect(auth(state, { type: 'UNRELATED' })).toBe(state);
});

it('sets the user on SET_CURRENT_USER', () => {
const username = 'my-username';
expect(auth(undefined, { type: 'SET_CURRENT_USER', payload: { username } })).toEqual({ username });
});

it('maintains the token when adding a username', () => {
const username = 'name-of-user';
const token = userAuthToken();
expect(auth({ token }, { type: 'SET_CURRENT_USER', payload: { username } })).toEqual({ token, username });
});

describe('set and reduce auth token', () => {
const setAndReduceToken = (token) => auth(undefined, setAuthToken(token));

Expand Down