Skip to content

Commit

Permalink
Revert [Manual Backport][2.x][Data Source] Restrict to manage data so…
Browse files Browse the repository at this point in the history
…urce on the DSM UI (opensearch-project#7303)

Signed-off-by: yubonluo <[email protected]>
  • Loading branch information
yubonluo committed Jul 23, 2024
1 parent fe9bde8 commit 4d11738
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 1,263 deletions.
2 changes: 0 additions & 2 deletions changelogs/fragments/7214.yml

This file was deleted.

6 changes: 0 additions & 6 deletions config/opensearch_dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,6 @@
# AWSSigV4:
# enabled: true

# Optional setting that controls the permissions of data source to create, update and delete.
# "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"

# 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
6 changes: 0 additions & 6 deletions src/plugins/data_source/common/data_sources/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,3 @@ export enum DataSourceEngineType {
Elasticsearch = 'Elasticsearch',
NA = 'No Engine Type Available',
}

export enum ManageableBy {
All = 'all',
DashboardAdmin = 'dashboard_admin',
None = 'none',
}
4 changes: 0 additions & 4 deletions src/plugins/data_source/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ export const configSchema = schema.object({
enabled: schema.boolean({ defaultValue: true }),
}),
}),
manageableBy: schema.oneOf(
[schema.literal('all'), schema.literal('dashboard_admin'), schema.literal('none')],
{ defaultValue: 'all' }
),
});

export type DataSourcePluginConfigType = TypeOf<typeof configSchema>;
21 changes: 0 additions & 21 deletions src/plugins/data_source/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import { registerTestConnectionRoute } from './routes/test_connection';
import { registerFetchDataSourceMetaDataRoute } from './routes/fetch_data_source_metadata';
import { AuthenticationMethodRegistry, IAuthenticationMethodRegistry } from './auth_registry';
import { CustomApiSchemaRegistry } from './schema_registry';
import { ManageableBy } from '../common/data_sources';
import { getWorkspaceState } from '../../../../src/core/server/utils';

export class DataSourcePlugin implements Plugin<DataSourcePluginSetup, DataSourcePluginStart> {
private readonly logger: Logger;
Expand Down Expand Up @@ -83,25 +81,6 @@ export class DataSourcePlugin implements Plugin<DataSourcePluginSetup, DataSourc
dataSourceSavedObjectsClientWrapper.wrapperFactory
);

const { manageableBy } = config;
core.capabilities.registerProvider(() => ({
dataSource: {
canManage: false,
},
}));

core.capabilities.registerSwitcher((request) => {
const { requestWorkspaceId, isDashboardAdmin } = getWorkspaceState(request);
// User can not manage data source in the workspace.
const canManage =
(manageableBy === ManageableBy.All && !requestWorkspaceId) ||
(manageableBy === ManageableBy.DashboardAdmin &&
isDashboardAdmin !== false &&
!requestWorkspaceId);

return { dataSource: { canManage } };
});

core.logging.configure(
this.config$.pipe<LoggerContextConfigInput>(
map((dataSourceConfig) => ({
Expand Down
Loading

0 comments on commit 4d11738

Please sign in to comment.