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

Linked 2 components #446

Merged
merged 29 commits into from
May 23, 2017
Merged

Linked 2 components #446

merged 29 commits into from
May 23, 2017

Conversation

pmongeau174
Copy link
Contributor

@pmongeau174 pmongeau174 commented May 4, 2017

All the rendering for the resultLink is now done by the renderUri function, just like the PrintableUri. ResultLink initiates the render instead of PrintableUri. Since PrintableUri already has a renderUri function, it is the one that is used for rendering. Need to add code to handle added options from ResultLink.
https://coveord.atlassian.net/browse/JSUI-1536

Deploy


This change is Reviewable

All the rendering for the resultLink is now done by the renderUri function, just like the PrintableUri. ResultLink initiates the render instead of PrintableUri. Since PrintableUri already has a renderUri function, it is the one that is used for rendering. Need to add code to handle added options from ResultLink.
https://coveord.atlassian.net/browse/JSUI-1536
@pmongeau174
Copy link
Contributor Author

Not sure if PrintableUri needs to implement iComponentBindings. Also not sure if it's OK to always initiate the rendering from ResultLink.

@pmongeau174 pmongeau174 self-assigned this May 4, 2017
@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 80.783% when pulling 1319916 on JSUI-1536 into f9bc600 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) to 80.79% when pulling 12c4ab5 on JSUI-1536 into f9bc600 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 80.713% when pulling 4c1bc65 on JSUI-1536 into f9bc600 on master.

This fixed the issue where a PrintableUri with the AlwaysOpenInNewWindow option set to true would open the link in a new tab AND open the link in the current tab.
https://coveord.atlassian.net/browse/JSUI-1536
results containing XML and results that don't now both use the same class for css.
https://coveord.atlassian.net/browse/JSUI-1536
@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 81.372% when pulling 5c9052e on JSUI-1536 into 5210fd2 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 81.372% when pulling 5c9052e on JSUI-1536 into 5210fd2 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 81.286% when pulling ca50bb6 on JSUI-1536 into f11678a on master.

@@ -1,21 +1,33 @@
@import "Variables";

