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

Skeleton OnDemand Radio Episode page #5804

Merged
merged 33 commits into from
Mar 16, 2020
Merged

Skeleton OnDemand Radio Episode page #5804

merged 33 commits into from
Mar 16, 2020

Conversation

rebeccamcginn
Copy link
Contributor

@rebeccamcginn rebeccamcginn commented Mar 7, 2020

RESOLVES #5797

Overall change:
Adding a new page type for OnDemand radio episodes

Code changes:

  • Added a new page - OnDemandRadio - with header, footer, cookies, and error message
  • Narrowed the regex for liveradio, added for OnDemand
  • Added fixture data for Pashto and Indonesian episodes

  • I have assigned myself to this PR and the corresponding issues
  • I have added labels to this PR for the relevant pod(s) affected by these changes
  • I have assigned this PR to the Simorgh project

Testing:

  • Automated (jest and/or cypress) tests added (for new features) or updated (for existing features)
  • If necessary, I have run the local E2E non-smoke tests relevant to my changes (CYPRESS_APP_ENV=local CYPRESS_SMOKE=false npm run test:e2e:interactive)
  • This PR requires manual testing

@rebeccamcginn rebeccamcginn added the ws-media World Service Media label Mar 7, 2020
@rebeccamcginn rebeccamcginn self-assigned this Mar 7, 2020
@rebeccamcginn rebeccamcginn marked this pull request as ready for review March 10, 2020 09:33
Comment on lines 1 to 19
import pipe from 'ramda/src/pipe';
import path from 'ramda/src/path';
import map from 'ramda/src/map';
import mergeDeepLeft from 'ramda/src/mergeDeepLeft';
import uuid from 'uuid';

const addIdToBlock = block => ({ ...block, uuid: uuid() });

const getBlocks = path(['content', 'blocks']);

const mapBlocks = pipe(getBlocks, map(addIdToBlock));

export default jsonRaw =>
mergeDeepLeft(
{
content: { blocks: mapBlocks(jsonRaw) },
},
jsonRaw,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

This appears to be a duplicate of https://github.com/bbc/simorgh/blob/latest/src/app/routes/radio/getInitialData/addIdsToBlocks.js - is it possible to try and reuse this somehow?

Choose a reason for hiding this comment

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

You could pop it in here src/app/routes/utils/sharedDataTransformers and call it addIdsToRadioBlocks so both live radio and ondemand routes can use it

Copy link
Contributor

@ryanmccombe ryanmccombe Mar 13, 2020

Choose a reason for hiding this comment

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

Not sure if this is in scope for this PR as it's just supposed to be a blank page, but I'm not really sure we need to be using the Blocks renderer for this page at all in the long term

It seems to be the case that ARES payloads for these pages only ever have one block - the block that contains the episode info

We don't have to be iterating over blocks if there's only ever one block, and if we're not iterating over blocks, we don't need to be adding IDs to them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed it

src/app/routes/utils/regex/utils/index.js Show resolved Hide resolved
Comment on lines +69 to +91
OnDemandRadioPage.propTypes = {
pageData: shape({
metadata: shape({
id: string,
tags: object,
}),
promo: shape({
subtype: string,
name: string,
}),
content: shape({
blocks: arrayOf(
shape({
uuid: string,
id: string,
externalId: string,
text: string,
type: string,
}),
),
}),
}).isRequired,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth extracting this into a separate function like this: https://github.com/bbc/simorgh/blob/latest/src/app/models/propTypes/radioPage/index.js

Copy link

@jroebu14 jroebu14 Mar 11, 2020

Choose a reason for hiding this comment

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

I've stressed so many times how important it is to keep prop types explicit and inline with the component and not to abstract them away because they it's super handy documentation for developers:

#4477
https://gist.github.com/jroebu14/cb3f82f51d74a02a586e7bc430414a05
https://gist.github.com/jroebu14/0ff63ba198e7e46cfce2df3381710256

I'd prefer it if we kept them as is even if it means duplication. The problem is really that our prop type definitions are too complex because we pass components the full Ares response instead of picking out only the bits we need from the response before passing props down. An example of how I'd like our prop types to be https://github.com/bbc/simorgh/pull/5566/files#diff-e449f3ce3c0cbe3fd43e2629cf8661baR71-R76 rather having a hidden away centralised and hard to understand system of proptypes.

We should do this for all our components. I refactored the Metadata component a while ago to accept only the props it needs instead of the full Ares response and how look how simple it is to use now! https://github.com/bbc/simorgh/pull/5804/files#diff-6f9218412f92864ee8850958a05c23a2R21-R24 I want to do the same for the ATI component #5743

Sorry for all the reading but I'm passionate about this issue because it's about developer experience! Grab me if you want me to explain more.

Copy link
Contributor

@karinathomasbbc karinathomasbbc Mar 11, 2020

Choose a reason for hiding this comment

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

Excellent explanation - thank you. Maybe it would make sense to eventually delete the functions in /src/app/models/propTypes/ which are no longer needed or used anymore. (But not in this PR obvs!)

Comment on lines +37 to +50
.add('default', ({ service }) => (
<BrowserRouter>
<OnDemandRadioPage
match={matchFixtures(service)}
pageData={onDemandRadioFixtures[service]}
status={status}
service={service}
isAmp={false}
loading={false}
error=""
pageType="media"
/>
</BrowserRouter>
));
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add a second example here for amp?

src/app/routes/index.js Outdated Show resolved Hide resolved
@LilyL0u LilyL0u self-assigned this Mar 16, 2020
@rebeccamcginn rebeccamcginn requested a review from jroebu14 March 16, 2020 12:07
Copy link

@jroebu14 jroebu14 left a comment

Choose a reason for hiding this comment

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

Looks good to me

@rebeccamcginn rebeccamcginn merged commit cb14436 into latest Mar 16, 2020
@rebeccamcginn rebeccamcginn deleted the SkeletonPageOnTest branch March 16, 2020 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ws-media World Service Media
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Skeleton OnDemand Radio Episode on Test
5 participants