Skip to content

Consider what we can do to reduce complexity in template logic #127

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

Closed
benjaminapetersen opened this issue Jun 30, 2016 · 2 comments
Closed

Comments

@benjaminapetersen
Copy link
Contributor

Original comment is here: https://github.com/openshift/origin-web-console/pull/82/files#r69194937

Some of our template logic may be getting out of hand. Here is one example from browse/_deployment-details.html:

<button 
  ng-if="'deploymentconfigrollbacks' | canI : 'create'" 
  ng-show="!rollBackCollapsed && (deployment | deploymentStatus) == 'Complete' && !(deployment | deploymentIsLatest : deploymentConfig) && !deployment.metadata.deletionTimestamp" 
  ng-disabled="(deploymentConfigDeploymentsInProgress[deploymentConfigName] | hashSize) > 0" 
  type="button" 
  class="btn btn-default btn-xs" ng-click="rollBackCollapsed = !rollBackCollapsed">

The ng-show in particular has a lot of details. I think we could probably reduce this down to <button ng-show="showRollBack">Roll back</button> and use a clearly named function to set the boolean in the controller.

Thoughts @jwforres @spadgett

@jwforres
Copy link
Member

jwforres commented Jul 5, 2016

I'd say in that particular example it makes sense. It is definitely a balance, we don't want to have a million helper methods either.

@jwforres
Copy link
Member

moving forward we want to have a rule that 3 boolean clauses in an ng-if is ok if they aren't too complex, but 4 is too many

f0x11 pushed a commit to f0x11/origin-web-console that referenced this issue Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants