-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 #3826: extract from EditorServices.js #3970
Merged
Merged
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
bf61e1f
Partial Fix #3826: extract from EditorServices.js
bching 85388f9
Merge branch 'develop' into extract-editorservice
bching a05df4b
fix merge mistakes
bching 675cf07
Merge remote-tracking branch 'origin/extract-editorservice' into extr…
bching e2c4ff3
fix e2e errors and linting errors
bching 587a84f
remove new line linter error
bching 55ad344
Merge branch 'develop' into extract-editorservice
bching 84dcff2
Update StatisticsTab.js
bching 106e41f
fix format and remove includes
bching d98998c
Merge remote-tracking branch 'origin/extract-editorservice' into extr…
bching 6de9b5f
Revert "Merge remote-tracking branch 'origin/extract-editorservice' i…
bching ad62ead
move to previous line
bching 8fae1c1
add periods
bching 323e730
remove erroneous additions
bching 31ef802
Merge branch 'develop' into extract-editorservice
bching 2e614c0
remove line
bching File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
core/templates/dev/head/pages/exploration_editor/AngularNameService.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2014 The Oppia Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS-IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/** | ||
* @fileoverview A service that maps IDs to Angular names. | ||
*/ | ||
|
||
oppia.factory('AngularNameService', [function() { | ||
var angularName = null; | ||
|
||
return { | ||
getNameOfInteractionRulesService: function(interactionId) { | ||
angularName = interactionId.charAt(0).toLowerCase() + | ||
interactionId.slice(1) + 'RulesService'; | ||
return angularName | ||
} | ||
}; | ||
}]); |
34 changes: 34 additions & 0 deletions
34
core/templates/dev/head/pages/exploration_editor/AngularNameServiceSpec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2014 The Oppia Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS-IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/** | ||
* @fileoverview Unit test for the Angular names service. | ||
*/ | ||
|
||
describe('Angular names service', function() { | ||
beforeEach(module('oppia')); | ||
|
||
describe('angular name service', function() { | ||
var ans = null; | ||
|
||
beforeEach(inject(function($injector) { | ||
ans = $injector.get('AngularNameService'); | ||
})); | ||
|
||
it('should map interaction ID to correct RulesService', function() { | ||
expect(ans.getNameOfInteractionRulesService('TextInput')).toEqual( | ||
'textInputRulesService'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these really needed here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. They are removed now.
If you are checking if these services are dependent on another, should I generally just do a grep on the file names and see if they are referenced by files within another directory i.e. collection_editor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I meant you had to analyse it before removing! I don't know for sure whether all would be removed or not.
Check out this, here I have tried to explain how I would go about analysing it. (See the comments for file
admin.html
). Let me know if you have any questions :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the link with the great explanation.
So ExplorationDataService is a dependency within EditorServices; EditorStateService is a dependency within RouterService; and AngularNameService is a dependency within EditorServices. EditorServices and RouterService are imported in collection_editor, so I believe they are needed here if my thinking is correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @bching, yup as much as I've checked these are needed here.
In general, you had to see, for example, if we need to include AngularNameService.js:
-
AngularNameService
is being directly used anywhere in collection_editor (say, there was a direct mention ofAngularNameService
in any of the services defined in collection_editor)or
-Any other service which depends on
AngularNameService
(directly or indirectly) is being used in collection_editor.We have AngularNameService defined in EditorServices.js and it is a dependency in ExplorationStateService (also defined in EditorServices.js). Now it might not be enough to say that as EditorServices.js is imported in collection_editor, so will also need AngularNameService.js. As it can be the case,(just for example sake consider), that in collection_editor we were using the
changeListService
only, because of which we needed to importEditorServices
but then there would have been no need of importingAngularNameService
too aschangeListService
does not depend on it.In short you had to see the subset of services defined in EditorServices.js that depend on
AngularNameService
and whether those services were being used in collection_editor.The reason why we need
AngularNameService
is becauseexplorationStatesService
has it as a dependency, andRouterService
(defined in RouterService.js) hasexplorationStatesService
as a dependency (so indirect dependency on AngularNameService). And in collection_editor we need RouterService.js, so we check which service defined in RouterService.js is actually needed by collection_editor. But as there is just one service present in RouterService.js we know for sure thatRouterService
is the one needed by collection_editor. So we can now say for sure that AngularNameService.js is also required by collection_editor.Hope I haven't confused you :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then, one possible outcome of extracting these services into discrete files is a reduction in the number of imports in a page?
That was a good explanation. Thank you for clearing things up further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well yup, reduction in some pages and increase for some. I think the advantage of having separate file for each service, in terms of import would be that now each page would be including only the services really needed by it.