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

Feature/deseng623 - Add frontend, update backend routes to use tenant short name #2538

Merged
merged 3 commits into from
Jun 11, 2024

Conversation

Baelx
Copy link
Collaborator

@Baelx Baelx commented Jun 11, 2024

Issue #: https://github.com/bcgov/met-public/issues/

Description of changes:

  • Add frontend language view
  • Update backend routes to use tenant short name, add authentication and CORS

Remaining work:

  • Add tests
  • Merge in changes from main
  • Create migration to add EDIT_LANGUAGES to admin composite role

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).

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.05%. Comparing base (0959d82) to head (87e1e4d).
Report is 27 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #2538    +/-   ##
========================================
  Coverage   76.04%   76.05%            
========================================
  Files         617      604    -13     
  Lines       22093    21808   -285     
  Branches     1686     1671    -15     
========================================
- Hits        16801    16586   -215     
+ Misses       5028     4959    -69     
+ Partials      264      263     -1     
Flag Coverage Δ
metweb 64.52% <ø> (-0.22%) ⬇️

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

Files Coverage Δ
met-api/src/met_api/models/__init__.py 100.00% <ø> (ø)
met-api/src/met_api/models/language.py 94.73% <ø> (-2.41%) ⬇️
met-api/src/met_api/resources/language.py 77.58% <ø> (+3.83%) ⬆️
met-api/src/met_api/services/language_service.py 94.44% <ø> (+7.77%) ⬆️
met-web/src/apiManager/endpoints/index.ts 100.00% <ø> (ø)

... and 73 files with indirect coverage changes

@Baelx Baelx changed the base branch from main to feature/deseng623 June 11, 2024 16:11
@Baelx Baelx marked this pull request as ready for review June 11, 2024 16:20
Copy link
Contributor

@NatSquared NatSquared left a comment

Choose a reason for hiding this comment

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

Looking good! I'm excited to see the language system taking shape :) Just a couple optional things to address if you have time

@@ -5,7 +5,7 @@

from http import HTTPStatus

from flask import jsonify, request
from flask import request
Copy link
Contributor

Choose a reason for hiding this comment

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

good catch :)

style={{ marginTop: '5%', marginBottom: '5%', width: isSmallScreen ? '50%' : '100%' }}
multiple
// Prevent users from clearing all languages with a button click.
clearIcon={<span style={{ display: 'none' }}></span>}
Copy link
Contributor

Choose a reason for hiding this comment

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

the boolean property "disableClearable" could be used here for concision. (API reference)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, thank you for finding that! I'll be switching

def delete(language_mapping_id):
@_jwt.requires_auth
@cross_origin(origins=allowedorigins())
def delete(language_id, tenant_short_name):
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for making sure all of this is consistent!

return 'Successfully deleted language-tenant mapping', HTTPStatus.NO_CONTENT
raise ValueError('Language-tenant mapping not found')
LanguageService.remove_language_mapping_from_tenant(language_id, tenant_short_name)
return {'status': 'success', 'message': 'Tenant language deleted successfully'}, HTTPStatus.OK
Copy link
Contributor

Choose a reason for hiding this comment

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

You could also return HTTP 204 No Content to indicate that the resource no longer exists, unless the message is planned to be utilized by the app

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I considered this for sure! Do you think there's a downside to having a message & 200 code returned on delete? I don't necessarily think that a 204 on delete is super idiomatic across the web

Copy link

sonarcloud bot commented Jun 11, 2024

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@Baelx Baelx merged commit 32e8b23 into feature/deseng623 Jun 11, 2024
1 check passed
Baelx added a commit that referenced this pull request Jun 19, 2024
…odes (#2540)

* DESENG-632 Add DB tables & API routes (#2533)

* DESENG-632 Add DB tables & API routes

* DESENG-623 fix linting

* DESENG-623 Move language to migration file, remove delete crud language route

* DESENG-623 Remove ability to delete language

---------

Co-authored-by: Alex <[email protected]>

* Feature/deseng623 - Add frontend, update backend routes to use tenant short name (#2538)

* DESENG-623 Add frontend, update backend routes

* DESENG-623 Add api route updates, correct linting

* DESENG-623 Correctly invoke autocomplete api to disable claering

---------

Co-authored-by: Alex <[email protected]>

* DESENG-623 Add frontend tests, trim api tests

* DESENG-623 Add frontend tests

* DESENG-623 Add new tests, fix broken ones, merge migrations

* DESENG-623 Update changelog

* DESENG-623 fix linting and tests, clean up code further

---------

Co-authored-by: Alex <[email protected]>
@NatSquared NatSquared deleted the feature/deseng623-frontend branch June 26, 2024 20:27
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