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

Render SerializedReference annotations in a more userfriendly way. #1325

Merged
merged 21 commits into from
Oct 24, 2016

Conversation

rf232
Copy link
Contributor

@rf232 rf232 commented Oct 11, 2016

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.

pod

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
@rf232 rf232 changed the title 1306 creator info pod Render SerializedReference annotations in a more userfriendly way. Oct 11, 2016
@codecov-io
Copy link

codecov-io commented Oct 11, 2016

Current coverage is 93.83% (diff: 100%)

No coverage report found for master at 7a9e35a.

Powered by Codecov. Last update 7a9e35a...7dc41eb

@@ -0,0 +1,43 @@
// Copyright 2015 Google Inc. All Rights Reserved.
Copy link
Contributor

@olekzabl olekzabl Oct 11, 2016

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} */
Copy link
Contributor

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() {
Copy link
Contributor

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?

Copy link
Contributor

@olekzabl olekzabl left a 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.
@rf232
Copy link
Contributor Author

rf232 commented Oct 17, 2016

Minor rework arrived, PTAL :)

@@ -1,4 +1,4 @@
// Copyright 2015 Google Inc. All Rights Reserved.
// Copyright 201666666 Google Inc. All Rights Reserved.
Copy link
Contributor

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 {
Copy link
Contributor

@olekzabl olekzabl Oct 18, 2016

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) => {
Copy link
Contributor

@olekzabl olekzabl Oct 19, 2016

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.

Copy link
Contributor Author

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', () => {
Copy link
Contributor

@olekzabl olekzabl Oct 19, 2016

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.

Copy link
Contributor Author

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', () => {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

});

// when
ctrl.recalculateDerivedProperties();
Copy link
Contributor

@olekzabl olekzabl Oct 19, 2016

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

Copy link
Contributor

@olekzabl olekzabl left a 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.
Copy link
Contributor

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 {
Copy link
Contributor

@olekzabl olekzabl Oct 19, 2016

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?

Copy link
Contributor Author

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

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 fully understand - but you have a reason, so I'm ok with this :)

Copy link
Contributor

@olekzabl olekzabl left a 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.

@rf232
Copy link
Contributor Author

rf232 commented Oct 21, 2016

@floreks @maciaszczykm @bryk any of you want to bless this?

Copy link
Contributor

@bryk bryk left a 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">
Copy link
Contributor

Choose a reason for hiding this comment

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

We need i18n here :)

Copy link
Contributor Author

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}}
Copy link
Contributor

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?

Copy link
Contributor Author

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() {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

Copy link
Contributor

@bryk bryk left a 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">
Copy link
Contributor

Choose a reason for hiding this comment

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

s/kubernetest/kubernetes

@bryk
Copy link
Contributor

bryk commented Oct 24, 2016

LGTM, please merge when travis is happy :)

@rf232 rf232 merged commit cc43ffe into kubernetes:master Oct 24, 2016
@rf232 rf232 deleted the 1306-creatorInfoPod branch October 24, 2016 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants