Skip to content

Commit

Permalink
Allow csrfToken to be set via a prop.
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-searle committed Nov 30, 2018
1 parent c88d052 commit 03db100
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion components/x-teaser-list/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ All `x-` components are designed to be compatible with a variety of runtimes, no

[jsx-wtf]: https://jasonformat.com/wtf-is-jsx/

### Properties
### Props

Feature | Type | Notes
------------------|---------|----------------------------
`items` | Array | Array of objects representing content items in Teaser format.
`showSaveButtons` | Boolean | Default = true. Whether to show the save buttons.
`csrfToken` | String | Cross-site Request Forgery token. Required if save buttons are shown.
4 changes: 2 additions & 2 deletions components/x-teaser-list/src/TeaserList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Teaser, presets } from '@financial-times/x-teaser';
import classNames from 'classnames';
import styles from './TeaserList.scss';

const TeaserList = ({ items = [], showSaveButtons = true }) => (
const TeaserList = ({ items = [], showSaveButtons = true, csrfToken = null }) => (
<ul className={classNames(styles.list)}>
{items.map(item => {
return (
Expand All @@ -24,7 +24,7 @@ const TeaserList = ({ items = [], showSaveButtons = true }) => (
id={`${item.id}-save-button`}
contentId={item.id}
contentTitle={item.title}
csrfToken="dummy-token"
csrfToken={csrfToken}
saved={item.saved || false}
/>
</div>}
Expand Down
3 changes: 2 additions & 1 deletion components/x-teaser-list/stories/with-save-buttons.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
exports.title = 'With save buttons';

exports.data = {
items: require('./content-items.json')
items: require('./content-items.json'),
csrfToken: 'dummy-token'
};

// This reference is only required for hot module loading in development
Expand Down

0 comments on commit 03db100

Please sign in to comment.