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 versioned doc support #905

Merged
merged 1 commit into from
Nov 18, 2021

Conversation

zuochengding
Copy link
Contributor

@zuochengding zuochengding commented Nov 3, 2021

Description

This PR is to add versioned doc url support in DocLinksServices.

  1. My proposal is to use package.json to control the doc url versioning. If the branch value is main then convert it to latest as the document version, otherwise use the branch value as the document version (e.g. 1.1, or 1.0)
  2. Create new doc link mappings based on doc website. Group them into three parts : opeansearch, opensearchDashboards and noDocuments. Mapping the structure into: [Group] -> [sub-page]->[sub-subpage] -> [anchor].
  3. Fix DQL link related bug
  4. Fix unit tests
  5. Update URL links to latest version.

Issues Resolved

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

@zuochengding zuochengding self-assigned this Nov 3, 2021
@zuochengding zuochengding added docs Improvements or additions to documentation rename-docs Document rename tracking enhancement New feature or request labels Nov 3, 2021
@zuochengding zuochengding linked an issue Nov 3, 2021 that may be closed by this pull request
@zuochengding
Copy link
Contributor Author

Pipeline Testing:
Screen Shot 2021-11-02 at 9 27 18 PM

Copy link
Contributor

@tmarkley tmarkley left a comment

Choose a reason for hiding this comment

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

I think this would be a good opportunity to clean up the DocLinksService a bit and make it clear which documentation does and does not exist. I believe in #335 we agreed to re-route "dead" links to the root documentation page for now, which we haven't done for all links, so we could fix that as well?

src/core/public/doc_links/doc_links_service.ts Outdated Show resolved Hide resolved
src/core/public/doc_links/doc_links_service.ts Outdated Show resolved Hide resolved
src/core/public/doc_links/doc_links_service.ts Outdated Show resolved Hide resolved
src/core/server/ui_settings/settings/date_formats.ts Outdated Show resolved Hide resolved
@tmarkley
Copy link
Contributor

tmarkley commented Nov 3, 2021

Looks like there are a few linting errors. You can fix those with node scripts/precommit_hook --fix and then commit the changes.

package.json Outdated Show resolved Hide resolved
@zuochengding zuochengding linked an issue Nov 5, 2021 that may be closed by this pull request
@zuochengding
Copy link
Contributor Author

Screen Shot 2021-11-04 at 7 08 43 PM

Copy link
Contributor

@tmarkley tmarkley left a comment

Choose a reason for hiding this comment

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

Looks good! Just a few minor questions/suggestions.

// https://opensearch.org/docs/latest/opensearch/install/docker-security/
dockerSecurity: `${OPENSEARCH_VERSIONED_DOCS}install/docker-security`,
// https://opensearch.org/docs/latest/opensearch/install/helm/
helm: `${OPENSEARCH_VERSIONED_DOCS}install//helm/`,
Copy link
Contributor

Choose a reason for hiding this comment

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

typo (extra /)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will fix

};
readonly date: {
readonly dateMath: string;
noDocumentation: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason this isn't readonly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should mark as readonly as well

Comment on lines 655 to 656
readonly management: Record<string, string>;
readonly visualize: Record<string, string>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we know why these are different from the others?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some unit test logic use different setting as a key to retrieve corresponding url. So i keep the Record type as it was.

readonly visualize: Record<string, string>;
readonly addData: string;
};
readonly scriptedFields: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this exist inside of noDocumentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch. I was changing the structure in doc_links_service but forgot to copy paste here

const opensearchDashboards = useOpenSearchDashboards();
const kueryQuerySyntaxDocs = opensearchDashboards.services.docLinks!.links.query.kueryQuerySyntax;
const docLinks = useOpenSearchDashboards().services.docLinks;
const kueryQuerySyntaxDocs = docLinks!.links.opensearchDashboards.dql.base;
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 take the opportunity to rename these keury variables now as referenced in #769?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will update

Comment on lines 46 to 47
const opensearchDashboadsDoc = opensearchDashboards.services.docLinks!.links.opensearchDashboards
.introduction;
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be better to add a vega property to the noDocumentation object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we can.

