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

Fix part of #5002: Removed NAV_MODE from side navigation bar #6008

Merged
merged 7 commits into from
Dec 24, 2018

Conversation

mighty-phoenix
Copy link
Contributor

@mighty-phoenix mighty-phoenix commented Dec 19, 2018

Explanation

Fixes part of #5002: Removed the constant NAV_MODE and made a new variable CURRENT_URL which stores the url of the current URL(as the name suggests). This variable is then used to determine the active tab/page.

Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The PR explanation includes the words "Fixes #bugnum: ..." (or "Fixes part of #bugnum" if the PR only partially fixes an issue).
  • The linter/Karma presubmit checks have passed.
    • These should run automatically, but if not, you can manually trigger them locally using python scripts/pre_commit_linter.py and bash scripts/run_frontend_tests.sh.
  • The PR is made from a branch that's not called "develop".
  • The PR follows the style guide.
  • The PR is assigned to an appropriate reviewer.
    • If you're a new contributor, please ask on Gitter for someone to assign a reviewer.
    • If you're not sure who the appropriate reviewer is, please assign to the issue's "owner" -- see the "talk-to" label on the issue.

@mighty-phoenix
Copy link
Contributor Author

@vojtechjelinek
I have tested the changes and it's working pretty fine. Kindly review.

Copy link
Contributor

@vojtechjelinek vojtechjelinek left a comment

Choose a reason for hiding this comment

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

Thanks! NAV_MODE is also used in TopNavigationBarDirective.js remove it from there too.

And after you remove all the usage of NAV_MODE in frontend you should remove it from our codebase completely. So for example from base.html, and in feconf.py there are constants related to NAV_MODE remove them too.

@@ -26,7 +26,7 @@ oppia.directive('sideNavigationBar', [
'side_navigation_bar_directive.html'),
controller: ['$scope', '$timeout', function(
$scope, $timeout) {
$scope.NAV_MODE = GLOBALS.NAV_MODE;
$scope.CURRENT_URL = window.location.pathname;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use angular version of window.location.pathname an since now it's not really a constant use camelCase

Suggested change
$scope.CURRENT_URL = window.location.pathname;
$scope.currentUrl = $location.path();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vojtechjelinek after this change in SideNavigationBarDirective.js, the side nav bar has stopped working even after making equivalent changes in html. I also added '$location' to controller and function parameters. Still the expected behaviour is not established.

Copy link
Contributor Author

@mighty-phoenix mighty-phoenix Dec 19, 2018

Choose a reason for hiding this comment

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

FYI,
image
image

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure, try to debug it, is there some error in browser console, try to print the value of currentUrl to check it contains correct value.

Copy link
Contributor Author

@mighty-phoenix mighty-phoenix Dec 20, 2018

Choose a reason for hiding this comment

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

@vojtechjelinek
I did all the research possible, and fixed the issue.
image

But now, a new problem has arised. The $location api doesn't have the capability of reloading the entire page, unlike window.location(Look at the screenshot below). So the url gets changed on clicking a button on side nav bar, but page doesn't get reloaded, resulting the user to stay on the same page as before. What should we do now? Use window.location itself?
image

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see, we definitely shouldn't modify $locationProvider, so use window.location.pathname please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vojtechjelinek Alright. Thanks.

…igationBarDirective.js

Co-Authored-By: rakshitkumarcse <32777813+rakshitkumarcse@users.noreply.github.com>
@codecov-io
Copy link

codecov-io commented Dec 19, 2018

Codecov Report

Merging #6008 into develop will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #6008   +/-   ##
=======================================
  Coverage     45.3%   45.3%           
=======================================
  Files          520     520           
  Lines        30667   30667           
  Branches      4597    4597           
=======================================
  Hits         13893   13893           
  Misses       16774   16774
Impacted Files Coverage Δ
.../side_navigation_bar/SideNavigationBarDirective.js 16.66% <0%> (ø) ⬆️
...ts/top_navigation_bar/TopNavigationBarDirective.js 0.8% <0%> (ø) ⬆️
...xploration_player/ExplorationPlayerStateService.js 1.53% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 05ed54f...4a09285. Read the comment docs.

@mighty-phoenix
Copy link
Contributor Author

@vojtechjelinek thanks for the guidance. This will make it easier for me to work on other parts of the issue.
Working on the changes.

@mighty-phoenix
Copy link
Contributor Author

@vojtechjelinek The PR is ready for final review and merge.
Thanks!

Copy link
Contributor

@vojtechjelinek vojtechjelinek left a comment

Choose a reason for hiding this comment

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

Hi, just one comment and nav_mode is also used in base.html so remove it from there.

@@ -61,7 +61,7 @@ def get(self, collection_id):

self.values.update({
'collection_id': collection.id,
'nav_mode': feconf.NAV_MODE_CREATE,
'nav_mode': 'create',
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need this variable anymore? This is just passed to the Jinja and Jinja will include int the HTML files. And since you removed NAV_MODE from base.html it!s not needed anymore. Ditto for the other files below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vojtechjelinek Oh. Removing these then.
Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vojtechjelinek Does this look fine now?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes

Copy link
Contributor

@vojtechjelinek vojtechjelinek left a comment

Choose a reason for hiding this comment

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

Thanks. LGTM!

@mighty-phoenix
Copy link
Contributor Author

@vojtechjelinek Kindly merge.

@vojtechjelinek
Copy link
Contributor

@seanlip or @apb7 Review, please.

Copy link
Contributor

@apb7 apb7 left a comment

Choose a reason for hiding this comment

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

LGTM (for changes in core/tests/..), thanks @rakshitkumarcse!

@apb7 apb7 merged commit b27bb32 into oppia:develop Dec 24, 2018
@mighty-phoenix
Copy link
Contributor Author

@apb7 Thanks for the review.

@mighty-phoenix mighty-phoenix deleted the remove_globals branch December 24, 2018 21:41
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.

4 participants