.CoveoPrintableUri{
.CoveoPrintableUri {
justify-content:flex-start;
Copy link
Member

Choose a reason for hiding this comment

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

Use bourbon mixin.

@include justify-content(flex-start);

font-size: $font-size-smallest;
@include clickable();
padding: 0 2px 0 2px;
display: flex;
Copy link
Member

Choose a reason for hiding this comment

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

Same, use bourbon mixin.

Basically, use bourbon mixin for every "flex" rules you are using.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using bourbon mixin on every flex rule, but I noticed that the ones for the flex-box have a deprecation warning. Leave them as is or use bourbon for that too ?

.coveo-printable-uri-part {
margin: 1px;
//box-sizing: border-box;
Copy link
Member

Choose a reason for hiding this comment

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

remove comments.

overflow: hidden;
text-overflow: ellipsis;
//display:inline-block;
Copy link
Member

Choose a reason for hiding this comment

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

Comments

this.uri = result.clickUri;
let stringAndHoles: StringAndHoles;
if (result.printableUri.indexOf('\\') == -1) {
stringAndHoles = StringAndHoles.shortenUri(result.printableUri, $$(element).width() / 7);
Copy link
Member

Choose a reason for hiding this comment

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

What's the / 7 purpose here ?

I understand it was there before, and you mostly imported the old implementation, but I would like if we had an explanation for this magic number/ a comment that explains why we are dividing by 7 like that.

stringAndHoles = StringAndHoles.shortenPath(result.printableUri, $$(element).width() / 7);
}
this.shortenedUri = HighlightUtils.highlightString(stringAndHoles.value, result.printableUriHighlights, stringAndHoles.holes, 'coveo-highlight');
let link = $$('div');
Copy link
Member

Choose a reason for hiding this comment

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

for this whole component, you can replace most of the let by const. Only when you need to re-assign a variable should you need to use const. Once again, I know it was like that before, but we should always try to update/upgrade the codebase over time to use const when we can.

}
this.shortenedUri = HighlightUtils.highlightString(stringAndHoles.value, result.printableUriHighlights, stringAndHoles.holes, 'coveo-highlight');
let link = $$('div');
link.setAttribute('title', result.printableUri);
Copy link
Member

Choose a reason for hiding this comment

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

this can all be replaced with

$$('div', {
className : 'coveo-printable-uri-part',
href : result.clickUri,
title : result.printableUri
}

Copy link
Member

Choose a reason for hiding this comment

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

This has not been changed :D

It should be modified to use the short hand method, instead of setting every attribute one by one.


it('should not modify the href template if there are no field specified', () => {
let hrefTemplate = 'test';
test = Mock.optionsResultComponentSetup<PrintableUri, IResultLinkOptions>(PrintableUri, { hrefTemplate: hrefTemplate }, fakeResult);
Copy link
Member

Choose a reason for hiding this comment

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

IPrintableUriOptions

let seperator = document.createElement('span');
seperator.innerText = '>';
seperator.innerText = ' > ';
Copy link
Contributor

Choose a reason for hiding this comment

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

innerText is non-standard. You should use textContent instead.

let link = document.createElement('a');
this.bindLogOpenDocument(link);
link.href = uri;
let link = document.createElement('span');
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 create elements in a more concise way using our $$ utilty function:

const link = $$('span', { className: 'coveo-printable-uri-part' }, modifiedName);

});

it('should display the XML correctly if the result has a very long parents field', () => {
fakeResult.raw.parents = '<?xml version="1.0" encoding="utf-16"?><parents><parent name="Organization" uri="https://na17.salesforce.com/home/home.jsp" /><parent name="Technical_Article__ka" uri="http://www.salesforce.com/org:organization/articletype:Technical_Article" /><parent name="Generator became sentient and refuses to cut power" uri="https://na17.salesforce.com/kA0o00000003Wpk" /><parent name="un autre test" uri="http//:google.ca" /></parents>';
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a suggestion : you can use template strings using a backtick (`) to write multi-line strings. It makes the code look a bit better.

@@ -63,7 +63,7 @@ export function ResultLinkTest() {
expect(window.open).toHaveBeenCalledWith(hrefTemplate, jasmine.anything());
});

it('should replaces fields in the href template by the results equivalent', () => {
it('should replace fields in the href template by the results equivalent', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

It should replaces hobbitses 😛

@coveralls
Copy link

Coverage Status

Coverage increased (+1.3%) to 82.14% when pulling 103a4fe on JSUI-1536 into f11678a on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+1.3%) to 82.14% when pulling 974a5da on JSUI-1536 into f11678a on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 82.199% when pulling b09f24b on JSUI-1536 into c5b7caa on master.

@@ -17,7 +17,9 @@ export interface IPrintableUriOptions extends IResultLinkOptions {
}

/**
* The PrintableUri component displays the URI, or path, to access a result.
* The PrintableUri component inherits from the ResultLink component and supports all of its options.
Copy link
Member

Choose a reason for hiding this comment

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

We should create a link in the documentation ( {@link ResultLink} )

@fbeaudoincoveo Any comments to add on this ?

I think we should

Copy link
Contributor

Choose a reason for hiding this comment

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

I would also put back-ticks around PrintableUri (PrintableUri). And [ResultLink]{@link ResultLink} instead of just {@link ResultLink}. Otherwise, it's great :)

}
this.shortenedUri = HighlightUtils.highlightString(stringAndHoles.value, result.printableUriHighlights, stringAndHoles.holes, 'coveo-highlight');
let link = $$('div');
link.setAttribute('title', result.printableUri);
Copy link
Member

Choose a reason for hiding this comment

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

This has not been changed :D

It should be modified to use the short hand method, instead of setting every attribute one by one.

this.element.innerHTML = newTitle ? StreamHighlightUtils.highlightStreamText(newTitle, this.result.termsToHighlight, this.result.phrasesToHighlight) : this.result.clickUri;
}
}
element.title = this.result.printableUri;
}

public buildSeparator() {
let seperator = document.createElement('span');
seperator.innerText = ' > ';
const seperator = document.createElement('span');
Copy link
Member

Choose a reason for hiding this comment

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

This should use the short hand method also with $$('span', {className : 'coveo-rpintable-uri-separator'}, ' > ');

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 82.228% when pulling 734d93e on JSUI-1536 into c5b7caa on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 82.228% when pulling 734d93e on JSUI-1536 into c5b7caa on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 82.225% when pulling 21c5370 on JSUI-1536 into 742d229 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 82.225% when pulling 21c5370 on JSUI-1536 into 742d229 on master.

@pmongeau174 pmongeau174 merged commit 9a5b8eb into master May 23, 2017
@pmongeau174 pmongeau174 deleted the JSUI-1536 branch May 23, 2017 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants