Skip to content

Commit

Permalink
resolve some issues
Browse files Browse the repository at this point in the history
Signed-off-by: Kapian1234 <wanjinch@amazon.com>
  • Loading branch information
Kapian1234 committed Sep 4, 2024
1 parent 2b4362a commit e138b57
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 21 deletions.
22 changes: 15 additions & 7 deletions config/opensearch_dashboards.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
savedObjects.permission.enabled: true
server.host: '0.0.0.0'
opensearch.hosts: ['https://localhost:9200']
opensearch.ssl.verificationMode: none
opensearch.username: 'admin'
opensearch.password: 'myStrongPassword123!'
opensearch.requestHeadersWhitelist: [authorization, securitytenant]
# opensearch_security.multitenancy.enabled: false
# opensearch_security.multitenancy.tenants.preferred: ['Private', 'Global']
# opensearch_security.readonly_mode.roles: ['kibana_read_only']
# opensearch_security.cookie.secure: false
workspace.enabled: true
opensearch.ignoreVersionMismatch: true
data_source.enabled: true
# OpenSearch Dashboards is served by a back end server. This setting specifies the port to use.
#server.port: 5601

Expand Down Expand Up @@ -359,13 +373,7 @@
# This publishes the Application Usage and UI Metrics into the saved object, which can be accessed by /api/stats?extended=true&legacy=true&exclude_usage=false
# usageCollection.uiMetric.enabled: false

# Set the value to true to enable enhancements for the data plugin
# data.enhancements.enabled: false

# Set the value to true to enable dynamic config service to obtain configs from a config store. By default, it's disabled
# dynamic_config_service.enabled: false

# Set the backend roles in groups or users, whoever has the backend roles or exactly match the user ids defined in this config will be regard as dashboard admin.
# Dashboard admin will have the access to all the workspaces(workspace.enabled: true) and objects inside OpenSearch Dashboards.
# opensearchDashboards.dashboardAdmin.groups: ["dashboard_admin"]
# opensearchDashboards.dashboardAdmin.users: ["dashboard_admin"]
opensearchDashboards.dashboardAdmin.users: ['dashboard_admin']
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dashboarding"
],
"private": true,
"version": "3.0.0",
"version": "2.15.0",
"branch": "main",
"types": "./opensearch_dashboards.d.ts",
"tsdocMetadata": "./build/tsdoc-metadata.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export const WorkspaceCreatorForm = (props: WorkspaceCreatorFormProps) => {
savedObjects={savedObjects}
assignedDataSources={formData.selectedDataSources}
data-test-subj={`workspaceForm-dataSourcePanel`}
isDashboardAdmin={true}
showDataSourceManagement={true}
/>
<EuiSpacer size="s" />
<EuiSpacer size="s" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ const dataSourceConnectionsMock = [

describe('WorkspaceDetailConnectionTable', () => {
beforeEach(() => {
const mockPrepend = jest.fn().mockImplementation((path) => path);
const mockHttp = {
basePath: {
serverBasePath: '',
prepend: mockPrepend,
},
};
(useOpenSearchDashboards as jest.Mock).mockImplementation(() => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,14 @@ export const DataSourceConnectionTable = ({
const basePath = http.basePath.serverBasePath;
let url: string;
if (record.connectionType === DataSourceConnectionType.OpenSearchConnection) {
url = `${origin}${basePath}/app/dataSources/${record.id}`;
url = http.basePath.prepend(`/app/dataSources/${record.id}`, {
withoutClientBasePath: true,
});
} else {
url = `${origin}${basePath}/app/dataSources/manage/${name}?dataSourceMDSId=${record.parentId}`;
url = http.basePath.prepend(`/app/dataSources/${record.id}`, {
withoutClientBasePath: true,
});
}
return (
<EuiLink href={url} className="eui-textTruncate">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const setup = ({
assignedDataSources = [],
onChange = jest.fn(),
errors = undefined,
isDashboardAdmin = true,
showDataSourceManagement = true,
}: Partial<SelectDataSourcePanelProps>) => {
return render(
<I18nProvider>
Expand All @@ -90,7 +90,7 @@ const setup = ({
savedObjects={savedObjects}
assignedDataSources={assignedDataSources}
errors={errors}
isDashboardAdmin={isDashboardAdmin}
showDataSourceManagement={showDataSourceManagement}
/>
</OpenSearchDashboardsContextProvider>
</I18nProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ export interface SelectDataSourcePanelProps {
savedObjects: SavedObjectsStart;
assignedDataSources: DataSource[];
onChange: (value: DataSource[]) => void;
isDashboardAdmin: boolean;
showDataSourceManagement: boolean;
}

export const SelectDataSourcePanel = ({
errors,
onChange,
assignedDataSources,
savedObjects,
isDashboardAdmin,
showDataSourceManagement,
}: SelectDataSourcePanelProps) => {
const [modalVisible, setModalVisible] = useState(false);
const [selectedItems, setSelectedItems] = useState<DataSourceConnection[]>([]);
Expand Down Expand Up @@ -79,7 +78,7 @@ export const SelectDataSourcePanel = ({
return (
<EuiPanel paddingSize="none" hasBorder={false}>
<DataSourceConnectionTable
isDashboardAdmin={isDashboardAdmin}
isDashboardAdmin={showDataSourceManagement}
items={assignedDataSourceConnections}
onUnlinkDataSource={handleSingleDataSourceUnAssign}
connectionType={AssociationDataSourceModalMode.OpenSearchConnections}
Expand Down Expand Up @@ -138,13 +137,13 @@ export const SelectDataSourcePanel = ({
<div>
<EuiSpacer size="m" />
<EuiFlexGroup alignItems="center" gutterSize="s">
{isDashboardAdmin && selectedItems.length > 0 && assignedDataSources.length > 0 && (
{showDataSourceManagement && selectedItems.length > 0 && assignedDataSources.length > 0 && (
<EuiFlexItem grow={false}>{removeButton}</EuiFlexItem>
)}
{isDashboardAdmin && (
{showDataSourceManagement && (
<EuiFlexItem grow={false}>{addOpenSearchConnectionsButton}</EuiFlexItem>
)}
{isDashboardAdmin && (
{showDataSourceManagement && (
<EuiFlexItem grow={false}>{addDirectQueryConnectionsButton}</EuiFlexItem>
)}
</EuiFlexGroup>
Expand All @@ -161,7 +160,7 @@ export const SelectDataSourcePanel = ({
http={http}
mode={toggleIdSelected as AssociationDataSourceModalMode}
notifications={notifications}
logos={chrome?.logos}
logos={chrome.logos}
/>
)}
</div>
Expand Down

0 comments on commit e138b57

Please sign in to comment.