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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate embed codes for Tobira directly instead of for the Opencast player #557

Merged
merged 27 commits into from
Oct 12, 2022

Conversation

JulianKniephoff
Copy link
Member

Wow, this took way too long. I got super hung up on how exactly to factor this. Turns out: Suddenly being embedded in an iframe breaks a lot of assumptions throughout all our components. In the end, after a long and painful deliberation process, I opted to mostly make the embedded stuff independent of all the rest. I made some obvious refactorings to reuse at least some stuff, but there is also a lot of (additional) duplication, now. (And looking through a lot of the code for this again, that's already somewhat true before this PR, so maybe it's not actually that bad.)

One argument for why this might be okay is that this is a rather ad hoc feature: We only want this to have the nice "stream will start whenever" view when you embed videos from Tobira. However, I think that's actually Paellas responsibility, so maybe we can even take out this code again at some point. On the other hand I also thought about extending the feature to being able to embedding other things, but if we really want that, I think we will have to rethink some of the choices I made here, so I'm kinda betting on us not wanting that. 馃

So what this means concretely is that there is exactly one route now that can be embedded. And in fact, trying to embed other routes will elicit an error. Components don't know about being embedded or not. The whole thing works by the embed-route just pasting together preexisting or factored-out components, or just flat out duplicating some.

The only exception to this is the global error boundary, which lives outside of the router. So if we want that to look nice in an iframe as well, it has to know whether it's embedded or not, instead of just relying on routing logic.

Anyway, I'm glad this is (mostly) over with, now. 馃槱

Meta

Closes #524.

Based on #554.

Can and should be reviewed commit by commit, which should also make clear when/how/what the whole thing does.

Note that the last commit is for demo/testing purposes only and should be removed before this is merged.

@github-actions
Copy link

馃殌 This PR was deployed at https://pr557.tobira.opencast.org. The deployment will be updated whenever someone pushes onto this PR's branch.

Copy link
Member

@LukasKalbertodt LukasKalbertodt left a comment

Choose a reason for hiding this comment

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

Overall the approach makes sense to me and I don't think its too much code duplication. The refactorings also make sense to me. Good jobs keeping atomic and understandable commits, made the review a lot easier I think.

I have not tested it yet, that will be in an additional comment.

I did find a few things that should still be fixed tho. (This review does not include the first three commits which are part of a different PR)

frontend/src/layout/Root.tsx Outdated Show resolved Hide resolved
@@ -233,7 +233,6 @@ type Props = {

const VideoPage: React.FC<Props> = ({ eventRef, realmRef, basePath }) => {
const { t } = useTranslation();
const rerender = useForceRerender();
Copy link
Member

Choose a reason for hiding this comment

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

That change aint good. I put it here specifically to redraw more than just the player. It's also about the time/date information below the player (i.e. in the <Metadata> component). For the video block it's probably fine to do it only in the Player, but here we specifically need to rerender the whole player page.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense. I pushed another commit.

frontend/src/ui/player/index.tsx Outdated Show resolved Hide resolved
frontend/src/routes/Embed.tsx Outdated Show resolved Hide resolved
frontend/src/routes/Embed.tsx Outdated Show resolved Hide resolved
frontend/src/routes/Embed.tsx Outdated Show resolved Hide resolved
frontend/src/routes/Embed.tsx Outdated Show resolved Hide resolved
frontend/src/i18n/locales/en.yaml Outdated Show resolved Hide resolved
frontend/src/routes/Video.tsx Outdated Show resolved Hide resolved
@LukasKalbertodt
Copy link
Member

Ok, I tested briefly. I didn't check every possible video state but I assume you did. Thanks for including the test page commit, that was helpful! I only got one new thought:

Forbid embedding all other pages... I like the idea but maybe we take too much freedom away from people? Like if they want to embed a specific page and it works for them... why not?

@github-actions

This comment was marked as resolved.

Technically this also extends them a bit, but that should be fine.
This way routes not using the `RootLoader` (<cough>embeds</cough>)
can define their own loading fallbacks.
This was always used together anyway and it will be so
for the embedded player as well.
This also makes the comment in the `Player` code make more sense. ;P
This avoids potential race conditions.
This change seems larger than it is mostly because I had to move
some stuff around to get rid of a dependency cycle in our module
structure which we unfortunately have lots of.

This was causing load order inconsistencies and made the app crash.
@github-actions github-actions bot removed the status:conflicts This PR has conflicts that need to be resolved label Oct 12, 2022
@JulianKniephoff
Copy link
Member Author

Forbid embedding all other pages... I like the idea but maybe we take too much freedom away from people? Like if they want to embed a specific page and it works for them... why not?

My thinking was mostly: Don't give people crazy ideas. I could imagine this leading to unintended use cases and absurd requirements. 馃し

@LukasKalbertodt
Copy link
Member

My thinking was mostly: Don't give people crazy ideas. I could imagine this leading to unintended use cases and absurd requirements.

Ok sure, then let's just disallow it for now, it's fine 馃し

@LukasKalbertodt LukasKalbertodt merged commit 0e38185 into elan-ev:master Oct 12, 2022
@JulianKniephoff JulianKniephoff deleted the embed-tobira-player branch October 19, 2022 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:user User facing changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change generated embed code to embed Tobira's own player instead of Opencast's
2 participants