Skip to content

Commit

Permalink
Add versioned document support in OSD
Browse files Browse the repository at this point in the history
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  #769
5. Add unit tests for doclinks branch name conversion

Signed-off-by: Zuocheng Ding <[email protected]>
  • Loading branch information
zuochengding committed Nov 18, 2021
1 parent 3d69c4f commit 9047044
Show file tree
Hide file tree
Showing 43 changed files with 907 additions and 371 deletions.
2 changes: 1 addition & 1 deletion DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ If you would like to install and run this project, please see the [Downloads Pag
#### Prerequisites

You need to have an OpenSearch server up and running to be able to run OpenSearch
Dashboards. The easiest way to do it is [using Docker](https://opensearch.org/docs/opensearch/install/docker).
Dashboards. The easiest way to do it is [using Docker](https://opensearch.org/docs/latest/opensearch/install/docker).

We recommend using [Node Version Manager](https://github.com/nvm-sh/nvm) to install
the node version we need.
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/chrome/chrome_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export class ChromeService {
basePath={http.basePath}
breadcrumbs$={breadcrumbs$.pipe(takeUntil(this.stop$))}
customNavLink$={customNavLink$.pipe(takeUntil(this.stop$))}
opensearchDashboardsDocLink={docLinks.links.opensearchDashboards}
opensearchDashboardsDocLink={docLinks.links.opensearchDashboards.introduction}
forceAppSwitcherNavigation$={navLinks.getForceAppSwitcherNavigation$()}
helpExtension$={helpExtension$.pipe(takeUntil(this.stop$))}
helpSupportUrl$={helpSupportUrl$.pipe(takeUntil(this.stop$))}
Expand Down
26 changes: 25 additions & 1 deletion src/core/public/doc_links/doc_links_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,30 @@ describe('DocLinksService#start()', () => {
const service = new DocLinksService();
const api = service.start({ injectedMetadata });
expect(api.DOC_LINK_VERSION).toEqual('test-branch');
expect(api.links.opensearchDashboards).toEqual('https://opensearch.org/docs/dashboards/');
expect(api.links.opensearchDashboards.introduction).toEqual(
'https://www.opensearch.org/docs/test-branch/dashboards/index/'
);
});

it('templates the doc links with the main branch from injectedMetadata', () => {
const injectedMetadata = injectedMetadataServiceMock.createStartContract();
injectedMetadata.getOpenSearchDashboardsBranch.mockReturnValue('main');
const service = new DocLinksService();
const api = service.start({ injectedMetadata });
expect(api.DOC_LINK_VERSION).toEqual('latest');
expect(api.links.opensearchDashboards.introduction).toEqual(
'https://www.opensearch.org/docs/latest/dashboards/index/'
);
});

it('templates the doc links with the release branch from injectedMetadata', () => {
const injectedMetadata = injectedMetadataServiceMock.createStartContract();
injectedMetadata.getOpenSearchDashboardsBranch.mockReturnValue('1.1');
const service = new DocLinksService();
const api = service.start({ injectedMetadata });
expect(api.DOC_LINK_VERSION).toEqual('1.1');
expect(api.links.opensearchDashboards.introduction).toEqual(
'https://www.opensearch.org/docs/1.1/dashboards/index/'
);
});
});
759 changes: 568 additions & 191 deletions src/core/public/doc_links/doc_links_service.ts

Large diffs are not rendered by default.

295 changes: 206 additions & 89 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,104 +452,221 @@ export const DEFAULT_APP_CATEGORIES: Record<string, AppCategory>;
export interface DocLinksStart {
// (undocumented)
readonly DOC_LINK_VERSION: string;
readonly OPENSEARCH_WEBSITE_URL: string;
// (undocumented)
readonly links: {
readonly dashboard: {
readonly drilldowns: string;
readonly drilldownsTriggerPicker: string;
readonly urlDrilldownTemplateSyntax: string;
readonly urlDrilldownVariables: string;
};
readonly filebeat: {
readonly base: string;
readonly installation: string;
readonly opensearch: {
readonly introduction: string;
readonly installation: {
readonly base: string;
readonly compatibility: string;
readonly docker: string;
readonly dockerSecurity: string;
readonly helm: string;
readonly tar: string;
readonly ansible: string;
readonly settings: string;
readonly plugins: string;
};
readonly configuration: string;
readonly elasticsearchOutput: string;
readonly startup: string;
readonly exportedFields: string;
};
readonly auditbeat: {
readonly base: string;
};
readonly metricbeat: {
readonly base: string;
};
readonly heartbeat: {
readonly base: string;
};
readonly logstash: {
readonly base: string;
};
readonly functionbeat: {
readonly base: string;
readonly cluster: {
readonly base: string;
readonly naming: string;
readonly set_attribute: string;
readonly build_cluster: string;
readonly config_host: string;
readonly start: string;
readonly config_shard: string;
readonly setup_hot_arch: string;
};
readonly indexData: {
readonly base: string;
readonly naming: string;
readonly read_data: string;
readonly update_data: string;
readonly delete_data: string;
};
readonly indexAlias: {
readonly base: string;
readonly create_alias: string;
readonly add_remove_index: string;
readonly manage_alias: string;
readonly filtered_alias: string;
readonly alias_option: string;
};
readonly dataStreams: string;
readonly aggregations: {
readonly base: string;
readonly metric: {
readonly base: string;
readonly types: string;
readonly sum: string;
readonly cardinality: string;
readonly value_count: string;
readonly stats: string;
readonly percentile: string;
readonly geo_bound: string;
readonly top_hits: string;
readonly scripted_metric: string;
};
readonly bucket: {
readonly base: string;
readonly terms: string;
readonly smapler: string;
readonly significant_terms: string;
readonly missing: string;
readonly histogram: string;
readonly range: string;
readonly filter: string;
readonly global: string;
readonly geo: string;
readonly adjacency_matrix: string;
readonly nested: string;
};
readonly pipeline: {
readonly base: string;
readonly syntax: string;
readonly types: string;
readonly avg_bucket: string;
readonly stats_bucket: string;
readonly bucket_script: string;
readonly bucket_sort: string;
readonly cumulative_sum: string;
readonly derivative: string;
readonly moving_avg: string;
readonly serial_diff: string;
};
};
readonly indexTemplates: {
readonly base: string;
readonly composable: string;
readonly options: string;
};
readonly reindexData: {
readonly base: string;
readonly all: string;
readonly remote: string;
readonly subset: string;
readonly combine: string;
readonly unique: string;
readonly transform: string;
readonly update: string;
readonly source: string;
readonly destination: string;
};
readonly queryDSL: {
readonly base: string;
readonly term: {
readonly base: string;
readonly terms: string;
readonly ids: string;
readonly range: string;
readonly prefix: string;
readonly exists: string;
readonly wildcards: string;
readonly regex: string;
};
readonly fullText: {
readonly base: string;
readonly match: string;
readonly multi_match: string;
readonly match_phrase: string;
readonly common_terms: string;
readonly query_string: string;
readonly options: string;
};
readonly boolQuery: string;
};
readonly searchTemplate: {
readonly base: string;
readonly create: string;
readonly execute: string;
readonly advanced_operation: string;
readonly multiple_search: string;
readonly manage: string;
};
readonly searchExperience: {
readonly base: string;
readonly autocomplete: string;
readonly paginate: string;
readonly scroll: string;
readonly sort: string;
readonly highlight_match: string;
};
readonly logs: {
readonly base: string;
readonly application_log: string;
readonly slow_log: string;
readonly deprecation_log: string;
};
readonly snapshotRestore: {
readonly base: string;
readonly register: string;
readonly take_snapshot: string;
readonly restore_snapshot: string;
readonly security_plugin: string;
};
readonly supportedUnits: string;
readonly commonParameters: string;
readonly popularAPI: string;
readonly restAPI: string;
};
readonly winlogbeat: {
readonly base: string;
};
readonly aggs: {
readonly date_histogram: string;
readonly date_range: string;
readonly filter: string;
readonly filters: string;
readonly geohash_grid: string;
readonly histogram: string;
readonly ip_range: string;
readonly range: string;
readonly significant_terms: string;
readonly terms: string;
readonly avg: string;
readonly avg_bucket: string;
readonly max_bucket: string;
readonly min_bucket: string;
readonly sum_bucket: string;
readonly cardinality: string;
readonly count: string;
readonly cumulative_sum: string;
readonly derivative: string;
readonly geo_bounds: string;
readonly geo_centroid: string;
readonly max: string;
readonly median: string;
readonly min: string;
readonly moving_avg: string;
readonly percentile_ranks: string;
readonly serial_diff: string;
readonly std_dev: string;
readonly sum: string;
readonly top_hits: string;
};
readonly scriptedFields: {
readonly scriptFields: string;
readonly scriptAggs: string;
readonly painless: string;
readonly painlessApi: string;
readonly painlessSyntax: string;
readonly luceneExpressions: string;
};
readonly indexPatterns: {
readonly loadingData: string;
readonly opensearchDashboards: {
readonly introduction: string;
readonly installation: {
readonly base: string;
readonly docker: string;
readonly tar: string;
readonly helm: string;
readonly tls: string;
readonly plugins: string;
};
readonly mapTiles: string;
readonly ganttCharts: string;
readonly reporting: string;
readonly notebooks: {
readonly base: string;
readonly notebook_tutorial: string;
readonly paragraph_tutorial: string;
readonly sample_notebook: string;
readonly create_report: string;
};
readonly dql: {
readonly base: string;
readonly terms_query: string;
readonly boolean_query: string;
readonly date_query: string;
readonly nested_query: string;
};
};
readonly addData: string;
readonly opensearchDashboards: string;
readonly siem: {
readonly guide: string;
readonly gettingStarted: string;
};
readonly query: {
readonly eql: string;
readonly luceneQuerySyntax: string;
readonly queryDsl: string;
readonly kueryQuerySyntax: string;
};
readonly date: {
readonly noDocumentation: {
readonly auditbeat: string;
readonly filebeat: string;
readonly metricbeat: string;
readonly heartbeat: string;
readonly logstash: string;
readonly functionbeat: string;
readonly winlogbeat: string;
readonly siem: string;
readonly indexPatterns: {
readonly loadingData: string;
readonly introduction: string;
};
readonly scriptedFields: {
readonly scriptFields: string;
readonly scriptAggs: string;
readonly painless: string;
readonly painlessApi: string;
readonly painlessSyntax: string;
readonly luceneExpressions: string;
};
readonly management: Record<string, string>;
readonly visualize: Record<string, string>;
readonly addData: string;
readonly vega: string;
readonly dateMath: string;
};
readonly management: Record<string, string>;
readonly visualize: Record<string, string>;
};
// (undocumented)
readonly OPENSEARCH_WEBSITE_URL: string;
}

export { EnvironmentMode }
Expand Down
4 changes: 1 addition & 3 deletions src/core/server/ui_settings/settings/date_formats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ export const getDateFormatSettings = (): Record<string, UiSettingsParams> => {
defaultMessage: 'Used for the {dateNanosLink} datatype of OpenSearch',
values: {
dateNanosLink:
// TODO: [RENAMEME] Need prod urls.
// issue: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/335#issuecomment-868294864
'<a href="https://opensearch.org/docs/opensearch/units" target="_blank" rel="noopener noreferrer">' +
'<a href="https://opensearch.org/docs/latest/opensearch/units/" target="_blank" rel="noopener noreferrer">' +
i18n.translate('core.ui_settings.params.dateNanosLinkTitle', {
defaultMessage: 'date_nanos',
}) +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,10 @@ export class Field extends PureComponent<FieldProps> {
<EuiBadge
color="warning"
onClick={() => {
window.open(links.management[setting.deprecation!.docLinksKey], '_blank');
window.open(
links.noDocumentation.management[setting.deprecation!.docLinksKey],
'_blank'
);
}}
onClickAriaLabel={i18n.translate('advancedSettings.field.deprecationClickAreaLabel', {
defaultMessage: 'Click to view deprecation documentation for {settingName}.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
"{indices}/_msearch",
"{indices}/{type}/_msearch"
],
"documentation": "https://opensearch.org/docs/opensearch/query-dsl/full-text/#multi-match"
"documentation": "https://opensearch.org/docs/latest/opensearch/query-dsl/full-text/#multi-match"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
"{indices}/_msearch/template",
"{indices}/{type}/_msearch/template"
],
"documentation": "https://opensearch.org/docs/opensearch/query-dsl/full-text/#multi-match"
"documentation": "https://opensearch.org/docs/latest/opensearch/query-dsl/full-text/#multi-match"
}
}
Loading

0 comments on commit 9047044

Please sign in to comment.