Skip to content

Commit

Permalink
Merge branch 'main' into feature/add-api-to-set-request-plugin-state
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe authored Apr 4, 2024
2 parents 52b601c + b92387a commit 9813351
Show file tree
Hide file tree
Showing 38 changed files with 2,347 additions and 37 deletions.
31 changes: 29 additions & 2 deletions .github/workflows/add-untriaged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,37 @@ on:
types: [opened, reopened, transferred]

jobs:
apply-label:
apply-label-if-not-collaborator:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
- name: Check if issue author is a collaborator
id: check-collaborator
uses: actions/github-script@v6
with:
script: |
const issueAuthor = context.payload.issue.user.login;
const repoOwner = context.repo.owner;
const repoName = context.repo.repo;
let isCollaborator = false;
try {
// Attempt to fetch user's permission level
await github.rest.repos.getCollaboratorPermissionLevel({
owner: repoOwner,
repo: repoName,
username: issueAuthor,
});
// If no error is thrown, the user is a collaborator
isCollaborator = true;
} catch (error) {
// Error thrown indicates the user is not a collaborator,
// or does not have explicit permission set.
console.log(`${issueAuthor} is not a collaborator.`);
}
core.setOutput('is_collaborator', isCollaborator.toString());
- name: Apply label if not a collaborator
if: steps.check-collaborator.outputs.is_collaborator == 'false'
uses: actions/github-script@v6
with:
script: |
github.rest.issues.addLabels({
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Multiple Datasource] Make sure customer always have a default datasource ([#6237](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6237))
- [Workspace] Add workspace list page ([#6182](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6182))
- [Workspace] Add workspaces column to saved objects page ([#6225](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6225))
- [Multiple Datasource] Enhanced data source selector with default datasource shows as first choice ([#6293](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6293))
- [Multiple Datasource] Add multi data source support to sample vega visualizations ([#6218](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6218))
- [Multiple Datasource] Fetch data source title for DataSourceView when only id is provided ([#6315](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6315)
- [Workspace] Add permission control logic ([#6052](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6052))
- [Multiple Datasource] Pass selected data sources to plugin consumers when the multi-select component initially loads ([#6333](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6333))
- [Workspace] Add APIs to support plugin state in request ([#6303](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6303))

### 🐛 Bug Fixes
Expand Down
12 changes: 12 additions & 0 deletions examples/multiple_data_source_examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Developer examples

The multiple data source examples adds a few pages to the developer example which is a landing page where developers go to search for working, tested examples of various developer
services. This example using the developerExamples `register` function offered on the `setup` contract to register the app.

To run the example in OpenSearch Dashboards with developer examples:

```
yarn start --run-examples
```

Then navigate to "Developer examples" and click on "Multiple Data Source Integration"
10 changes: 10 additions & 0 deletions examples/multiple_data_source_examples/opensearch_dashboards.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": "multipleDataSourceExamples",
"version": "0.0.1",
"opensearchDashboardsVersion": "opensearchDashboards",
"server": false,
"ui": true,
"requiredPlugins": ["developerExamples", "navigation"],
"optionalPlugins": ["dataSource", "dataSourceManagement"]
}

36 changes: 36 additions & 0 deletions examples/multiple_data_source_examples/public/application.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import React from 'react';
import ReactDOM from 'react-dom';
import { DataSourcePluginSetup } from 'src/plugins/data_source/public';
import { DataSourceManagementPluginSetup } from 'src/plugins/data_source_management/public';
import { NavigationPublicPluginStart } from 'src/plugins/navigation/public';
import { CoreStart, AppMountParameters } from '../../../src/core/public';
import { Home } from './components/home';

export const renderApp = (
{ notifications, http, savedObjects, application }: CoreStart,
dataSource: DataSourcePluginSetup,
dataSourceManagement: DataSourceManagementPluginSetup,
{ appBasePath, element, setHeaderActionMenu }: AppMountParameters,
navigation: NavigationPublicPluginStart
) => {
ReactDOM.render(
<Home
basename={appBasePath}
notifications={notifications}
http={http}
savedObjects={savedObjects}
dataSourceEnabled={dataSource.dataSourceEnabled}
setActionMenu={setHeaderActionMenu}
dataSourceManagement={dataSourceManagement}
navigateToApp={application.navigateToApp}
navigation={navigation}
/>,
element
);

return () => ReactDOM.unmountComponentAtNode(element);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import { EuiBasicTableColumn } from '@elastic/eui';
import { ComponentProp } from './types';

export const COLUMNS: Array<EuiBasicTableColumn<ComponentProp>> = [
{
field: 'name',
name: 'Name',
},
{
field: 'required',
name: 'Required',
},
{
field: 'defaultValue',
name: 'Default Value',
},
{
field: 'description',
name: 'Description',
},
{
field: 'deprecated',
name: 'Deprecated',
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import React from 'react';
import {
EuiBasicTable,
EuiPageBody,
EuiPageContent,
EuiPageContentBody,
EuiPageHeader,
EuiPageHeaderSection,
EuiSpacer,
EuiText,
EuiTitle,
} from '@elastic/eui';
import { MountPoint, CoreStart } from 'opensearch-dashboards/public';
import {
DataSourceAggregatedViewConfig,
DataSourceManagementPluginSetup,
} from 'src/plugins/data_source_management/public';
import { ComponentProp } from './types';
import { COLUMNS } from './constants';

interface DataSourceListActiveExampleProps {
savedObjects: CoreStart['savedObjects'];
dataSourceEnabled: boolean;
notifications: CoreStart['notifications'];
setActionMenu?: (menuMount: MountPoint | undefined) => void;
dataSourceManagement: DataSourceManagementPluginSetup;
}

export const DataSourceListActiveExample = ({
savedObjects,
dataSourceEnabled,
notifications,
setActionMenu,
dataSourceManagement,
}: DataSourceListActiveExampleProps) => {
const DataSourceMenu = dataSourceManagement.ui.getDataSourceMenu<
DataSourceAggregatedViewConfig
>();
const data: ComponentProp[] = [
{
name: 'savedObjects',
required: true,
defaultValue: '-',
description: 'The saved object client is used to fetch available data sources',
deprecated: false,
},
{
name: 'notifications',
required: true,
defaultValue: '-',
description: 'The notifications toasts object exposes interfaces to show toasts',
deprecated: false,
},
{
name: 'hideLocalCluster',
required: false,
defaultValue: 'false',
description: 'The property to hide local cluster from the data source selector',
deprecated: false,
},
{
name: 'fullWidth',
required: true,
defaultValue: '-',
description:
'The property of OutComboBox and when specified to true would expand to the entire width available',
deprecated: false,
},
{
name: 'displayAllCompatibleDataSources',
required: false,
defaultValue: 'undefined',
description: 'When specified to true, it will show all compatible data sources',
deprecated: false,
},
{
name: 'dataSourceFilter',
required: false,
defaultValue: 'undefined',
description:
'When specified, the filter function will be used to filter the available options before rendering',
deprecated: false,
},
{
name: 'activeDataSourceIds',
required: false,
defaultValue: 'undefined',
description:
'This property is only assessed when displayAllCompatibleDataSources is set to false, it is used to specify the active data source ids and the component will show active data sources',
deprecated: false,
},
];

return (
<EuiPageBody component="main">
<EuiPageHeader>
{dataSourceEnabled && (
<DataSourceMenu
setMenuMountPoint={setActionMenu}
componentType={'DataSourceAggregatedView'}
componentConfig={{
fullWidth: false,
savedObjects: savedObjects.client,
notifications,
displayAllCompatibleDataSources: true,
}}
/>
)}
<EuiPageHeaderSection>
<EuiTitle size="l">
<h1>Data Source Aggregated View To List Active Example</h1>
</EuiTitle>
</EuiPageHeaderSection>
</EuiPageHeader>
<EuiPageContent>
<EuiPageContentBody>
<EuiText>
The data source aggregated view component is introduced in 2.14 which uses
OuiContextMenu and OuiPopOver as the base components. When multi data source feature is
enabled, this component can be consumed by adding dataSourceManagement as option plugin,
and then mounted to the navigation bar by passing setHeaderActionMenu from
AppMountParameters to the getDataSourceMenu function exposed from the plugin. This
component can be used to show active connected data sources in the page. Find the
mounted example in the navigation bar
</EuiText>
<EuiSpacer />
<EuiText>
The component exposes a few properties via the DataSourceMenu component:
</EuiText>
<EuiBasicTable
tableCaption="dataSourceListActiveEuiBasicTable"
items={data}
rowHeader="name"
columns={COLUMNS}
/>
</EuiPageContentBody>
</EuiPageContent>
</EuiPageBody>
);
};
Loading

0 comments on commit 9813351

Please sign in to comment.