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

Add a widget for managing thumbnail #1568

Merged
merged 4 commits into from
Jun 13, 2022

Conversation

roro-lv
Copy link
Contributor

@roro-lv roro-lv commented Jun 2, 2022

Purpose

Add a widget for uploading a thumbnail for the live video.
It also allows the instructor to replace it and/or delete it to get back to the default thumbnail.
The thumbnail is displayed when the live is starting or paused (on the student side) and when the video is converted to a VOD.

Caution : For now deleting a thumbnail is not working, because there is a bug on python soft delete (see here)

image

@roro-lv roro-lv self-assigned this Jun 2, 2022
@roro-lv roro-lv force-pushed the feature/widget/roro-lv/manage-thumbnail branch 13 times, most recently from 4c6f9e2 to 9fae066 Compare June 3, 2022 18:49
@roro-lv roro-lv force-pushed the feature/widget/roro-lv/manage-thumbnail branch from 082b78c to acd3322 Compare June 3, 2022 19:17
CHANGELOG.md Outdated Show resolved Hide resolved
Comment on lines 68 to 69
size="0.875rem"
style={{ fontFamily: 'Roboto-Regular' }}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
size="0.875rem"
style={{ fontFamily: 'Roboto-Regular' }}
size="xsmall"

Roboto-Regular shouldn't be needed.
Also, maybe xsmall provides a similar size ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would like to refute or confirm what you suggest, but i can't fin any correspondence table between pre-defined size and size in rem in grommet...

Comment on lines 63 to 67
{video.thumbnail && video.thumbnail.urls ? (
<ThumbnailDisplayer thumbnail={video.thumbnail} />
) : (
<Image fit="cover" src={appData.static.img.liveBackground} />
)}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe is there a way to use the same components for both static and uploaded thumbnails ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I put everything in one component

