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

Add DocView links pluggable injection capability #1200

Merged

Conversation

RoyiSitbon
Copy link
Contributor

Signed-off-by: sitbubu [email protected]

Description

Currently, we don't have an option to assimilate links under our top doc view section.
The “view surrounding documents” and “view single document” were written as static content.
We would like to make the top right side under doc view to be pluggable,
in order to assimilate new abilities such as “open in new tab icons” etc.

Before:
injections1

After:
injections2

Additional info under linked issue:
#1199

@RoyiSitbon RoyiSitbon requested a review from a team as a code owner February 2, 2022 09:54
@kavilla kavilla linked an issue Feb 3, 2022 that may be closed by this pull request
@RoyiSitbon RoyiSitbon force-pushed the AddDocViewPlugableLinkInjection branch from 57d308f to 944f7c3 Compare February 16, 2022 08:01
@RoyiSitbon RoyiSitbon requested a review from kavilla February 18, 2022 14:00
@RoyiSitbon RoyiSitbon force-pushed the AddDocViewPlugableLinkInjection branch 2 times, most recently from 56bd0e7 to 9f0c57b Compare February 19, 2022 15:43
@ashwin-pc
Copy link
Member

Nice PR. I just had one question. In your Before and After images, there is an "open in new tab" icon (EUI popout icon). The EuiListGroup element can show icons but your PR doesn't seem to use that. How have you achieved that?

@RoyiSitbon
Copy link
Contributor Author

Nice PR. I just had one question. In your Before and After images, there is an "open in new tab" icon (EUI popout icon). The EuiListGroup element can show icons but your PR doesn't seem to use that. How have you achieved that?

Hey, thanks for replying. It was an example, basically, you can set any icon you want. e.g:
Screen Shot 2022-02-22 at 10 22 39
Screen Shot 2022-02-22 at 10 22 24

@ashwin-pc
Copy link
Member

Hey, thanks for replying. It was an example, basically, you can set any icon you want.

Oh right, I missed the how you were extending EuiListGroupItemProps. This looks good to me 👍 . It looks like your PR is breaking some functional tests in discover though.

@RoyiSitbon
Copy link
Contributor Author

Hey, thanks for replying. It was an example, basically, you can set any icon you want.

Oh right, I missed the how you were extending EuiListGroupItemProps. This looks good to me 👍 . It looks like your PR is breaking some functional tests in discover though.

Thanks, added a small fix.
Hopefully, all will pass as expected now.

Comment on lines 16 to 19
if (item.generateurlcb) {
item.href = item.generateurlcb(renderProps);
delete item.generateurlcb;
}
Copy link
Member

Choose a reason for hiding this comment

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

Sorry i didnt catch this earlier but we should avoid mutating the docViewLink object directly. We can return a new object instead e.g.

