-
Notifications
You must be signed in to change notification settings - Fork 35
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
base: feature/app-setup
Are you sure you want to change the base?
[APPINT-1044] Update frontend and components to display info about add-ons #352
Conversation
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. |
881f4c5
to
0ef05a7
Compare
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 @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) |
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.
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 }}"> |
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.
Remove the .ng-hide
class
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.
It seems there .ng-hide
class everywhere in this file. Please remove them.
@@ -129,6 +129,8 @@ ul.dock { | |||
.menu-item { | |||
cursor: pointer; | |||
|
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.
Remove empty line
MnoeApiSvc.one('organizations', MnoeOrganizations.selectedId).one('/app_instances', instance.id).one('/setup_form').get() | ||
|
||
@submitForm = (instance, model) -> | ||
body = {} |
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.
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() |
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.
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> |
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.
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> |
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.
Use bootstrap table classes: https://getbootstrap.com/docs/3.3/css/#tables
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.
Remove corresponding LESS in app-connect-modal.less
|
||
MnoeAppInstances.getSyncs($scope.app) | ||
.then((response) -> | ||
for i in [0...response.length] |
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.
Use lodash map
app.add_on | ||
app.add_on && | ||
app.organization && | ||
app.organization.has_account_linked |
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.
This code is already present somewhere, could this be in a service?
display:block; | ||
clear:both; | ||
content:''; | ||
} |
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.
Either define a tab style globally or reuse an existing one.
d88f7e9
to
adc13a3
Compare
@alexnoox Please review. I'll rebase after to fix the conflicts |
@manu-d Please rebase your branch to fix the conflicts |
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.
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) |
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.
Shouldn't the server send an error and this error be catch
ed?
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.
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")) |
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.
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> |
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.
Missing locale
ctrl.forceSelectEntities = -> | ||
ctrl.hasChosenEntities = true | ||
|
||
ctrl.update = (entities) -> |
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.
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')}"> |
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.
For the date format, please use a format supporting user's locale.
|
||
toast { | ||
z-index: 9999; | ||
} |
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.
Move this in index.less
types: data[1] | ||
changeEntity: (model) -> | ||
$scope.loadIdMaps(model) | ||
getIndexFromValue: (value, array) -> |
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.
This could be more concise using lodash
6f23302
to
1b11694
Compare
@manu-d Please rebase this properly so we can only see only your changes. |
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.
@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) -> |
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.
Could be written on one line
) | ||
|
||
ctrl.close = -> | ||
ctrl.close() |
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.
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) |
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.
Shouldn't the error be catched in an error
callback?
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.
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"?
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.
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 |
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.
Should be in a finally
callback.
ctrl.forceSelectEntities = -> | ||
ctrl.hasChosenEntities = true | ||
|
||
ctrl.update = (entities) -> |
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.
entities
param is never used
$scope.selectHistory = -> | ||
$scope.isLeftFooterButtonShown = true | ||
$scope.selectedTab = 0 | ||
$scope.textForFooterButton = "Synchronize" |
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.
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()"> |
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.
Heading i18n
</div> | ||
</uib-tab> | ||
|
||
<uib-tab index="1" heading="Data" select="selectData()"> |
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.
Heading i18n
</div> | ||
</uib-tab> | ||
|
||
<uib-tab index="2" heading="Entities" select="selectEntities()"> |
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.
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"> |
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.
This class doesn't exist
26df9cb
to
132e984
Compare
@alexnoox |
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.
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> |
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.
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} }} </th> | ||
</tr> | ||
<tr ng-repeat="entity in $ctrl.app.addon_organization.displayable_synchronized_entities"> | ||
<td>{{entity.connec_name}} </td> |
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.
 
to remove
|
||
<table class="table-striped table-condensed" width="100%"> | ||
<tr> | ||
<th>{{"mno_enterprise.templates.components.addon_connect.entities.entity" | translate}} </th> |
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.
  to remove
<table class="table-striped table-condensed" width="100%"> | ||
<tr> | ||
<th>{{"mno_enterprise.templates.components.addon_connect.entities.entity" | translate}} </th> | ||
<th>{{"mno_enterprise.templates.components.addon_connect.entities.to_app" | translate:{ appname: $ctrl.app.app_name} }} </th> |
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.
  to remove
<tr> | ||
<th>{{"mno_enterprise.templates.components.addon_connect.entities.entity" | translate}} </th> | ||
<th>{{"mno_enterprise.templates.components.addon_connect.entities.to_app" | translate:{ appname: $ctrl.app.app_name} }} </th> | ||
<th>{{"mno_enterprise.templates.components.addon_connect.entities.to_connec" | translate:{ appname: $ctrl.app.app_name} }} </th> |
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.
  to remove
translate-values="{appname: $ctrl.app.name}"></h3> | ||
</div> | ||
|
||
|
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.
Remove double empty lines (only one)
</div> | ||
</div> | ||
|
||
|
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.
Remove double empty lines (only one)
1510f49
to
04d0f38
Compare
0ecb52b
to
716b4ee
Compare
716b4ee
to
0087383
Compare
Two main modals: