diff --git a/common/interfaces.ts b/common/interfaces.ts index 0a26e4f9..8f42d379 100644 --- a/common/interfaces.ts +++ b/common/interfaces.ts @@ -16,6 +16,9 @@ export type Index = { /** ********** WORKFLOW TYPES/INTERFACES ********** */ +export type MDSQueryParams = { + dataSourceId?: string; +}; export type ConfigFieldType = | 'string' diff --git a/common/utils.ts b/common/utils.ts index 6a5b9c0f..b6892191 100644 --- a/common/utils.ts +++ b/common/utils.ts @@ -5,7 +5,22 @@ import moment from 'moment'; import { DATE_FORMAT_PATTERN } from './'; +import { isEmpty } from 'lodash'; export function toFormattedDate(timestampMillis: number): String { return moment(new Date(timestampMillis)).format(DATE_FORMAT_PATTERN); } + +const PERMISSIONS_ERROR_PATTERN = /no permissions for \[(.+)\] and User \[name=(.+), backend_roles/; + +export const prettifyErrorMessage = (rawErrorMessage: string) => { + if (isEmpty(rawErrorMessage) || rawErrorMessage === 'undefined') { + return 'Unknown error is returned.'; + } + const match = rawErrorMessage.match(PERMISSIONS_ERROR_PATTERN); + if (isEmpty(match)) { + return rawErrorMessage; + } else { + return `User ${match[2]} has no permissions to [${match[1]}].`; + } +}; diff --git a/opensearch_dashboards.json b/opensearch_dashboards.json index f11b3401..49348747 100644 --- a/opensearch_dashboards.json +++ b/opensearch_dashboards.json @@ -9,5 +9,5 @@ "navigation", "opensearchDashboardsUtils" ], - "optionalPlugins": [] + "optionalPlugins": ["dataSource","dataSourceManagement"] } \ No newline at end of file diff --git a/public/app.tsx b/public/app.tsx index f2a352c8..78e29ef1 100644 --- a/public/app.tsx +++ b/public/app.tsx @@ -4,7 +4,12 @@ */ import React from 'react'; -import { Route, RouteComponentProps, Switch } from 'react-router-dom'; +import { + Route, + RouteComponentProps, + Switch, + useLocation, +} from 'react-router-dom'; import { EuiPageSideBar, EuiSideNav, @@ -18,13 +23,24 @@ import { WorkflowDetailRouterProps, WorkflowsRouterProps, } from './pages'; +import { MountPoint } from '../../../src/core/public'; +import { + constructHrefWithDataSourceId, + getDataSourceFromURL, +} from './utils/utils'; // styling import './global-styles.scss'; -interface Props extends RouteComponentProps {} +interface Props extends RouteComponentProps { + setHeaderActionMenu: (menuMount?: MountPoint) => void; +} export const FlowFrameworkDashboardsApp = (props: Props) => { + const { setHeaderActionMenu } = props; + const location = useLocation(); + const queryParams = getDataSourceFromURL(location); + const dataSourceId = queryParams.dataSourceId; const sidebar = (