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 video widget admin side component and resource #1828

Merged
merged 8 commits into from
Jul 13, 2023

Conversation

jadmsaadaot
Copy link
Collaborator

Description of changes:

  • Add video widget to option cards
  • Add video widget drawer form
  • Add create, get and update video widget resources

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the met-public license (Apache 2.0).

@jadmsaadaot jadmsaadaot self-assigned this Jul 11, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jul 11, 2023

Codecov Report

Merging #1828 (57d6010) into main (c5f382e) will decrease coverage by 0.58%.
The diff coverage is 46.04%.

@@            Coverage Diff             @@
##             main    #1828      +/-   ##
==========================================
- Coverage   71.47%   70.89%   -0.58%     
==========================================
  Files         396      405       +9     
  Lines       12051    12327     +276     
  Branches      910      923      +13     
==========================================
+ Hits         8613     8739     +126     
- Misses       3291     3431     +140     
- Partials      147      157      +10     
Flag Coverage Δ
metapi 78.75% <58.77%> (-0.42%) ⬇️
metweb 63.99% <37.19%> (-0.69%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
met-web/src/apiManager/endpoints/index.ts 100.00% <ø> (ø)
...gement/form/EngagementWidgets/WidgetCardSwitch.tsx 21.95% <0.00%> (-3.05%) ⬇️
...ponents/engagement/form/EngagementWidgets/type.tsx 100.00% <ø> (ø)
.../src/services/widgetService/VideoService/index.tsx 23.07% <23.07%> (ø)
...s/engagement/form/EngagementWidgets/Video/Form.tsx 27.41% <27.41%> (ø)
...ment/form/EngagementWidgets/Video/VideoContext.tsx 32.00% <32.00%> (ø)
...t-api/src/met_api/services/widget_video_service.py 34.48% <34.48%> (ø)
...t/form/EngagementWidgets/Video/VideoOptionCard.tsx 59.45% <59.45%> (ø)
met-api/src/met_api/resources/widget_video.py 60.00% <60.00%> (ø)
met-api/src/met_api/models/widget_video.py 65.21% <65.21%> (ø)
... and 9 more

@jadmsaadaot jadmsaadaot marked this pull request as ready for review July 11, 2023 21:22
@sonarcloud
Copy link

sonarcloud bot commented Jul 12, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

sa.Column('description', sa.String))

op.bulk_insert(widget_type_table, [
{'id': 7, 'name': 'Video', 'description': 'Add a link to a hosted video and link preview'}
Copy link
Collaborator

Choose a reason for hiding this comment

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

in one of the alembic scripts , i haev a better of handling the increment numbers.. can you look up that?
basically it reads value from the sequnce and does a plus one

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's definitely a smarter way to do it. I just choose to hard code 7 here because it is hard coded in the front end:
image

And types are hard coded in the backend in the constants in WidgetType which is used for the tests. I wasn't comfortable leaving it up for a calculation although it will reach the same result of 7. What do you think

image

},
});
const response = await http.PatchRequest<VideoWidget>(url, data);
if (response.data) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

return response.data || Promise.reject(' etc

works? the if statement looks like long

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea, will fix in the next PR directly after this

Comment on lines +27 to +30
if (response.data) {
return response.data;
}
return Promise.reject('Failed to create video widget');
Copy link
Collaborator

Choose a reason for hiding this comment

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

same like below..may be use a || to avoid if
make sure it works please

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea, will fix in the next PR directly after this

@jadmsaadaot jadmsaadaot merged commit bd80e5f into bcgov:main Jul 13, 2023
16 checks passed
NatSquared pushed a commit that referenced this pull request Oct 19, 2023
* Add video widget model and option card

* add video widget service and resource

* Add video widget crud and UI component

* Fix linting issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants