Skip to content

Commit

Permalink
Hide create data source routes when feature flag is enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Yuanqi(Ella) Zhu <[email protected]>
  • Loading branch information
zhyuanqi committed Jul 18, 2024
1 parent a34389e commit f35be50
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
4 changes: 2 additions & 2 deletions config/opensearch_dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
# vis_builder.enabled: false

# Set the value of this setting to true to enable multiple data source feature.
#data_source.enabled: false
data_source.enabled: true
# Set the value of this setting to true to hide local cluster in data source feature.
#data_source.hideLocalCluster: false
# Set the value of these settings to customize crypto materials to encryption saved credentials
Expand Down Expand Up @@ -325,7 +325,7 @@
# "none": The data source is readonly for all users.
# "dashboard_admin": The data source can only be managed by dashboard admin.
# "all": The data source can be managed by all users. Default to "all".
# data_source.manageableBy: "all"
data_source.manageableBy: "none"

# Set the value of this setting to false to hide the help menu link to the OpenSearch Dashboards user survey
# opensearchDashboards.survey.url: "https://survey.opensearch.org"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,43 @@ describe('mountManagementSection', () => {
expect(route.prop('path')).not.toEqual(['/:id']);
});
});

it('renders CreateDataSourcePanel when canManageDataSource is true', async () => {
const mockGetStartServices: StartServicesAccessor<DataSourceManagementStartDependencies> = jest
.fn()
.mockResolvedValue([
{
chrome: { docTitle: { reset: jest.fn() } },
application: { capabilities: { dataSource: { canManage: true } } },
savedObjects: {},
uiSettings: {},
notifications: {},
overlays: {},
http: {},
docLinks: {},
},
]);

await mountManagementSection(mockGetStartServices, mockParams, mockAuthMethodsRegistry, true);
const wrapper = shallow(
<OpenSearchDashboardsContextProvider services={{}}>
<I18nProvider>
<Router history={mockParams.history}>
<Switch>
<Route path={['/create']} />
<Route path={['/configure/OpenSearch']} />
<Route
path={['/configure/:type']}
component={ConfigureDirectQueryDataSourceWithRouter}
/>
<Route path={['/:id']} component={EditDataSourceWithRouter} />
<Route path={['/']} component={DataSourceHomePanel} />
</Switch>
</Router>
</I18nProvider>
</OpenSearchDashboardsContextProvider>
);

expect(wrapper.find(Route)).toHaveLength(5);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,21 @@ export async function mountManagementSection(
authenticationMethodRegistry: authMethodsRegistry,
};

const canManageDataSource = !!application.capabilities?.dataSource?.canManage;

ReactDOM.render(
<OpenSearchDashboardsContextProvider services={deps}>
<I18nProvider>
<Router history={params.history}>
<Switch>
<Route path={['/create']}>
<CreateDataSourcePanel {...params} featureFlagStatus={featureFlagStatus} />
{canManageDataSource ? (
<CreateDataSourcePanel {...params} featureFlagStatus={featureFlagStatus} />
) : null}
</Route>
{featureFlagStatus && (
<Route path={['/configure/OpenSearch']}>
<CreateDataSourceWizardWithRouter />
{canManageDataSource ? <CreateDataSourceWizardWithRouter /> : null}
</Route>
)}
<Route path={['/configure/:type']}>
Expand Down

0 comments on commit f35be50

Please sign in to comment.