diff --git a/src/core/public/saved_objects/saved_objects_client.ts b/src/core/public/saved_objects/saved_objects_client.ts index 6e5482614e40..88495e2c2bef 100644 --- a/src/core/public/saved_objects/saved_objects_client.ts +++ b/src/core/public/saved_objects/saved_objects_client.ts @@ -491,7 +491,7 @@ export class SavedObjectsClient { return new SimpleSavedObject(this, options); } - private getPath(path: Array): string { + public getPath(path: Array): string { return resolveUrl(API_BASE_URL, join(...path)); } diff --git a/src/core/public/saved_objects/simple_saved_object.ts b/src/core/public/saved_objects/simple_saved_object.ts index 71b1445e95aa..42268e02f26f 100644 --- a/src/core/public/saved_objects/simple_saved_object.ts +++ b/src/core/public/saved_objects/simple_saved_object.ts @@ -31,7 +31,7 @@ import { set } from '@elastic/safer-lodash-set'; import { get, has } from 'lodash'; import { SavedObject as SavedObjectType } from '../../server'; -import { SavedObjectsClientContract } from './saved_objects_client'; +import { SavedObjectsClient } from './saved_objects_client'; /** * This class is a very simple wrapper for SavedObjects loaded from the server @@ -51,10 +51,10 @@ export class SimpleSavedObject { public migrationVersion: SavedObjectType['migrationVersion']; public error: SavedObjectType['error']; public references: SavedObjectType['references']; - public updated_at: SavedObjectType['updated_at']; + public updated_at: SavedObjectType['updated_at'] constructor( - private client: SavedObjectsClientContract, + private client: SavedObjectsClient, { id, type, diff --git a/src/plugins/vis_type_drilldown/public/drilldown_options.tsx b/src/plugins/vis_type_drilldown/public/drilldown_options.tsx index 6060414ba4d0..adfa134bc82b 100644 --- a/src/plugins/vis_type_drilldown/public/drilldown_options.tsx +++ b/src/plugins/vis_type_drilldown/public/drilldown_options.tsx @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import React, { useCallback, useState } from 'react'; +import React, { useCallback, Fragment, useState, useEffect, useRef } from 'react'; import { EuiPanel, EuiTitle, @@ -12,11 +12,13 @@ import { EuiFlexItem, EuiFieldText, EuiAccordion, + EuiSuperSelect, + EuiText, } from '@elastic/eui'; -import { FormattedMessage } from '@osd/i18n/react'; import { VisOptionsProps } from 'src/plugins/vis_default_editor/public'; -import { DrilldownVisParams } from './types'; +import { useOpenSearchDashboards } from '../../opensearch_dashboards_react/public'; +import { DrilldownServices, DrilldownVisParams } from './types'; function DrilldownOptions({ stateParams, setValue }: VisOptionsProps) { const onMarkdownUpdate = useCallback( @@ -24,11 +26,77 @@ function DrilldownOptions({ stateParams, setValue }: VisOptionsProps(); + + interface List { + value: string; + inputDisplay: string; + dropdownDisplay: JSX.Element; // Adjust the type based on the actual type of dropdownDisplay + } + + const options = useRef([ + { + value: '1', + inputDisplay: 'Option 1', + dropdownDisplay: ( + + Name + +

+ id +
+ text +

+
+
+ ), + }, + ]); + + const saved = useRef(); + const index = useRef(); + + useEffect(() => { + const fetchData = async () => { + saved.current = savedObjects?.client.find({ + type: 'dashboard', + }); + const path = (await saved.current).savedObjects[0]['client'] + .getPath(['dashboard', (await saved.current).savedObjects[0].id]) + .substring(28); + const savedObjectURL = http.basePath.prepend('/app/dashboards#/view/' + path); + options.current = [ + { + value: savedObjectURL, + inputDisplay: 'yes', + dropdownDisplay: ( + + Name + +

+ id +
+ text +

+
+
+ ), + }, + ]; + }; + fetchData(); + }, []); + const onDescriptionUpdate = useCallback( (value: DrilldownVisParams['cardDescription']) => setValue('cardDescription', value), [setValue] ); + const activeVisName = ''; + const handleVisTypeChange = () => {}; + return ( @@ -70,6 +138,22 @@ function DrilldownOptions({ stateParams, setValue }: VisOptionsProps + + + +

+ +

+
+
+ +
diff --git a/src/plugins/vis_type_drilldown/public/types.ts b/src/plugins/vis_type_drilldown/public/types.ts index b147c2745027..54a63f10e845 100644 --- a/src/plugins/vis_type_drilldown/public/types.ts +++ b/src/plugins/vis_type_drilldown/public/types.ts @@ -3,9 +3,10 @@ * SPDX-License-Identifier: Apache-2.0 */ +import { SavedObjectsClientContract } from 'src/core/public/saved_objects/saved_objects_client'; +import { CoreStart } from 'src/core/server'; import { NavigationPublicPluginStart } from '../../navigation/public'; import { VisualizationsSetup } from '../../visualizations/public'; -import { Arguments } from '../../vis_type_markdown/public/types'; export interface VisDrilldownPluginSetup { getGreeting: () => string; @@ -39,3 +40,7 @@ export interface DrilldownVisParams { cardName: DrilldownArguments['cardName']; cardDescription: DrilldownArguments['cardDescription']; } + +export interface DrilldownServices extends CoreStart { + savedObjectsClient: SavedObjectsClientContract; +}