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/ace_editor #282

Merged
merged 19 commits into from
May 10, 2018
Merged

Feature/ace_editor #282

merged 19 commits into from
May 10, 2018

Conversation

agduncan94
Copy link
Contributor

@agduncan94 agduncan94 commented May 9, 2018

Adds Ace Editor for viewing files
-built in search, line numbers, themes
-will be very useful for hosted entry editing
-wrapped in a component so it can be added anywhere on the site
-lots of other extra features, such as custom shortcuts, autocomplete, code generation, etc

Also

  • Adds new command line reporter for karma tests that is similar to Cypress (for spec tests)
  • Completely removes highlight JS 🎉
  • New highlighting with ace is based off of Github Linquist "Official" grammars, can be fairly easily converted

For converting grammars:
https://wiki.oicr.on.ca/display/DOC/Dockstore+Primer#DockstorePrimer-CustomGrammars

@agduncan94 agduncan94 self-assigned this May 9, 2018
@agduncan94 agduncan94 requested review from denis-yuen and garyluu May 9, 2018 17:45
Copy link
Member

@denis-yuen denis-yuen left a comment

Choose a reason for hiding this comment

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

Seems satisfying.
Might want to also add some docs to the readme for how to generate the grammars from the original source repos. (Or a link to that documentation if it is in the primer)

} else if (filepath.endsWith('json')) {
this.mode = 'json';
} else {
this.mode = 'yaml';
Copy link
Member

Choose a reason for hiding this comment

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

Maybe look for *.yml or *.yaml for 'yaml'
Otherwise default to text might make more sense
(Consider CWL workflows which I've seen include JS files for example)

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'll make the changes for yaml and text. As for CWL including JS files, you can define sub grammars based on existing grammars. This would be a good future task.

Copy link
Member

Choose a reason for hiding this comment

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

I'm actually thinking about workflows that include js files outright
https://dockstore.org/workflows/github.com/ICGC-TCGA-PanCancer/pcawg-oxog-filter

<section [innerHTML]="fileService.highlightCode(content)"></section>
</div>
<div [hidden]="!content || !_selectedVersion?.valid">
<app-code-editor [(content)]="content" [filepath]="getFilePath(currentFile)"></app-code-editor>
Copy link
Contributor

Choose a reason for hiding this comment

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

check number of times getFilePath() is executed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya for some reason for some components we had the filepath as a variable but for others we used this. I was introducing a new dependency in this PR so I didn't want to change anything like that that may introduce some bugs while developing.

styleUrls: ['./code-editor.component.scss']
})
export class CodeEditorComponent implements AfterViewInit {
_content: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

https://angular.io/guide/styleguide#style-03-04

Avoid prefixing private properties and methods with an underscore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's strange this comes straight from an example on the angular site for sharing between parent and child containers 🤔


@Input() set content(content: string) {
this._content = content;
if (this.editor !== undefined && content !== undefined && content !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

content !== undefined && content !== null can probably be replaced with content the other non-truthy values don't apply to strings.

editor: any;
mode = 'yaml';
_filepath: string;
aceId: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could use a comment on what aceId is and why it's a random number

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just in case we have multiple on the same screen.

<section [innerHTML]="fileService.highlightCode(content)"></section>
</div>
<div [hidden]="!content || !_selectedVersion?.valid">
<app-code-editor [(content)]="content" [filepath]="getFilePath(currentFile)"></app-code-editor>
Copy link
Contributor

Choose a reason for hiding this comment

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

Here too

@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AfterViewChecked, Component, ElementRef, Input } from '@angular/core';
import { AfterViewChecked, Component, Input } from '@angular/core';
Copy link
Contributor

Choose a reason for hiding this comment

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

AfterViewChecked unused import

@codecov-io
Copy link

codecov-io commented May 9, 2018

Codecov Report

Merging #282 into develop will increase coverage by 0.07%.
The diff coverage is 67.39%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #282      +/-   ##
===========================================
+ Coverage    63.29%   63.37%   +0.07%     
===========================================
  Files          120      122       +2     
  Lines         3621     3664      +43     
  Branches       399      405       +6     
===========================================
+ Hits          2292     2322      +30     
- Misses        1236     1252      +16     
+ Partials        93       90       -3
Impacted Files Coverage Δ
src/app/shared/selectors/entry-file-selector.ts 53.84% <ø> (-1.71%) ⬇️
src/app/shared/dockstore.service.ts 87.5% <ø> (-0.5%) ⬇️
src/app/shared/file.service.ts 30% <ø> (-1.25%) ⬇️
...c/app/container/dockerfile/dockerfile.component.ts 55.88% <100%> (+1.12%) ⬆️
.../app/workflow/descriptors/descriptors.component.ts 72.41% <100%> (+4.84%) ⬆️
...app/container/descriptors/descriptors.component.ts 80% <100%> (+6.31%) ⬆️
...rc/app/shared/code-editor/code-editor.component.ts 38.88% <38.88%> (ø)
...rc/app/workflow/paramfiles/paramfiles.component.ts 71.42% <66.66%> (+2.85%) ⬆️
src/app/shared/grammars/custom-grammars.js 83.72% <83.72%> (ø)
... and 1 more

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 ea98438...eebf5ae. Read the comment docs.

@agduncan94
Copy link
Contributor Author

@garyluu The changes have been made.

}

/**
* Changes the mode of the editor based on the filepath, fallback is text modew
Copy link
Contributor

Choose a reason for hiding this comment

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

small typo

@agduncan94 agduncan94 merged commit a31f346 into develop May 10, 2018
@agduncan94 agduncan94 deleted the feature/codemirror_trial branch May 10, 2018 14:42
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