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

Angular components for the Dialog Editor #55

Merged
merged 22 commits into from
Feb 2, 2017

Conversation

romanblanco
Copy link
Member

@@ -5,7 +5,7 @@
.directive('dialogEditorModalFieldTemplate', function() {
return {
templateUrl: function(tElement, tAttrs) {
return 'app/components/dialog-editor-modal-field-template/' + tAttrs.template;
return tAttrs.template;
Copy link
Member Author

Choose a reason for hiding this comment

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

Still not sure about this one, have to try if it works before removing WIP

@romanblanco romanblanco changed the title [WIP] Angular components for the Dialog Editor Angular components for the Dialog Editor Jan 11, 2017
@karelhala
Copy link
Contributor

The build is failing, because you are mixing .js files in typescript. You should rewrite any javascript file to typescript.

@mtho11
Copy link
Contributor

mtho11 commented Jan 11, 2017

@karelhala you beat me to it ;)

Steps:

  • Convert all *.js to *.ts
  • Move from common.js modules to ES6 modules
  • Move syntax from ES5 to ES6/typescript

@himdel
Copy link
Contributor

himdel commented Jan 12, 2017

@karelhala, @mtho11 I don't agree. Is there any technical reason ui-components needs to be typescript-only?

It makes sense to me to put all our shared ui components here, whether they're written in ES5, ES6 or TypeScript.

(I'm not saying this component shouldn't be typescript, if it is, even better .. but I am saying that it should not be a requirement.)

@karelhala
Copy link
Contributor

Well the biggest problem is that we don't have loader for .js files, so they are not compiled from es6 to es5 (which is reason why this particular build is failing). However this can be solved by adding babel loader alongside with eslint rules.

But does it makes sense to mix JS and TS in one project? I'd say more reasonable approach would be not to use all TS's features, but still rewriting every JS file to typescript (you don't have to create interfaces, use types or whatever, just replace IIF with export class and leave the rest as is). To be honest, I'd prefer going either full babel with ES6, or Typescript. But mixing these two together feels, like we could not decide what to use so we used both of them.

I understand that it's easier to take already functioning component and just use it here, it sure is faster than rewriting whole thing over and over again. So what about we put babel loader to webpack and allow using JS files in build process (whether they are written in ES6 or 5) and when such component is introduced we create new issue which states that and when somebody has a bit of spare time he will rewrite such component to typescript. So we have more consistent code base.

@romanblanco romanblanco changed the title Angular components for the Dialog Editor [WIP] Angular components for the Dialog Editor Jan 12, 2017
@mtho11
Copy link
Contributor

mtho11 commented Jan 12, 2017

What about not adding the babel loader and just keeping everything *.ts and just replacing the IFFE blocks with export class like @karelhala says above. The typescript compiler should handle both ES5 and ES6 syntax, but this way we are not complicating the webpack build and not totally opening the gate to ES5 whatever. I guess this is my endorsement for what @karelhala said above 🥇

@himdel
Copy link
Contributor

himdel commented Jan 12, 2017

Well, I guess the difference is that I'm thinking of this as a bag for reusable components, not a library with a consistent style and language.. So in my mind, we should support all the options.

That said, @romanblanco seems OK with updating the PR to something typescript-like, so I guess we don't have to have that discussion here and now.

But just to be clear about this, TS is not able to handle ES6 syntax. let foo = {}; foo.bar = 5; .. see if it works :).

@mtho11
Copy link
Contributor

mtho11 commented Jan 12, 2017

@himdel It does if you play with implicit any stuff. There are compiler settings for this. But you can also just do: let foo:any = {}; foo.bar = 5; and that works.

I just tried it in: http://www.typescriptlang.org/play/

@romanblanco romanblanco force-pushed the dialog_editor branch 5 times, most recently from d7ebb61 to cb6d9a4 Compare January 19, 2017 21:35
@romanblanco romanblanco changed the title [WIP] Angular components for the Dialog Editor Angular components for the Dialog Editor Jan 20, 2017
@romanblanco romanblanco force-pushed the dialog_editor branch 2 times, most recently from 2fe4fa5 to b331c5d Compare January 20, 2017 12:57
@karelhala
Copy link
Contributor

@romanblanco you do not need to add 3rd party libraries to your index.ts via require just make sure they will be loaded in application which will use your module. If you'd were to require them, they'd become part of our library and we'd have to take care of them (hence the drop in coveralls).

@romanblanco
Copy link
Member Author

@karelhala Thanks, I've just removed them :)

@@ -21,6 +21,9 @@
"node": ">= 6.0.0",
"npm": ">= 3.8.1"
},
"files": [
"dist/js/ui-components.js"
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess you don't want this .. if I'm reading the docs correctly, this would limit the npm package to just that one file

);
// load categories from API, if the field is Tag Control
if (this.modalData.type === 'DialogFieldTagControl') {
this.resolveCategories(this.CollectionsApi).then(function(categories: any) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this.resolveCategories() - resolveCategories doesn't seem to take any arguments

@romanblanco romanblanco force-pushed the dialog_editor branch 2 times, most recently from 3c2e62f to 1e24e56 Compare January 20, 2017 18:01
@romanblanco
Copy link
Member Author

@dtaylor113 This PR is now ready, you can do your changes based on this

@romanblanco romanblanco force-pushed the dialog_editor branch 3 times, most recently from 2f36163 to e00615c Compare January 25, 2017 16:03
@karelhala
Copy link
Contributor

@romanblanco found the problem why build started to fail. Looks like Webpack 1 ignored any error and exits every time with 0, even tho some build errors occurred. However webpack 2 is coded better (for us, worse) and does not ignore build errors. However we can force him to ignore these errors, just go to package.json and add webpack || true to prepublish. It's an ugly sollution but it works and we can merge this PR and work on webpack/typescript settings in seperate PR.

...
 "scripts": {
    "start": "webpack --watch",
    "test": "karma start",
    "prepublish": "webpack || true",
    "build": "webpack --config webpack.vendor.config.js && webpack -p",
    "install-vendor": "webpack --config webpack.vendor.config.js",
    "build-docs": "jsdoc -c jsdoc-conf.json"
 },
...

@romanblanco
Copy link
Member Author

Thank you, @karelhala!

@himdel
Copy link
Contributor

himdel commented Feb 2, 2017

Merging, will release a new version together with #58.

The problem with not being able to see the DialogEditor service has something to do with yarn and branches, installing via npm worked just fine.

@himdel himdel added this to the Sprint 54 Ending Feb 13, 2017 milestone Feb 2, 2017
@himdel himdel merged commit 41d4ad7 into ManageIQ:master Feb 2, 2017
@mtho11
Copy link
Contributor

mtho11 commented Feb 2, 2017

@himdel What exactly is the issue with yarn and branches?

@himdel
Copy link
Contributor

himdel commented Feb 2, 2017

@mtho11 no idea about the exact issue, but have a read in ManageIQ/manageiq-ui-service#478 :).

As it is now (with "manageiq-ui-components": "romanblanco/ui-components#dialog_editor" in package.json), it would install a version where dist/js/ui-components.js did not include the substring miqStaticAssets.dialogEditor at all :).

EDIT: possibly fixed in yarn-0.19.1, not sure, 0.16.1 is definitely affected

@himdel
Copy link
Contributor

himdel commented Feb 2, 2017

Released 0.0.12

@romanblanco romanblanco deleted the dialog_editor branch February 7, 2017 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants