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

[APPINT-1044] Update frontend and components to display info about add-ons #352

Open
wants to merge 25 commits into
base: feature/app-setup
Choose a base branch
from

Conversation

manu-d
Copy link

@manu-d manu-d commented Oct 4, 2017

Two main modals:

  • Added app-connect-modal-cloud
  • Updated app-settings-modal

@manu-d manu-d requested a review from alexnoox October 4, 2017 15:39
@manu-d
Copy link
Author

manu-d commented Oct 4, 2017

For the app-settings-modal, you can just look at the coffee controller for the moment. The html and css need to be completely rewritten.

@manu-d manu-d force-pushed the feature/application-setup branch from 881f4c5 to 0ef05a7 Compare October 4, 2017 15:47
Copy link
Contributor

@alexnoox alexnoox left a comment

Choose a reason for hiding this comment

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

Hi @manu-d,

Please see my comments. I will do another review later to see if we can avoid code duplication using components.

TODO:

  • I18n all the texts

instance.stack == 'connector' &&
!instance.oauth_keys_valid
(instance.app_nid != 'office-365' && instance.stack == 'connector' && !instance.oauth_keys_valid) ||
(instance.add_on && instance.organization && !instance.organization.has_account_linked)
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 reuse $scope.helper.isCreateAccountShown

@@ -9,10 +9,13 @@
<div class="dock-arrow"><i class="fa fa-chevron-up"></i></div>
<div class="inner-dock-menu">
<!-- EO Connectors Buttons -->
<div class="menu-item ng-hide" ng-show="helper.isCreateAccountShown(app)" uib-tooltip="{{ 'mno_enterprise.templates.components.app_install_btn.create_account_tooltip' | translate }}">
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the .ng-hide class

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems there .ng-hide class everywhere in this file. Please remove them.

