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

Self host runner #3

Open
wants to merge 132 commits into
base: workspace
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
912b6d2
setup workspace plugin project skeleton
ruanyl Jun 7, 2023
b774c50
test: add unit tests
ruanyl Jun 9, 2023
56a314c
workspace template init commit
Hailong-am Jun 9, 2023
327498c
refacter workspace template into hooks
Hailong-am Jun 9, 2023
ff1645a
refacter workspace template hooks
Hailong-am Jun 9, 2023
f1d0a35
update coverImage comments
Hailong-am Jun 9, 2023
168ba7f
feature: add public/workspaces service
SuZhou-Joe Jun 7, 2023
7d3f24c
feat: add interfaces for workspaces client
SuZhou-Joe Jun 8, 2023
c6f9a47
feat: add interfaces for workspaces client
SuZhou-Joe Jun 8, 2023
e82777f
feat: add interfaces for workspaces client
SuZhou-Joe Jun 8, 2023
2c96331
feat: implement workspaces service
SuZhou-Joe Jun 12, 2023
5ec3feb
feat: changes to client type interface
SuZhou-Joe Jun 13, 2023
0477076
feat: changes to client implement
SuZhou-Joe Jun 13, 2023
0c07b79
feat: implement more for workspaces service
SuZhou-Joe Jun 13, 2023
7767933
feat: implement more for workspaces service
SuZhou-Joe Jun 13, 2023
ef1a245
feat: implement more for workspaces service
SuZhou-Joe Jun 13, 2023
dce7d76
feat: add workspace creator page (#5)
wanglam Jun 14, 2023
6117c8f
Add validation when load page (#8)
SuZhou-Joe Jun 15, 2023
a21d0c2
feat: use BehaviorObject and optimize code (#14)
SuZhou-Joe Jun 15, 2023
e9b5c3b
feat: integrate with workspace create API (#13)
wanglam Jun 15, 2023
704520a
Add currentWorkspace$ (#15)
SuZhou-Joe Jun 16, 2023
5074400
register plugin with workspace template (#16)
Hailong-am Jun 16, 2023
cf16249
workspace dropdown list (#9)
zhichao-aws Jun 16, 2023
42d1a51
init workspace menu stage 1 (#12)
raintygao Jun 16, 2023
d7e740b
Fix template registration import error (#21)
Hailong-am Jun 16, 2023
6f93c2f
Add workspace overview page (#19)
wanglam Jun 19, 2023
43c1bb6
feat: navigate to workspace create page after button clicked (#23)
wanglam Jun 19, 2023
e9d2571
fix failed test snapshots (#22)
ruanyl Jun 19, 2023
e0170ca
change to currentWorkspace, wrap title using i18n (#20)
zhichao-aws Jun 20, 2023
a28e12d
add workspace switch (#17)
raintygao Jun 20, 2023
763eddb
Add update workspace page (#25)
gaobinlong Jun 21, 2023
b56117d
Delete Workspace (#24)
yuye-aws Jun 21, 2023
6024e9a
feat: redirect to overview page after workspace switch (#26)
wanglam Jun 25, 2023
9f60da9
update menu filter logic (#28)
raintygao Jun 25, 2023
1097a89
feat: redirect to workspace overview page after created success (#29)
wanglam Jun 25, 2023
33af728
[Feature] Complied saved_objects create/find (#18)
SuZhou-Joe Jun 25, 2023
e21dcf3
feat: redirect to workspace update page after workspace switch (#30)
wanglam Jun 25, 2023
14e03da
Move delete button to update page (#27)
yuye-aws Jun 25, 2023
5e7b548
fix: linting error
ruanyl Jun 26, 2023
7cf1227
remove duplicate EuiPage (#34)
Hailong-am Jun 26, 2023
1f76aa2
remove clear button, add the width of create button (#33)
zhichao-aws Jun 26, 2023
29fccee
rename OpenSearch Plugins to OpenSearch Features
ruanyl Jun 27, 2023
274c96d
Add some logic check when overwrite a saved object (#32)
SuZhou-Joe Jun 29, 2023
d983d14
Add color, icon and defaultVISTheme for workspace (#36)
wanglam Jul 5, 2023
ad0c47b
feat: add workspace list (#39)
raintygao Jul 6, 2023
bf5528f
Feature/menu change (#37)
SuZhou-Joe Jul 7, 2023
1aafbd6
feat: different left menu and exit workspace (#38)
yuye-aws Jul 7, 2023
0184a77
feat: make url stateful (#35)
SuZhou-Joe Jul 10, 2023
8337f9f
Fix build error and part of test error (#42)
raintygao Jul 11, 2023
1d20134
feat: optimize code (#40)
SuZhou-Joe Jul 11, 2023
3af0e6a
fix: bootstrap error (#43)
SuZhou-Joe Jul 12, 2023
ee9623a
feat: add workspace permission control interface (#41)
wanglam Jul 13, 2023
f8c6586
allow user to turn on/off workspace from advance settings (#46)
ruanyl Jul 14, 2023
6cd4015
fix: unit test failure (#50)
SuZhou-Joe Jul 17, 2023
79d3e6b
Add workspace column into saved objects table (#44)
Hailong-am Jul 18, 2023
018af70
fix missing mocks of workspacesSetup
ruanyl Jul 19, 2023
356e96d
Integrate workspace service into saved object management (#31)
SuZhou-Joe Jul 20, 2023
01996e1
Feature: hide workspace from saved objects management page. (#45)
SuZhou-Joe Jul 21, 2023
f47d178
Add copy saved objects among workspaces functionality (#53)
gaobinlong Jul 21, 2023
444d7f6
add workspace saved objects client wrapper (#51)
wanglam Jul 21, 2023
ed560b9
Refactor navigation links from left menu hard code to workspace plugi…
yuye-aws Jul 24, 2023
041189e
fix: osd bootstrap error (#57)
yuye-aws Jul 24, 2023
46d50c3
feat: filter out ADMIN application and add feature dependency logic (…
wanglam Jul 24, 2023
cac4d52
feat: do not register app when feature flag is off (#56)
SuZhou-Joe Jul 24, 2023
3be54b0
Sort category and non-category nav link according to order in left me…
yuye-aws Jul 26, 2023
614cf9a
Refactor: Assign default value for filtered nav links (#64)
yuye-aws Jul 31, 2023
cde45c5
Permission control service for saved objects (#63)
SuZhou-Joe Jul 31, 2023
0fd7bfe
Remove server side workspace feature flag check (#69)
ruanyl Aug 2, 2023
b77007d
apply workspace permission check when bulk creating object (#66)
raintygao Aug 2, 2023
345d96e
Register application "See more", "Home", "Create" and "Workspace Sett…
yuye-aws Aug 3, 2023
57984a2
Add acl permission related functions (#65)
gaobinlong Aug 3, 2023
0e3bc40
share saved objects to workspace api (#67)
Hailong-am Aug 3, 2023
8bacb1b
Feat remove feature group (#72)
wanglam Aug 3, 2023
9bf4ffd
feat: remove template section (#73)
raintygao Aug 4, 2023
5a12d0b
Integration ACL check with saved objects. (#74)
SuZhou-Joe Aug 7, 2023
e14f696
feat: add permission control section to workspace form (#75)
wanglam Aug 8, 2023
06e37a3
write permisions outside instead of workspace attributes (#79)
wanglam Aug 9, 2023
7715023
Refactor UI setting register (#77)
ruanyl Aug 9, 2023
d4e27e5
refactor: simplified ACL transformPermission function (#78)
ruanyl Aug 9, 2023
23a77e9
Change public objects logic & Search with ACL control (#71)
SuZhou-Joe Aug 9, 2023
166c06d
Refactor workspace server plugin (#82)
ruanyl Aug 11, 2023
dd1ae90
add workspace filter into saved objects page (#76)
Hailong-am Aug 11, 2023
3b8879d
add permission check when updating workspace (#81)
raintygao Aug 11, 2023
e4b45a9
Show objects without workspace info when no workspaces are provided i…
SuZhou-Joe Aug 11, 2023
9393525
feat: call saved objects with internal user (#80)
wanglam Aug 15, 2023
b49aa1f
feat: workspace context menu and picker menu (#86)
yuye-aws Aug 16, 2023
7b6800f
fix: permission check error (#88)
SuZhou-Joe Aug 17, 2023
d732833
fix: redirect to home only when delete and exit workspace successfull…
yuye-aws Aug 17, 2023
d7f743c
feat: add management permission for workspace create user (#92)
wanglam Aug 18, 2023
7fd4139
refactor: in left menu, move recently viewed from top to middle (#87)
yuye-aws Aug 21, 2023
64bcc8b
refactor: register workspace dropdown menu to left menu (#90)
ruanyl Aug 21, 2023
33b1109
move index pattern to Library (#91)
Hailong-am Aug 21, 2023
e2778ad
create workspace bug fix: navigate to workspace overview after create…
yuye-aws Aug 22, 2023
866e122
feat: accomplish dashboard_admin (#95)
SuZhou-Joe Aug 22, 2023
a9ffe1b
fix: incorrect permission modes when checking workspace permissions (…
SuZhou-Joe Aug 22, 2023
67260a8
fix: two "Overview"s under library section (#94)
yuye-aws Aug 22, 2023
c83393b
supports configure workspace features with wildcard (#96)
ruanyl Aug 22, 2023
39df76c
update feature config of public workspace (#99)
ruanyl Aug 24, 2023
8cc4ea2
fix: redirect error (#105)
SuZhou-Joe Aug 24, 2023
5a8e5b8
feat: register data source as application (#101)
SuZhou-Joe Aug 24, 2023
a1f7a81
fix import error on workspace updater (#107)
yuye-aws Aug 24, 2023
1aae8de
fix: make importing workspace-specific objects as copy (#62)
SuZhou-Joe Aug 24, 2023
54d9d1b
Change workspace id to 6 random characters (#100)
ruanyl Aug 25, 2023
d384519
add workspace attribute check and refactor saved object acl check (#93)
raintygao Aug 25, 2023
3c79905
filter non-configurable workspace features in workspace configuration…
raintygao Aug 25, 2023
a058a37
feat: filter applications according to categories (#103)
yuye-aws Aug 25, 2023
e2f277c
[Refractor] Feature flag (#102)
SuZhou-Joe Aug 28, 2023
e89d320
feat: register advanced settings under Management library (#111)
SuZhou-Joe Aug 29, 2023
acaf609
fix: update snapshot for collapsible_nav.test.tsx and header.test.tsx…
yuye-aws Aug 29, 2023
081046e
index pattern always show under library (#115)
Hailong-am Aug 30, 2023
0f26494
feat: duplicate selected objects (#113)
yuye-aws Aug 30, 2023
f3a9672
add workspace name duplication check (#117)
Hailong-am Aug 31, 2023
220bb9d
feat: customize management workspace (#122)
yuye-aws Sep 4, 2023
2b9acb0
feat: remove workspace switch droplist and create workspace button (#…
raintygao Sep 5, 2023
3c42271
cleanup: move WORKSPACE_TYPE constant to core/utils/constants (#129)
SuZhou-Joe Sep 6, 2023
8802477
Update backport.yml installation id
ruanyl Sep 6, 2023
58605a8
Revert "[Refractor] Feature flag (#102)" (#124)
ruanyl Sep 6, 2023
c6037d5
fix: type import on WORKSPACE_TYPE (#131)
SuZhou-Joe Sep 6, 2023
6d59211
Setup mechanism for register customized query DSL logic (#128)
SuZhou-Joe Sep 6, 2023
56c8971
refactor: derive currentWorkspace in workspaces_service (#126)
ruanyl Sep 6, 2023
538fea9
feat: add self host runner
SuZhou-Joe Sep 7, 2023
7146b49
feat: update
SuZhou-Joe Sep 7, 2023
95a1ec8
feat: update
SuZhou-Joe Sep 8, 2023
78f9f9c
feat: update
SuZhou-Joe Sep 8, 2023
fc24867
feat: use v4
SuZhou-Joe Sep 8, 2023
058c6ce
feat: update
SuZhou-Joe Sep 9, 2023
3b688de
Revert "feat: use v4"
SuZhou-Joe Sep 11, 2023
9e08e89
feat: use auto-scaleable runners
SuZhou-Joe Sep 13, 2023
7a0840c
feat: use sudo
SuZhou-Joe Sep 13, 2023
ec08c32
feat: update
SuZhou-Joe Sep 13, 2023
3a37711
feat: update
SuZhou-Joe Sep 15, 2023
977e6a5
feat: update
SuZhou-Joe Sep 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/add-untriaged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
apply-label:
runs-on: ubuntu-latest
runs-on: arc-runner-set-suzhou
steps:
- uses: actions/github-script@v6
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
backport:
runs-on: ubuntu-latest
runs-on: arc-runner-set-suzhou
permissions:
contents: write
pull-requests: write
Expand All @@ -31,7 +31,7 @@ jobs:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
# opensearch-trigger-bot installation ID
installation_id: 22958780
installation_id: 41494816

- name: Backport
uses: VachaShah/backport@v2.2.0
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/build_and_test_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
os: [arc-runner-set-suzhou, windows-latest]
group: [1, 2, 3, 4]
include:
- os: ubuntu-latest
- os: arc-runner-set-suzhou
name: Linux
- os: windows-latest
name: Windows
Expand Down Expand Up @@ -92,13 +92,13 @@ jobs:

- name: Run linter
# ciGroup 1 of unit-tests is shorter and Linux is faster
if: matrix.group == 1 && matrix.os == 'ubuntu-latest'
if: matrix.group == 1 && matrix.os == 'arc-runner-set-suzhou'
id: linter
run: yarn lint

- name: Validate NOTICE file
# ciGroup 1 of unit-tests is shorter and Linux is faster
if: matrix.group == 1 && matrix.os == 'ubuntu-latest'
if: matrix.group == 1 && matrix.os == 'arc-runner-set-suzhou'
id: notice-validate
run: yarn notice:validate

Expand Down Expand Up @@ -130,10 +130,10 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
os: [arc-runner-set-suzhou, windows-latest]
group: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
include:
- os: ubuntu-latest
- os: arc-runner-set-suzhou
name: Linux
- os: windows-latest
name: Windows
Expand Down Expand Up @@ -217,12 +217,12 @@ jobs:
strategy:
matrix:
include:
- os: ubuntu-latest
- os: arc-runner-set-suzhou
name: Linux x64
ext: tar.gz
suffix: linux-x64
script: build-platform --linux --skip-os-packages
- os: ubuntu-latest
- os: arc-runner-set-suzhou
name: Linux ARM64
ext: tar.gz
suffix: linux-arm64
Expand Down Expand Up @@ -308,7 +308,7 @@ jobs:

bwc-tests:
needs: [build-min-artifact-tests]
runs-on: ubuntu-latest
runs-on: arc-runner-set-suzhou
container:
image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2
options: --user 1001
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/changelog_verifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
# Enforces the update of a changelog file on every pull request
verify-changelog:
runs-on: ubuntu-latest
runs-on: arc-runner-set-suzhou
steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create_doc_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:
jobs:
create-issue:
if: ${{ github.event.label.name == 'needs-documentation' }}
runs-on: ubuntu-latest
runs-on: arc-runner-set-suzhou
name: Create Documentation Issue
steps:
- name: GitHub App token
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/cypress_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:

jobs:
cypress-tests:
runs-on: ubuntu-latest
runs-on: arc-runner-set-suzhou
container:
image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2
options: --user 1001
Expand Down Expand Up @@ -55,7 +55,8 @@ jobs:
with:
path: ${{ env.FTR_PATH }}
repository: opensearch-project/opensearch-dashboards-functional-test
ref: '${{ github.base_ref }}'
# revert this to '${{ github.base_ref }}'
ref: 'main'

- name: Get Cypress version
id: cypress_version
Expand Down Expand Up @@ -88,7 +89,7 @@ jobs:
name: ftr-cypress-screenshots
path: ${{ env.FTR_PATH }}/cypress/screenshots
retention-days: 1

- uses: actions/upload-artifact@v3
if: always()
with:
Expand All @@ -101,4 +102,4 @@ jobs:
with:
name: ftr-cypress-results
path: ${{ env.FTR_PATH }}/cypress/results
retention-days: 1
retention-days: 1
2 changes: 1 addition & 1 deletion .github/workflows/delete_backport_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
delete-branch:
runs-on: ubuntu-latest
runs-on: arc-runner-set-suzhou
if: startsWith(github.event.pull_request.head.ref,'backport/')
steps:
- name: Delete merged branch
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/github-workflow-badger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
call-action:
runs-on: ubuntu-latest
runs-on: arc-runner-set-suzhou
permissions:
pull-requests: write
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/links_checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
linkchecker:

runs-on: ubuntu-latest
runs-on: arc-runner-set-suzhou

steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 3 additions & 0 deletions config/opensearch_dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,6 @@
# Set the value of this setting to true to enable plugin augmentation on Dashboard
# vis_augmenter.pluginAugmentationEnabled: true

# Set the backend roles, whoever has the backend roles defined in this config will be regard as dashboard admin.
# Dashboard admin will have the access to all the workspaces and objects inside OpenSearch Dashboards.
# workspace.dashboardAdmin.backendRoles: ["dashboard_admin"]
13 changes: 13 additions & 0 deletions src/core/public/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { IUiSettingsClient } from '../ui_settings';
import { SavedObjectsStart } from '../saved_objects';
import { AppCategory } from '../../types';
import { ScopedHistory } from './scoped_history';
import { WorkspaceStart } from '../workspace';

/**
* Accessibility status of an application.
Expand Down Expand Up @@ -244,6 +245,16 @@ export interface App<HistoryLocationState = unknown> {
* ```
*/
exactRoute?: boolean;

/**
* The dependencies of one application, required feature will be automatic select and can't
* be unselect in the workspace configuration.
*/
dependencies?: {
[key: string]: {
type: 'required' | 'optional';
};
};
}

/**
Expand Down Expand Up @@ -334,6 +345,8 @@ export interface AppMountContext {
injectedMetadata: {
getInjectedVar: (name: string, defaultValue?: any) => unknown;
};
/** {@link WorkspaceService} */
workspaces: WorkspaceStart;
};
}

Expand Down
2 changes: 2 additions & 0 deletions src/core/public/chrome/chrome_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const createStartContractMock = () => {
getHeaderComponent: jest.fn(),
navLinks: {
getNavLinks$: jest.fn(),
getFilteredNavLinks$: jest.fn(),
setFilteredNavLinks: jest.fn(),
has: jest.fn(),
get: jest.fn(),
getAll: jest.fn(),
Expand Down
2 changes: 2 additions & 0 deletions src/core/public/chrome/chrome_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { notificationServiceMock } from '../notifications/notifications_service.
import { uiSettingsServiceMock } from '../ui_settings/ui_settings_service.mock';
import { ChromeService } from './chrome_service';
import { getAppInfo } from '../application/utils';
import { workspacesServiceMock } from '../workspace/workspaces_service.mock';

class FakeApp implements App {
public title = `${this.id} App`;
Expand All @@ -67,6 +68,7 @@ function defaultStartDeps(availableApps?: App[]) {
injectedMetadata: injectedMetadataServiceMock.createStartContract(),
notifications: notificationServiceMock.createStartContract(),
uiSettings: uiSettingsServiceMock.createStartContract(),
workspaces: workspacesServiceMock.createStartContract(),
};

if (availableApps) {
Expand Down
11 changes: 7 additions & 4 deletions src/core/public/chrome/chrome_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { FormattedMessage } from '@osd/i18n/react';
import { BehaviorSubject, combineLatest, merge, Observable, of, ReplaySubject } from 'rxjs';
import { flatMap, map, takeUntil } from 'rxjs/operators';
import { EuiLink } from '@elastic/eui';
import { mountReactNode } from '../utils/mount';
import { mountReactNode } from '../utils';
import { InternalApplicationStart } from '../application';
import { DocLinksStart } from '../doc_links';
import { HttpStart } from '../http';
Expand All @@ -48,7 +48,7 @@ import { ChromeNavLinks, NavLinksService, ChromeNavLink } from './nav_links';
import { ChromeRecentlyAccessed, RecentlyAccessedService } from './recently_accessed';
import { Header } from './ui';
import { ChromeHelpExtensionMenuLink } from './ui/header/header_help_menu';
import { Branding } from '../';
import { Branding, WorkspaceStart } from '../';
export { ChromeNavControls, ChromeRecentlyAccessed, ChromeDocTitle };

const IS_LOCKED_KEY = 'core.chrome.isLocked';
Expand Down Expand Up @@ -99,6 +99,7 @@ interface StartDeps {
injectedMetadata: InjectedMetadataStart;
notifications: NotificationsStart;
uiSettings: IUiSettingsClient;
workspaces: WorkspaceStart;
}

/** @internal */
Expand Down Expand Up @@ -152,6 +153,7 @@ export class ChromeService {
injectedMetadata,
notifications,
uiSettings,
workspaces,
}: StartDeps): Promise<InternalChromeStart> {
this.initVisibility(application);

Expand Down Expand Up @@ -243,15 +245,15 @@ export class ChromeService {
badge$={badge$.pipe(takeUntil(this.stop$))}
basePath={http.basePath}
breadcrumbs$={breadcrumbs$.pipe(takeUntil(this.stop$))}
customNavLink$={customNavLink$.pipe(takeUntil(this.stop$))}
opensearchDashboardsDocLink={docLinks.links.opensearchDashboards.introduction}
forceAppSwitcherNavigation$={navLinks.getForceAppSwitcherNavigation$()}
helpExtension$={helpExtension$.pipe(takeUntil(this.stop$))}
helpSupportUrl$={helpSupportUrl$.pipe(takeUntil(this.stop$))}
homeHref={http.basePath.prepend('/app/home')}
isVisible$={this.isVisible$}
opensearchDashboardsVersion={injectedMetadata.getOpenSearchDashboardsVersion()}
navLinks$={navLinks.getNavLinks$()}
navLinks$={navLinks.getFilteredNavLinks$()}
customNavLink$={customNavLink$.pipe(takeUntil(this.stop$))}
recentlyAccessed$={recentlyAccessed.get$()}
navControlsLeft$={navControls.getLeft$()}
navControlsCenter$={navControls.getCenter$()}
Expand All @@ -262,6 +264,7 @@ export class ChromeService {
isLocked$={getIsNavDrawerLocked$}
branding={injectedMetadata.getBranding()}
survey={injectedMetadata.getSurvey()}
workspaces={workspaces}
/>
),

Expand Down
9 changes: 8 additions & 1 deletion src/core/public/chrome/nav_links/nav_link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,22 @@ export interface ChromeNavLink {
* Disables a link from being clickable.
*
* @internalRemarks
* This is only used by the ML and Graph plugins currently. They use this field
* This is used by the ML and Graph plugins. They use this field
* to disable the nav link when the license is expired.
* This is also used by recently visited category in left menu
* to disable "No recently visited items".
*/
readonly disabled?: boolean;

/**
* Hides a link from the navigation.
*/
readonly hidden?: boolean;

/**
* Links can be navigated through url.
*/
readonly externalLink?: boolean;
}

/** @public */
Expand Down
39 changes: 37 additions & 2 deletions src/core/public/chrome/nav_links/nav_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ export interface ChromeNavLinks {
*/
getNavLinks$(): Observable<Array<Readonly<ChromeNavLink>>>;

/**
* Set an observable for a sorted list of filtered navlinks.
*/
getFilteredNavLinks$(): Observable<Array<Readonly<ChromeNavLink>>>;

/**
* Set filtered navlinks.
*/
setFilteredNavLinks(filteredNavLinks: ReadonlyMap<string, ChromeNavLink>): void;

/**
* Get the state of a navlink at this point in time.
* @param id
Expand Down Expand Up @@ -116,6 +126,9 @@ type LinksUpdater = (navLinks: Map<string, NavLinkWrapper>) => Map<string, NavLi

export class NavLinksService {
private readonly stop$ = new ReplaySubject(1);
private filteredNavLinks$ = new BehaviorSubject<ReadonlyMap<string, ChromeNavLink> | undefined>(
undefined
);

public start({ application, http }: StartDeps): ChromeNavLinks {
const appLinks$ = application.applications$.pipe(
Expand All @@ -140,8 +153,8 @@ export class NavLinksService {
return linkUpdaters.reduce((links, updater) => updater(links), appLinks);
})
)
.subscribe((navlinks) => {
navLinks$.next(navlinks);
.subscribe((navLinks) => {
navLinks$.next(navLinks);
});

const forceAppSwitcherNavigation$ = new BehaviorSubject(false);
Expand All @@ -151,6 +164,21 @@ export class NavLinksService {
return navLinks$.pipe(map(sortNavLinks), takeUntil(this.stop$));
},

setFilteredNavLinks: (filteredNavLinks: ReadonlyMap<string, ChromeNavLink>) => {
this.filteredNavLinks$.next(filteredNavLinks);
},

getFilteredNavLinks$: () => {
return combineLatest([navLinks$, this.filteredNavLinks$]).pipe(
map(([navLinks, filteredNavLinks]) =>
filteredNavLinks === undefined
? sortNavLinks(navLinks)
: sortChromeNavLinks(filteredNavLinks)
),
takeUntil(this.stop$)
);
},

get(id: string) {
const link = navLinks$.value.get(id);
return link && link.properties;
Expand Down Expand Up @@ -215,3 +243,10 @@ function sortNavLinks(navLinks: ReadonlyMap<string, NavLinkWrapper>) {
'order'
);
}

function sortChromeNavLinks(chromeNavLinks: ReadonlyMap<string, ChromeNavLink>) {
return sortBy(
[...chromeNavLinks.values()].map((link) => link as Readonly<ChromeNavLink>),
'order'
);
}
Loading
Loading