package.json Outdated Show resolved Hide resolved
src/core/public/public.api.md Outdated Show resolved Hide resolved
@@ -141,7 +141,10 @@ function DateRangesParamEditor({
<EuiFormRow compressed fullWidth>
<>
<EuiText size="xs">
<EuiLink href={services.docLinks.links.date.dateMath} target="_blank">
<EuiLink
href={services.docLinks.links.opensearch.aggregations.bucket.range}
Copy link
Member

Choose a reason for hiding this comment

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

is this the right link? bucket aggregations are a different thing.

Copy link
Contributor Author

@zuochengding zuochengding Nov 5, 2021

Choose a reason for hiding this comment

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

Not so sure, I was thinking to use : https://opensearch.org/docs/latest/opensearch/units/ but it doesn't contains enough info related date_range. Instead, https://opensearch.org/docs/latest/opensearch/bucket-agg/#range-date_range-ip_range, contains more info about date_range. Open to any inputs

@kavilla
Copy link
Member

kavilla commented Nov 8, 2021

Screen Shot 2021-11-08 at 2 29 08 PM

Can this one be replaced by dql?

@kavilla
Copy link
Member

kavilla commented Nov 8, 2021

Like the proposal, do we know if custom plugins consume the docs service? Like I would check some of the dashboards plugins in the opensearch-project and see if they are using some of the links provided. If so we might have to prep folks and wait for a 2.0 version bump.

Also, have you verified the 'zero-data' state works fine. I pulled this down and works fine with me just haven't checked zero data and thought I'd ask before clearing my stuff out.

NIT: Can you squash the commits with the context provided?

Thanks!

@zuochengding
Copy link
Contributor Author

zuochengding commented Nov 9, 2021

Yes, I have tested the app with no data ingested, the urls look fine to me. My understanding is that all the urls in DocLinksService are from external doc website, shouldn't have dependency on local data indexing.

To make sure my understanding regarding the comments is correct, you are suggesting to use :

Will squash commits in next revision

@kavilla
Copy link
Member

kavilla commented Nov 9, 2021

Yes, I have tested the app with no data ingested, the urls look fine to me. My understanding is that all the urls in DocLinksService are from external doc website, shouldn't have dependency on local data indexing.

For sure, just making sure if there were links on views that only showed in the empty data state existed then there are still working.

https://opensearch.org/docs/latest/opensearch/query-dsl/index/ for Query string options

Not sure, if it should go to Query DSL, seeing more if it should go the newly created to the new DQL link created.

create an default dataMath url in noDocument group for date.dateMath
right?

If dateMath doesn't exist than 10-4 because just looking in the diff going from date to bucket agg that seems incorrect to me. If it was a bug that it was referencing date math but should have referenced aggs then so be it. But if its just a dead link then add it to the no docs section.

Will squash commits in next revision

💯

Any comment about custom plugins or still verifying that?

@zuochengding
Copy link
Contributor Author

Need some time to check the plugins

@zuochengding
Copy link
Contributor Author

By searching the code references in other open search plugin repos, there is no plugin depended on doc_links_service.ts. Most plugin projects just use hardcoded doc website links in their code base .

kavilla
kavilla previously approved these changes Nov 9, 2021
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.

Since adding a conditional we should probably had a test or two for verifying the conditional. Otherwise LGTM. I'm in an opinion this doesn't get backported to 1.2 and hesitatant to backport to 1.x since we are restructuring things. I don't think external plugins would be consuming this but just in case.

boktorbb
boktorbb previously approved these changes Nov 10, 2021
Copy link
Contributor

@boktorbb boktorbb left a comment

Choose a reason for hiding this comment

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

LGTM. I noticed we have the path src/plugins/data/common/opensearch_query/kuery. We should probably rename this. It doesn't have to be in this PR so we don't pollute the commits but it should probably be done

@tmarkley
Copy link
Contributor

Since adding a conditional we should probably had a test or two for verifying the conditional. Otherwise LGTM. I'm in an opinion this doesn't get backported to 1.2 and hesitant to backport to 1.x since we are restructuring things. I don't think external plugins would be consuming this but just in case.

Agreed on all counts. Can we spend a little more time on adding tests?

@zuochengding
Copy link
Contributor Author

zuochengding commented Nov 11, 2021

Yeah. Working on adding the new tests

@tmarkley
Copy link
Contributor

Like the proposal, do we know if custom plugins consume the docs service? Like I would check some of the dashboards plugins in the opensearch-project and see if they are using some of the links provided. If so we might have to prep folks and wait for a 2.0 version bump.

Is this the case for any service in our repo? If so, that's a serious inhibitor for any change that we're making. Not being able to refactor anything between major version bumps is a slippery slope.

Copy link
Contributor

@tmarkley tmarkley left a comment

Choose a reason for hiding this comment

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

This looks great! Just a couple very minor changes and then I think we're good to go.

This is PR is to add versioned document support in OSD.
1. Add logic to pick up doc version from package.json and convert it to `latest` if we are on default `main` branch.
2. Refactor doc_link_service to have 3 urls groups: opensearch, opensearchDashboards, and noDocumentation.
3. Update dynamic versioned doc links and clean up unused urls
4. Fix known url bug  opensearch-project#769
5. Add unit tests for doclinks branch name conversion

Signed-off-by: Zuocheng Ding <zding817@gmail.com>
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.

LGTM!

Copy link
Contributor

@tmarkley tmarkley left a comment

Choose a reason for hiding this comment

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

This is great!

@zuochengding zuochengding merged commit 9047044 into opensearch-project:main Nov 18, 2021
@zuochengding zuochengding deleted the versioned-doc branch November 18, 2021 22:11
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Feb 10, 2022
…rch-project#905)

bump semantic-release from 16.0.1 to 17.2.3 and upgrade semantic-release deps and node version

Bumps [semantic-release](https://github.com/semantic-release/semantic-release) from 16.0.1 to 17.2.3.
- [Release notes](https://github.com/semantic-release/semantic-release/releases)
- [Commits](semantic-release/semantic-release@v16.0.1...v17.2.3)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Nick Partridge <nick.ryan.partridge@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation enhancement New feature or request rename-docs Document rename tracking v1.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Docs] handle version in docs [BUG] DQL Link in Syntax Options goes to unrelated query language
4 participants