@@ -129,6 +129,8 @@ ul.dock {
.menu-item {
cursor: pointer;

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove empty line

MnoeApiSvc.one('organizations', MnoeOrganizations.selectedId).one('/app_instances', instance.id).one('/setup_form').get()

@submitForm = (instance, model) ->
body = {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use data instead of body

MnoeApiSvc.one('organizations', MnoeOrganizations.selectedId).one('/app_instances', instance.id).post('/create_omniauth', body)

@getSyncs = (instance) ->
MnoeApiSvc.one('organizations', MnoeOrganizations.selectedId).one('/app_instances', instance.id).one('/sync_history').get()
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use one without id parameter. You should use customGET or doGET.
cf. https://github.com/mgonto/restangular#custom-methods


<button class="btn btn-success" ng-click="synchronize(historicalData)" style="float: right;">Start synchronizing</button>

<div style="clear: both;"></div>
Copy link
Contributor

Choose a reason for hiding this comment

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

You can directly apply a clearfix class.

See how to use it here: https://getbootstrap.com/docs/3.3/css/#helper-classes-clearfix

<div class="modal-body">
<h4 class="text-center">Chose which entities you want to synchronize</h4>

<table>
Copy link
Contributor

Choose a reason for hiding this comment

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

Use bootstrap table classes: https://getbootstrap.com/docs/3.3/css/#tables

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove corresponding LESS in app-connect-modal.less


MnoeAppInstances.getSyncs($scope.app)
.then((response) ->
for i in [0...response.length]
Copy link
Contributor

Choose a reason for hiding this comment

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

Use lodash map

app.add_on
app.add_on &&
app.organization &&
app.organization.has_account_linked
Copy link
Contributor

Choose a reason for hiding this comment

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

This code is already present somewhere, could this be in a service?

display:block;
clear:both;
content:'';
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Either define a tab style globally or reuse an existing one.

@manu-d manu-d force-pushed the feature/application-setup branch from d88f7e9 to adc13a3 Compare October 25, 2017 16:45
@manu-d
Copy link
Author

manu-d commented Nov 2, 2017

@alexnoox Please review. I'll rebase after to fix the conflicts

@alexnoox
Copy link
Contributor

alexnoox commented Nov 6, 2017

@manu-d Please rebase your branch to fix the conflicts

Copy link
Contributor

@alexnoox alexnoox left a comment

Choose a reason for hiding this comment

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

This is generally good. Just a few comments and remarks:

  • Make sure that all the locales are using a key
  • There is a typo in filename connec-addon-modal.coffee, it is missing a t in connect

MnoeAppInstances.submitForm(ctrl.app, ctrl.model)
.then((response) ->
if response.error
toastr.error(response.error)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the server send an error and this error be catched?

Copy link
Author

Choose a reason for hiding this comment

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

We have some validation on the connector side when a user wants to link their account.
For example, only one account can be linked, or sometimes, we know of some kind of common mistake people make. And so, for each of these situations, we have a custom error message that I returned in the response.
Should I change the json key from the response "error" to something like "linking_error"?

MnoeAppInstances.sync(ctrl.app, ctrl.historicalData)
ctrl.app.addon_organization.sync_enabled = true
ctrl.close()
toastr.success($filter('translate')("mno_enterprise.templates.components.addon_connect.sync.sync_launched"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of calling the filter in the controller, you should use the $translate service. Call it once at the initialisation to fetch all the locales, and then use the returned array to get the locale.

https://angular-translate.github.io/docs/#/api/pascalprecht.translate.$translate

</ul>

<div class="modal-body">
<h4 class="text-center">Chose wether to synchronize historical data</h4>
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing locale

ctrl.forceSelectEntities = ->
ctrl.hasChosenEntities = true

ctrl.update = (entities) ->
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need to pass the entities parameter. It is never used.

<p translate="mno_enterprise.templates.components.addon_connect.sync.warning_hisorical_html" translate-values="{appname: $ctrl.app.name}"></p>
<input ng-model="$ctrl.historicalData" type="checkbox" display=inline-block></input>
<small ng-show="!$ctrl.historicalData"
translate="mno_enterprise.templates.components.addon_connect.sync.historical_unchecked" translate-values="{date: ($ctrl.date | amDateFormat:'dddd, MMMM Do YYYY, h:mm:ss a')}">
Copy link
Contributor

Choose a reason for hiding this comment

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

For the date format, please use a format supporting user's locale.

Cf.http://momentjs.com/
screen shot 2017-11-06 at 2 54 45 pm


toast {
z-index: 9999;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this in index.less

types: data[1]
changeEntity: (model) ->
$scope.loadIdMaps(model)
getIndexFromValue: (value, array) ->
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be more concise using lodash

@alexnoox
Copy link
Contributor

@manu-d Please rebase this properly so we can only see only your changes.

Copy link
Contributor

@alexnoox alexnoox left a comment

Choose a reason for hiding this comment

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

@manu-d I did another review, a bit more granular. The code and logic are good generally.

Please see my comments and:

  • Write your then promise callbacks on one line
  • Please make sure everything supports i18n (especially in the tables)
  • Do not manage the buttons rendering in the controller, prefer using logic in the template

ctrl.app = ctrl.resolve.app
ctrl.hasLinked = ctrl.app.addon_organization.has_account_linked
MnoeAppInstances.getForm(ctrl.app)
.then((response) ->
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be written on one line

)

ctrl.close = ->
ctrl.close()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't you just use $ctrl.close() in the template?
This is a bit redundant.

MnoeAppInstances.submitForm(ctrl.app, ctrl.model)
.then((response) ->
if response.error
toastr.error(response.error)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the error be catched in an error callback?

Copy link
Author

Choose a reason for hiding this comment

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

We have some validation on the connector side when a user wants to link their account.
For example, only one account can be linked, or sometimes, we know of some kind of common mistake people make. And so, for each of these situations, we have a custom error message that I returned in the response.
Should I change the json key from the response "error" to something like "linking_error"?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that would be great. This is a bit confusing and alarming. linking_error sounds more like a specific error.

else
ctrl.app.addon_organization.has_account_linked = true
ctrl.hasLinked = true
ctrl.isSubmitting = false
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be in a finally callback.

ctrl.forceSelectEntities = ->
ctrl.hasChosenEntities = true

ctrl.update = (entities) ->
Copy link
Contributor

Choose a reason for hiding this comment

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

entities param is never used

$scope.selectHistory = ->
$scope.isLeftFooterButtonShown = true
$scope.selectedTab = 0
$scope.textForFooterButton = "Synchronize"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a rendering problematic. This should be in the template, using ng-show on buttons.

@@ -16,7 +16,54 @@
<!-- Add on settings -->
<div ng-show="helper.isAddOnSettingShown(app)">
<hr>
<button ng-click="helper.addOnSettingLauch(app)" class="btn btn-warning">{{ 'mno_enterprise.templates.impac.dock.settings.access_add-on_settings' | translate }}</button>
<uib-tabset active="activeJustified" justified="true">
<uib-tab index="0" heading="History" ng-click="loadSyncs()" select="selectHistory()">
Copy link
Contributor

Choose a reason for hiding this comment

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

Heading i18n

</div>
</uib-tab>

<uib-tab index="1" heading="Data" select="selectData()">
Copy link
Contributor

Choose a reason for hiding this comment

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

Heading i18n

</div>
</uib-tab>

<uib-tab index="2" heading="Entities" select="selectEntities()">
Copy link
Contributor

Choose a reason for hiding this comment

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

Heading i18n

@@ -50,7 +97,19 @@
<!-- Deletion -->
<hr>
<div ng-show="helper.canDeleteApp()" class="app-deletion">
<button class="btn btn-danger" ng-hide="app.showDelete" ng-click="app.showDelete = !app.showDelete">{{ 'mno_enterprise.templates.impac.dock.settings.delete' | translate }}</button>
<div class="col-xs-13">
Copy link
Contributor

Choose a reason for hiding this comment

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

This class doesn't exist

@manu-d manu-d force-pushed the feature/application-setup branch from 26df9cb to 132e984 Compare November 14, 2017 17:14
@manu-d
Copy link
Author

manu-d commented Nov 15, 2017

@alexnoox
I18ned and rework the rendering problems. (It's true that it's much more readable like that ^^)

Copy link
Contributor

@alexnoox alexnoox left a comment

Choose a reason for hiding this comment

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

We are getting there 👍

Only a few remarks.


<li ng-switch-when="true|1|2" ng-switch-when-separator="|"><a href="#" class="not-active">{{"mno_enterprise.templates.components.addon_connect.link_account.title" | translate}}</a></li>
<li ng-switch-when="true|1" ng-switch-when-separator="|">{{"mno_enterprise.templates.components.addon_connect.entities.select" | translate}}</li>
<li ng-switch-when="true|1" ng-switch-when-separator="|"><a href="#" ng-click="$ctrl.forceSelectEntities()">{{"mno_enterprise.templates.components.addon_connect.sync.start_sync" | translate}}</a></li>
Copy link
Contributor

Choose a reason for hiding this comment

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

In the ng-switch-when, could you only use numbers?

<th>{{"mno_enterprise.templates.components.addon_connect.entities.to_connec" | translate:{ appname: $ctrl.app.app_name} }}&nbsp</th>
</tr>
<tr ng-repeat="entity in $ctrl.app.addon_organization.displayable_synchronized_entities">
<td>{{entity.connec_name}}&nbsp</td>
Copy link
Contributor

Choose a reason for hiding this comment

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

&nbsp to remove


<table class="table-striped table-condensed" width="100%">
<tr>
<th>{{"mno_enterprise.templates.components.addon_connect.entities.entity" | translate}}&nbsp</th>
Copy link
Contributor

Choose a reason for hiding this comment

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

&nbsp to remove

<table class="table-striped table-condensed" width="100%">
<tr>
<th>{{"mno_enterprise.templates.components.addon_connect.entities.entity" | translate}}&nbsp</th>
<th>{{"mno_enterprise.templates.components.addon_connect.entities.to_app" | translate:{ appname: $ctrl.app.app_name} }}&nbsp</th>
Copy link
Contributor

Choose a reason for hiding this comment

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

&nbsp to remove

<tr>
<th>{{"mno_enterprise.templates.components.addon_connect.entities.entity" | translate}}&nbsp</th>
<th>{{"mno_enterprise.templates.components.addon_connect.entities.to_app" | translate:{ appname: $ctrl.app.app_name} }}&nbsp</th>
<th>{{"mno_enterprise.templates.components.addon_connect.entities.to_connec" | translate:{ appname: $ctrl.app.app_name} }}&nbsp</th>
Copy link
Contributor

Choose a reason for hiding this comment

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

&nbsp to remove

translate-values="{appname: $ctrl.app.name}"></h3>
</div>


Copy link
Contributor

Choose a reason for hiding this comment

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

Remove double empty lines (only one)

</div>
</div>


Copy link
Contributor

Choose a reason for hiding this comment

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

Remove double empty lines (only one)

@manu-d manu-d force-pushed the feature/application-setup branch from 1510f49 to 04d0f38 Compare November 22, 2017 10:03
@manu-d manu-d force-pushed the feature/application-setup branch from 0ecb52b to 716b4ee Compare February 5, 2018 17:38
@manu-d manu-d force-pushed the feature/application-setup branch from 716b4ee to 0087383 Compare June 4, 2018 15:38
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.

2 participants