-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Render SerializedReference annotations in a more userfriendly way. #1325
Conversation
Some rendering errors and perhaps not the most beautiful code, but hey it works.
Somewhere during the coding there existed an actual AnnotationsController that derived from LabelsController, but in the end it had no own logic, so just reuse the LabelsController
Current coverage is 93.83% (diff: 100%)
|
@@ -0,0 +1,43 @@ | |||
// Copyright 2015 Google Inc. All Rights Reserved. |
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.
Since you explained to me that this is a copy of another CSS file (with some changes), I'd prefer to avoid copying that much (for easier maintenance of changes in the future), use the original CSS in your new template, and restrict this CSS file only to the real changes. But these are only my feelings, ignore them if yours are different.
/** @export {string} */ | ||
this.reference; | ||
|
||
/** {!ui.router.$state} */ |
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.
Is this annotation valid? (So far, I've only seen ones with "@Private")
$scope.$watch(() => this.reference, () => this.recalculateDerivedProperties()); | ||
} | ||
|
||
recalculateDerivedProperties() { |
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 you add a comment?
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.
Minor comments arrived, PTAL
Made a overarching set of class names for the currently used styles in labels and annotations, name refers back to the md-chip origin of the visual design of them.
Minor rework arrived, PTAL :) |
@@ -1,4 +1,4 @@ | |||
// Copyright 2015 Google Inc. All Rights Reserved. | |||
// Copyright 201666666 Google Inc. All Rights Reserved. |
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's great to plan for such a long period ;)
display: block; | ||
padding: ($baseline-grid / 4) $baseline-grid; | ||
} | ||
|
||
kd-annotations { |
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.
Just curiousity: why is this CSS out of unification?
// then | ||
let labels = element.find('kd-middle-ellipsis'); | ||
expect(labels.length).toEqual(3); | ||
angular.forEach((key, value, index) => { |
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 first argument? (What are you iterating over?)
Same in 1 place below.
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.
hmm, I stole that snippet from the label_directive tests, lets see if those are broken too :)
expect(labels.eq(index).text()).toBe(`${key}=${value}`); | ||
}); | ||
}); | ||
it('should render 1 annotation of created-by kind as serialized reference', () => { |
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.
Separate "it"s by a newline.
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.
ack
expect(ctrl.valid).toBe(false); | ||
expect(ctrl.state_.href).not.toHaveBeenCalled(); | ||
}); | ||
it('should set the state to invalid on a non SerializedReference object', () => { |
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.
Separate "it"s by a newline.
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.
ack
}); | ||
|
||
// when | ||
ctrl.recalculateDerivedProperties(); |
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.
Won't "scope.$digest()" have the same effect?
If it will, I'd prefer to call "scope.$digest()", as it shows more clearly that you're testing what will happen anyway, without further interactions with the component.
(Same in 2 places below).
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.
ack
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.
A few more comments.
@@ -0,0 +1,20 @@ | |||
// Copyright 201666666 Google Inc. All Rights Reserved. |
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's good to plan for such a long time :)
display: block; | ||
padding: ($baseline-grid / 4) $baseline-grid; | ||
} | ||
|
||
kd-labels { |
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.
Just out of curiosity: why does this not participate in the unification?
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.
because this is the element name and not a class name that i could unify. perhaps I could add this to a class and apply class to both. Not sure if that is worth it though
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 fully understand - but you have a reason, so I'm ok with this :)
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.
Sorry, I'm still often fooled by those tools.
I've had two more comments which apparently disappeared, so I'm sending them once again.
@floreks @maciaszczykm @bryk any of you want to bless this? |
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.
Look and feel is great! :) A few cosmetic comments on coding practices.
ng-if="annotationsCtrl.isVisible($index)" class="kd-chips"> | ||
<div ng-switch on="key"> | ||
<div ng-switch-when="kubernetes.io/created-by" class="kd-chip"> | ||
Created by: <kd-serialized-reference reference="value"> |
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 need i18n here :)
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.
ack
<div class="kd-chips kd-chips-switch" ng-show="annotationsCtrl.isMoreAvailable()" | ||
ng-click="annotationsCtrl.switchLabelsView()"> | ||
{{annotationsCtrl.isShowingAll() ? | ||
annotationsCtrl.i18n.MSG_LABELS_SHOW_LESS_TOOLTIP : annotationsCtrl.i18n.MSG_LABELS_SHOW_ALL_TOOLTIP}} |
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 we use the new i18n here?
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.
okey
* | ||
* @return {!angular.Directive} | ||
*/ | ||
export default function serializedReferenceDirective() { |
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 you make this a component? This has been our standard practice so far. Everything is a component, unless it uses some of the directive features.
There are examples in the codebase to inspire on. Basically, you turn this into an object instead of a function returning an object. Delete some lines and change referencectrl to $ctrl
.
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.
ack
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.
Last trivial comment and let's merge! :)
@@ -19,7 +19,7 @@ | |||
ng-if="annotationsCtrl.isVisible($index)" class="kd-chips"> | |||
<div ng-switch on="key"> | |||
<div ng-switch-when="kubernetes.io/created-by" class="kd-chip"> | |||
Created by: <kd-serialized-reference reference="value"> | |||
[[Created by:|Friendly name of the kubernetest.io/created-by annotation]] <kd-serialized-reference reference="value"> |
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.
s/kubernetest/kubernetes
LGTM, please merge when travis is happy :) |
dropping my i18n messages for easier resolution
Render SerializedReference annotations in a more userfriendly way.
part of #1306, this one just makes the SerializedReference annotations into links to the referenced object
see the attachment for a preview of how this looks.