UseDeleteThumbnailError,
UseDeleteThumbnailData
>;
export const useDeleteThumbnail = (options?: UseDeleteThumbnailOptions) => {
Copy link
Member

Choose a reason for hiding this comment

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

IMO, you should add tests in src/frontend/data/queries/index.spec.tsx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes i forgot it ty !

onClickOutside={onModalCloseOrCancel}
responsive={false}
style={{
width: size === 'small' ? '95%' : '500px',
Copy link
Member

Choose a reason for hiding this comment

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

That's huge difference. Are you sure about this values ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For info, this component comes from the PR on the shared live media : https://github.com/openfun/marsha/blob/9f991d654dfb754566af8ca8dd71c93ec49becd7/src/frontend/components/DashboardVideoLiveControlPane/customs/DashboardVideoLiveConfirmationModal/index.tsx

I think the values are correct because this is what I wanted : a almost full page modal when the screen is small, a medium fixed sized modal otherwise

@roro-lv roro-lv force-pushed the feature/widget/roro-lv/manage-thumbnail branch from acd3322 to 4a94fd6 Compare June 7, 2022 16:33
@roro-lv roro-lv changed the title Feature/widget/roro lv/manage thumbnail Add a widget for managing thumbnail Jun 8, 2022
@lunika lunika mentioned this pull request Jun 8, 2022
4 tasks
uploadManagerState,
}: ThumbnailManagerProps) => {
const intl = useIntl();
const thumbnailState = thumbnail ? thumbnail.upload_state : uploadState.READY;
Copy link
Contributor

Choose a reason for hiding this comment

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

How can thumbnail be undefined or null ?

Copy link
Contributor Author

@roro-lv roro-lv Jun 8, 2022

Choose a reason for hiding this comment

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

you're right, ty !

Comment on lines 45 to 46
if (thumbnailState === uploadState.ERROR) {
textMessage = intl.formatMessage(messages.noThumbnailUploaded);
} else if (
Copy link
Contributor

Choose a reason for hiding this comment

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

When the state is in error, should we really display this message ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I agree, i changed the message to be more accurate

textMessage = intl.formatMessage(messages.noThumbnailUploaded);
} else if (
(thumbnailState === uploadState.PENDING &&
uploadManagerState[thumbnail!.id]?.status ===
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need an assert here ? And you shouldn't use assert (or there is no reason to use typescript in the project)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I forgot to remove it, ty

(thumbnailState === uploadState.PENDING &&
uploadManagerState[thumbnail!.id]?.status ===
UploadManagerStatus.UPLOADING) ||
uploadManagerState[thumbnail!.id]?.status === UploadManagerStatus.INIT
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment here about the assert

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I forgot to remove it, ty


let textMessage = null;

if (thumbnailState === uploadState.ERROR) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like you can externalize these if else if from this component (like in a dedicated file).

Copy link
Contributor Author

@roro-lv roro-lv Jun 8, 2022

Choose a reason for hiding this comment

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

mm the point of the ThumbnailManager was already to externalize the logic you are talking about


export const ThumbnailDisplayer = ({
rounded,
thumbnail,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you should use a thumbnail here, you are using only the urls.
If you change your component props to receive urls you will be able to use this component to render the default background with it.
CF : https://github.com/openfun/marsha/pull/1568/files#r891150092

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put everything in one component

@RVassili
Copy link
Contributor

RVassili commented Jun 8, 2022

And it would probably be easier if this is split in 2 PR:

  • one updating the waiting screen background for the student
  • one adding the component for the teacher to upload a thumbnail

@roro-lv roro-lv force-pushed the feature/widget/roro-lv/manage-thumbnail branch 3 times, most recently from 121cf48 to 4a49034 Compare June 8, 2022 14:46
Copy link
Member

@lunika lunika left a comment

Choose a reason for hiding this comment

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

The default live background is display with a very high size in the dashboard with firefox

Comment on lines 44 to 59
if (thumbnail.upload_state === uploadState.ERROR) {
textMessage = intl.formatMessage(messages.thumbnailError);
} else if (
(thumbnail.upload_state === uploadState.PENDING &&
uploadManagerState[thumbnail.id]?.status ===
UploadManagerStatus.UPLOADING) ||
uploadManagerState[thumbnail.id]?.status === UploadManagerStatus.INIT
) {
textMessage = intl.formatMessage(messages.thumbnailUploaded);
} else if (
thumbnail.upload_state === uploadState.PROCESSING ||
(thumbnail.upload_state === uploadState.PENDING &&
uploadManagerState[thumbnail.id]?.status === UploadManagerStatus.SUCCESS)
) {
textMessage = intl.formatMessage(messages.thumbnailProcessed);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I insist, you can externalize this in a dedicated function returning a Nullable, and this component will be cleaner

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

} else {
id = thumbnail.id;
}
addUpload(modelName.THUMBNAILS, id, event.target.files![0]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remove this assert ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

>
<Box direction={'column'} justify={'center'} gap="small">
{!thumbnail ||
(thumbnail && !thumbnail.urls && !uploadManagerState[thumbnail!.id]) ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

And this one too ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

<Stack anchor="top-right">
<Box>
<ThumbnailManager
thumbnail={thumbnail!}
Copy link
Contributor

Choose a reason for hiding this comment

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

And this one too ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

<PictureSVG height="24px" width="24px" iconColor="blue-active" />
</Box>
}
onClick={() => hiddenFileInput.current!.click()}
Copy link
Contributor

Choose a reason for hiding this comment

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

And this one too ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@roro-lv roro-lv force-pushed the feature/widget/roro-lv/manage-thumbnail branch 2 times, most recently from 248426d to 836b074 Compare June 9, 2022 10:18
@roro-lv
Copy link
Contributor Author

roro-lv commented Jun 9, 2022

The default live background is display with a very high size in the dashboard with firefox

Indeed, there was a display problem on the thumbnail (display was different whether you accessed the website from Firefox or Chrome). It's now fixed.

@roro-lv roro-lv force-pushed the feature/widget/roro-lv/manage-thumbnail branch from e8fe35e to 5bf4a97 Compare June 9, 2022 13:35
CHANGELOG.md Outdated
@@ -20,6 +20,7 @@ Versioning](https://semver.org/spec/v2.0.0.html).
- Add Legacy LTI configuration XML
- Add an instructor widget to modify join the discussion mode
- Prevent join API calls in join mode denied
- Add a widget for the instructor to upload a live video thumbnail
Copy link
Member

Choose a reason for hiding this comment

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

Remember to move it in the Unreleased section

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, ty !

Add a Bin SVG (used for deletion) and a Picture SVG (used for upload image
button) to the project.
@roro-lv roro-lv force-pushed the feature/widget/roro-lv/manage-thumbnail branch from 5bf4a97 to 95940a1 Compare June 13, 2022 14:16
Update advertising student screen, to display the uploaded thumbnail, when it
exists.
@roro-lv roro-lv force-pushed the feature/widget/roro-lv/manage-thumbnail branch from 95940a1 to a1f9735 Compare June 13, 2022 14:18
roro-lv and others added 2 commits June 13, 2022 16:25
Add a button for removing thumbnail (and add its associated queries). Add a
component to manage what to display when thumbnail is uploaded. Add a
confirmation modal for when an user wants to delete a thumbnail.

Co-Authored-By: Manuel Raynaud <[email protected]>
Co-Authored-By: Nicolas Clerc <[email protected]>
Add a widget to allow teacher to upload a thumbnail for its live. It also
allows him to replace it or delete it and display the default thumbnail.
@roro-lv roro-lv force-pushed the feature/widget/roro-lv/manage-thumbnail branch from a1f9735 to 6a071fb Compare June 13, 2022 14:25
@roro-lv roro-lv merged commit cb59c0b into master Jun 13, 2022
@roro-lv roro-lv deleted the feature/widget/roro-lv/manage-thumbnail branch June 13, 2022 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants