Skip to content

Commit

Permalink
changes for label
Browse files Browse the repository at this point in the history
Signed-off-by: sumukhswamy <[email protected]>
  • Loading branch information
sumukhswamy committed Aug 29, 2024
1 parent 6b97d14 commit 2433e06
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,16 @@ export const getSampleNotebooksModal = (
dataSourceManagement: DataSourceManagementPluginSetup,
savedObjectsMDSClient: SavedObjectsStart,
notifications: CoreStart['notifications'],
handleSelectedDataSourceChange: (dataSourceMDSId: string | undefined) => void
handleSelectedDataSourceChange: (
dataSourceMDSId: string | undefined,
dataSourceMDSLabel: string | undefined
) => void
) => {
let DataSourceSelector;
const onSelectedDataSource = (e) => {
const dataConnectionId = e[0] ? e[0].id : undefined;
handleSelectedDataSourceChange(dataConnectionId);
const dataConnectionLabel = e[0] ? e[0].label : undefined;
handleSelectedDataSourceChange(dataConnectionId, dataConnectionLabel);
};

if (dataSourceEnabled) {
Expand Down
8 changes: 4 additions & 4 deletions public/components/notebooks/components/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export class Main extends React.Component<MainProps, MainState> {
console.error(err.body.message);
});
};
addSampleNotebooks = async (dataSourceMDSId?: string) => {
addSampleNotebooks = async (dataSourceMDSId?: string, dataSourceMDSLabel?: string) => {
try {
this.setState({ loading: true });
const flights = await this.props.http
Expand Down Expand Up @@ -357,7 +357,7 @@ export class Main extends React.Component<MainProps, MainState> {
query: {
type: 'visualization',
search_fields: 'title',
search: '[Logs] Response Codes Over Time + Annotations',
search: `[Logs] Response Codes Over Time + Annotations_${dataSourceMDSLabel}`,
},
})
.then((resp) => visIds.push(resp.saved_objects[0].id));
Expand All @@ -366,7 +366,7 @@ export class Main extends React.Component<MainProps, MainState> {
query: {
type: 'visualization',
search_fields: 'title',
search: '[Logs] Unique Visitors vs. Average Bytes',
search: `[Logs] Unique Visitors vs. Average Bytes_${dataSourceMDSLabel}`,
},
})
.then((resp) => visIds.push(resp.saved_objects[0].id));
Expand All @@ -375,7 +375,7 @@ export class Main extends React.Component<MainProps, MainState> {
query: {
type: 'visualization',
search_fields: 'title',
search: '[Flights] Flight Count and Average Ticket Price',
search: `[Flights] Flight Count and Average Ticket Price_${dataSourceMDSLabel}`,
},
})
.then((resp) => visIds.push(resp.saved_objects[0].id));
Expand Down
14 changes: 11 additions & 3 deletions public/components/notebooks/components/note_table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ const newNavigation = coreRefs.chrome?.navGroup.getNavGroupEnabled();
interface NoteTableProps {
loading: boolean;
fetchNotebooks: () => void;
addSampleNotebooks: (dataSourceMDSId: string | undefined) => void;
addSampleNotebooks: (
dataSourceMDSId: string | undefined,
dataSourceLabel: string | undefined
) => void;
notebooks: NotebookType[];
createNotebook: (newNoteName: string) => void;
renameNotebook: (newNoteName: string, noteId: string) => void;
Expand Down Expand Up @@ -96,6 +99,7 @@ export function NoteTable({
const location = useLocation();
const history = useHistory();
const [_dataSourceMDSId, setDataSourceMDSId] = useState<string | undefined>('');
const [_dataSourceMDSLabel, setDataSourceMDSLabel] = useState<string | undefined>('');

useEffect(() => {
setNavBreadCrumbs(
Expand Down Expand Up @@ -174,16 +178,20 @@ export function NoteTable({

const addSampleNotebooksModal = async () => {
let selectedDataSourceId: string | undefined;
const handleSelectedDataSourceChange = (id?: string) => {
let selectedDataSourceLabel: string | undefined;
const handleSelectedDataSourceChange = (id?: string, label?: string) => {
selectedDataSourceId = id;
selectedDataSourceLabel = label;
setDataSourceMDSId(id);
setDataSourceMDSLabel(label);
};
setModalLayout(
getSampleNotebooksModal(
closeModal,
async () => {
console.log(selectedDataSourceId, selectedDataSourceLabel);
closeModal();
await addSampleNotebooks(selectedDataSourceId);
await addSampleNotebooks(selectedDataSourceId, selectedDataSourceLabel);
},
dataSourceEnabled,
dataSourceManagement,
Expand Down

0 comments on commit 2433e06

Please sign in to comment.