Skip to content

Commit

Permalink
Hide create data source routes when data_source.manageableBy is none (#…
Browse files Browse the repository at this point in the history
…7298)

* Hide create data source routes when feature flag is enabled

Signed-off-by: Yuanqi(Ella) Zhu <[email protected]>

* Add flint related link

Signed-off-by: Yuanqi(Ella) Zhu <[email protected]>

* Changeset file for PR #7298 created/updated

---------

Signed-off-by: Yuanqi(Ella) Zhu <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
  • Loading branch information
zhyuanqi and opensearch-changeset-bot[bot] committed Jul 18, 2024
1 parent 902da44 commit 2c6e78e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/7298.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Disable certain routes when data_source.manageableBy is none ([#7298](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7298))
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,37 @@ 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: false } } },
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={['/:id']} component={EditDataSourceWithRouter} />
<Route path={['/']} component={DataSourceHomePanel} />
</Switch>
</Router>
</I18nProvider>
</OpenSearchDashboardsContextProvider>
);

expect(wrapper.find(Route)).toHaveLength(2);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,26 @@ export async function mountManagementSection(
authenticationMethodRegistry: authMethodsRegistry,
};

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

const content = (
<Router history={params.history}>
<Switch>
<Route path={['/create']}>
<CreateDataSourcePanel {...params} featureFlagStatus={featureFlagStatus} />
</Route>
{featureFlagStatus && (
{canManageDataSource && (
<Route path={['/create']}>
<CreateDataSourcePanel {...params} featureFlagStatus={featureFlagStatus} />
</Route>
)}
{featureFlagStatus && canManageDataSource && (
<Route path={['/configure/OpenSearch']}>
<CreateDataSourceWizardWithRouter />
</Route>
)}
<Route path={['/configure/:type']}>
<ConfigureDirectQueryDataSourceWithRouter notifications={notifications} />
</Route>
{canManageDataSource && (
<Route path={['/configure/:type']}>
<ConfigureDirectQueryDataSourceWithRouter notifications={notifications} />
</Route>
)}
{featureFlagStatus && (
<Route path={['/:id']}>
<EditDataSourceWithRouter />
Expand Down

0 comments on commit 2c6e78e

Please sign in to comment.