.map((item) => {
  const { generateurlcb, href, ...props } = item;
  const listItem: EuiListGroupItemProps = {
    ...props,
    href: generateurlcb ? generateurlcb(renderProps) : href,
  }

  return listItem;
}

This way we also ensure that the new object has only the props that the EuiListGroup component accepts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

amazing, thanks

@@ -10,7 +10,7 @@ import { IndexPattern } from '../../../../data/public';
export interface DocViewLink extends EuiListGroupItemProps {
href?: string;
order: number;
generateurlfn?(renderProps: any): string;
generateurlcb?(renderProps: any): string;
Copy link
Member

Choose a reason for hiding this comment

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

Any reason this property isn't camel cased?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, changed.

@RoyiSitbon RoyiSitbon force-pushed the AddDocViewPlugableLinkInjection branch from 6b62b70 to 7a25121 Compare February 22, 2022 12:24
@RoyiSitbon RoyiSitbon requested a review from ashwin-pc February 22, 2022 13:25
@RoyiSitbon RoyiSitbon force-pushed the AddDocViewPlugableLinkInjection branch from 71712a3 to b77de09 Compare March 1, 2022 06:49
@RoyiSitbon
Copy link
Contributor Author

@ashwin-pc , it passed all the tests. Thanks

ashwin-pc
ashwin-pc previously approved these changes Mar 2, 2022
Copy link
Member

@ashwin-pc ashwin-pc left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes. This looks good to me

@kavilla
Copy link
Member

kavilla commented Mar 3, 2022

@RoyiSitbon, can you run yarn test:jest -u and push the snapshot update?

@RoyiSitbon
Copy link
Contributor Author

@RoyiSitbon, can you run yarn test:jest -u and push the snapshot update?

done :)

@RoyiSitbon RoyiSitbon requested a review from ashwin-pc March 3, 2022 20:50
@kavilla kavilla added the v1.3.0 label Mar 4, 2022
ashwin-pc
ashwin-pc previously approved these changes Mar 4, 2022
Copy link
Member

@ashwin-pc ashwin-pc left a comment

Choose a reason for hiding this comment

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

Thanks for that, LGTM

@@ -0,0 +1,21 @@
.osdDocViewerLinks {
Copy link
Member

@kavilla kavilla Mar 4, 2022

Choose a reason for hiding this comment

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

I guess we don't lint scss files? I wonder if we broke something with the linter or perhaps we need to add it to the linter file.

In the meantime, I see most of our scss files are two space indented and I think some of the indention could use some loving.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

data-test-subj="docTableRowAction"
ng-href="{{ getContextAppHref() }}"
ng-if="indexPattern.isTimeBased()"
i18n-id="discover.docTable.tableRow.viewSurroundingDocumentsLinkText"
Copy link
Member

Choose a reason for hiding this comment

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

Is there a way to utilize i18n within the updated component once we have i18n translations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, added.

class="euiLink"
data-test-subj="docTableRowAction"
ng-href="{{ getContextAppHref() }}"
ng-if="indexPattern.isTimeBased()"
Copy link
Member

Choose a reason for hiding this comment

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

I'm not seeing this logic in the src/plugins/discover/public/plugin.ts, could we include that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@kavilla
Copy link
Member

kavilla commented Mar 4, 2022

I think this is an awesome change! I have some comments, I'm also wondering where can include some of this information of how to access this functionality as a plugin as it's not really called out anywhere. Perhaps we can tack on this information on this issue: opensearch-project/documentation-website#171?

@kavilla
Copy link
Member

kavilla commented Mar 7, 2022

@RoyiSitbon, apologies we were targeting to get this into the release for 1.3.0 but as pens down was last week Friday [issue]. We will target this for the next release.

Again, sorry about the inconvenience but thank you for the awesome changes!

@kavilla kavilla removed the v1.3.0 label Mar 7, 2022
Copy link
Member

@kavilla kavilla left a comment

Choose a reason for hiding this comment

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

PR was updated with main.

Re-approving. This looks good to me @tmarkley, @ashwin-pc, have any objections? I think we can target for 2.2 as well.

Copy link
Member

@ananzh ananzh left a comment

Choose a reason for hiding this comment

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

LGTM 💚
Thanks for converting part of the detail view to react component, registering it and fixing the link

@RoyiSitbon
Copy link
Contributor Author

💚

💚

@kavilla kavilla merged commit c33bf8c into opensearch-project:main Jul 13, 2022
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jul 13, 2022
* Add DocView links pluggable injection capability
* Add proper e2e + bugfix
* set prop as lower case
* Better name
* Delete prop after usage
* Camel case + avoid mutating
* Added right data-test-subj in order to fix tests
* update snapshot
* Add hide prop in order to mimic ng-if condition
* Add i18n translation support
* Fix tests
* Made text smaller + used eui components instead of custom css
* Snapshots

Signed-off-by: sitbubu <[email protected]>
(cherry picked from commit c33bf8c)
kavilla pushed a commit that referenced this pull request Jul 13, 2022
* Add DocView links pluggable injection capability
* Add proper e2e + bugfix
* set prop as lower case
* Better name
* Delete prop after usage
* Camel case + avoid mutating
* Added right data-test-subj in order to fix tests
* update snapshot
* Add hide prop in order to mimic ng-if condition
* Add i18n translation support
* Fix tests
* Made text smaller + used eui components instead of custom css
* Snapshots

Signed-off-by: sitbubu <[email protected]>
Signed-off-by: Royi Sitbon <[email protected]>

(cherry picked from commit c33bf8c)
bandinib-amzn pushed a commit to bandinib-amzn/OpenSearch-Dashboards that referenced this pull request Jul 13, 2022
…1200)

* Add DocView links pluggable injection capability
* Add proper e2e + bugfix
* set prop as lower case
* Better name
* Delete prop after usage
* Camel case + avoid mutating
* Added right data-test-subj in order to fix tests
* update snapshot
* Add hide prop in order to mimic ng-if condition
* Add i18n translation support
* Fix tests
* Made text smaller + used eui components instead of custom css
* Snapshots

Signed-off-by: sitbubu <[email protected]>
joshuarrrr pushed a commit that referenced this pull request Jul 20, 2022
* Add DocView links pluggable injection capability
* Add proper e2e + bugfix
* set prop as lower case
* Better name
* Delete prop after usage
* Camel case + avoid mutating
* Added right data-test-subj in order to fix tests
* update snapshot
* Add hide prop in order to mimic ng-if condition
* Add i18n translation support
* Fix tests
* Made text smaller + used eui components instead of custom css
* Snapshots

Signed-off-by: sitbubu <[email protected]>
Signed-off-by: Royi Sitbon <[email protected]>

(cherry picked from commit c33bf8c)

Co-authored-by: Royi Sitbon <[email protected]>
CPTNB pushed a commit to CPTNB/OpenSearch-Dashboards that referenced this pull request Aug 8, 2022
…1200)

* Add DocView links pluggable injection capability
* Add proper e2e + bugfix
* set prop as lower case
* Better name
* Delete prop after usage
* Camel case + avoid mutating
* Added right data-test-subj in order to fix tests
* update snapshot
* Add hide prop in order to mimic ng-if condition
* Add i18n translation support
* Fix tests
* Made text smaller + used eui components instead of custom css
* Snapshots

Signed-off-by: sitbubu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Top Right docViewer linkable plugin injection
7 participants