Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Updated cache for the sub tree in Workbench #2351

Merged
merged 7 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/types/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
}

export interface ITabQueryResults {
[tabId: string]: any;

Check warning on line 70 in common/types/explorer.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
}

export interface ITabQueries {
Expand Down Expand Up @@ -133,17 +133,17 @@
side?: string | undefined
) => void;
http: CoreStart['http'];
tabCreatedTypes?: any;

Check warning on line 136 in common/types/explorer.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
searchBarConfigs?: any;

Check warning on line 137 in common/types/explorer.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
appId?: string;
addVisualizationToPanel?: any;

Check warning on line 139 in common/types/explorer.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
startTime?: string;
endTime?: string;
setStartTime?: any;

Check warning on line 142 in common/types/explorer.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
setEndTime?: any;

Check warning on line 143 in common/types/explorer.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
appBaseQuery?: string;
callback?: any;

Check warning on line 145 in common/types/explorer.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
callbackInApp?: any;

Check warning on line 146 in common/types/explorer.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
queryManager?: QueryManager;
}

Expand Down Expand Up @@ -210,10 +210,10 @@

export interface IVisualizationContainerPropsData {
appData?: { fromApp: boolean };
rawVizData?: any;

Check warning on line 213 in common/types/explorer.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
query?: IQuery;
indexFields?: IField[];
userConfigs?: any;

Check warning on line 216 in common/types/explorer.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
defaultAxes?: {
xaxis: IField[];
yaxis: IField[];
Expand Down Expand Up @@ -438,4 +438,5 @@
lang: string;
datasource: string;
sessionId?: string;
dataSourceMDSId?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,10 @@ exports[`Log Config component renders empty log config 1`] = `
"getCenter$": [MockFunction],
"getLeft$": [MockFunction],
"getLeftBottom$": [MockFunction],
"getPrimaryHeaderRight$": [MockFunction],
"getRight$": [MockFunction],
"registerCenter": [MockFunction],
"registerLeft": [MockFunction],
"registerLeftBottom": [MockFunction],
"registerPrimaryHeaderRight": [MockFunction],
"registerRight": [MockFunction],
},
"navGroup": Object {
Expand Down Expand Up @@ -762,12 +760,10 @@ exports[`Log Config component renders with query 1`] = `
"getCenter$": [MockFunction],
"getLeft$": [MockFunction],
"getLeftBottom$": [MockFunction],
"getPrimaryHeaderRight$": [MockFunction],
"getRight$": [MockFunction],
"registerCenter": [MockFunction],
"registerLeft": [MockFunction],
"registerLeftBottom": [MockFunction],
"registerPrimaryHeaderRight": [MockFunction],
"registerRight": [MockFunction],
},
"navGroup": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,10 @@ exports[`Service Config component renders empty service config 1`] = `
"getCenter$": [MockFunction],
"getLeft$": [MockFunction],
"getLeftBottom$": [MockFunction],
"getPrimaryHeaderRight$": [MockFunction],
"getRight$": [MockFunction],
"registerCenter": [MockFunction],
"registerLeft": [MockFunction],
"registerLeftBottom": [MockFunction],
"registerPrimaryHeaderRight": [MockFunction],
"registerRight": [MockFunction],
},
"navGroup": Object {
Expand Down Expand Up @@ -1444,12 +1442,10 @@ exports[`Service Config component renders with one service selected 1`] = `
"getCenter$": [MockFunction],
"getLeft$": [MockFunction],
"getLeftBottom$": [MockFunction],
"getPrimaryHeaderRight$": [MockFunction],
"getRight$": [MockFunction],
"registerCenter": [MockFunction],
"registerLeft": [MockFunction],
"registerLeftBottom": [MockFunction],
"registerPrimaryHeaderRight": [MockFunction],
"registerRight": [MockFunction],
},
"navGroup": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,10 @@ exports[`Trace Config component renders empty trace config 1`] = `
"getCenter$": [MockFunction],
"getLeft$": [MockFunction],
"getLeftBottom$": [MockFunction],
"getPrimaryHeaderRight$": [MockFunction],
"getRight$": [MockFunction],
"registerCenter": [MockFunction],
"registerLeft": [MockFunction],
"registerLeftBottom": [MockFunction],
"registerPrimaryHeaderRight": [MockFunction],
"registerRight": [MockFunction],
},
"navGroup": Object {
Expand Down Expand Up @@ -2541,12 +2539,10 @@ exports[`Trace Config component renders with one trace selected 1`] = `
"getCenter$": [MockFunction],
"getLeft$": [MockFunction],
"getLeftBottom$": [MockFunction],
"getPrimaryHeaderRight$": [MockFunction],
"getRight$": [MockFunction],
"registerCenter": [MockFunction],
"registerLeft": [MockFunction],
"registerLeftBottom": [MockFunction],
"registerPrimaryHeaderRight": [MockFunction],
"registerRight": [MockFunction],
},
"navGroup": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1237,12 +1237,10 @@ exports[`Panels View Component renders panel view container with visualizations
"getCenter$": [MockFunction],
"getLeft$": [MockFunction],
"getLeftBottom$": [MockFunction],
"getPrimaryHeaderRight$": [MockFunction],
"getRight$": [MockFunction],
"registerCenter": [MockFunction],
"registerLeft": [MockFunction],
"registerLeftBottom": [MockFunction],
"registerPrimaryHeaderRight": [MockFunction],
"registerRight": [MockFunction],
},
"navGroup": Object {
Expand Down Expand Up @@ -3146,12 +3144,10 @@ exports[`Panels View Component renders panel view container with visualizations
"getCenter$": [MockFunction],
"getLeft$": [MockFunction],
"getLeftBottom$": [MockFunction],
"getPrimaryHeaderRight$": [MockFunction],
"getRight$": [MockFunction],
"registerCenter": [MockFunction],
"registerLeft": [MockFunction],
"registerLeftBottom": [MockFunction],
"registerPrimaryHeaderRight": [MockFunction],
"registerRight": [MockFunction],
},
"navGroup": Object {
Expand Down Expand Up @@ -3609,12 +3605,10 @@ exports[`Panels View Component renders panel view container without visualizatio
"getCenter$": [MockFunction],
"getLeft$": [MockFunction],
"getLeftBottom$": [MockFunction],
"getPrimaryHeaderRight$": [MockFunction],
"getRight$": [MockFunction],
"registerCenter": [MockFunction],
"registerLeft": [MockFunction],
"registerLeftBottom": [MockFunction],
"registerPrimaryHeaderRight": [MockFunction],
"registerRight": [MockFunction],
},
"navGroup": Object {
Expand Down Expand Up @@ -5402,12 +5396,10 @@ exports[`Panels View Component renders panel view container without visualizatio
"getCenter$": [MockFunction],
"getLeft$": [MockFunction],
"getLeftBottom$": [MockFunction],
"getPrimaryHeaderRight$": [MockFunction],
"getRight$": [MockFunction],
"registerCenter": [MockFunction],
"registerLeft": [MockFunction],
"registerLeftBottom": [MockFunction],
"registerPrimaryHeaderRight": [MockFunction],
"registerRight": [MockFunction],
},
"navGroup": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,10 @@ exports[`Panel Grid Component renders panel grid component with empty visualizat
"getCenter$": [MockFunction],
"getLeft$": [MockFunction],
"getLeftBottom$": [MockFunction],
"getPrimaryHeaderRight$": [MockFunction],
"getRight$": [MockFunction],
"registerCenter": [MockFunction],
"registerLeft": [MockFunction],
"registerLeftBottom": [MockFunction],
"registerPrimaryHeaderRight": [MockFunction],
"registerRight": [MockFunction],
},
"navGroup": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ describe('AccelerationDetailsFlyout Component Tests', () => {
index="mockIndex"
acceleration={mockAcceleration}
dataSourceName="mockDataSource"
dataSourceMDSId=""
/>
);

expect(coreRefsModule.coreRefs.dslService!.fetchFields).toHaveBeenCalledWith('testIndex');
expect(coreRefsModule.coreRefs.dslService!.fetchSettings).toHaveBeenCalledWith('testIndex');
expect(coreRefsModule.coreRefs.dslService!.fetchIndices).toHaveBeenCalledWith('testIndex');
expect(coreRefsModule.coreRefs.dslService!.fetchFields).toHaveBeenCalledWith('testIndex', '');
expect(coreRefsModule.coreRefs.dslService!.fetchSettings).toHaveBeenCalledWith('testIndex', '');
expect(coreRefsModule.coreRefs.dslService!.fetchIndices).toHaveBeenCalledWith('testIndex', '');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be add test cases with MDS enabled as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay sure

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test added

});

it('switches tabs correctly', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,25 @@ export interface AccelerationDetailsFlyoutProps {
dataSourceMDSId?: string;
}

const getMappings = (index: string): Promise<OpenSearchDashboardsResponse> | undefined => {
return coreRefs.dslService?.fetchFields(index);
const getMappings = (
index: string,
dataSourceMDSId?: string
): Promise<OpenSearchDashboardsResponse> | undefined => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return Promise or undefined? is it supposed to be Promise<OpenSearchDashboardsResponse | undefined>?

return coreRefs.dslService?.fetchFields(index, dataSourceMDSId);
};

const getSettings = (index: string): Promise<OpenSearchDashboardsResponse> | undefined => {
return coreRefs.dslService?.fetchSettings(index);
const getSettings = (
index: string,
dataSourceMDSId?: string
): Promise<OpenSearchDashboardsResponse> | undefined => {
return coreRefs.dslService?.fetchSettings(index, dataSourceMDSId);
};

const getIndexInfo = (index: string): Promise<OpenSearchDashboardsResponse> | undefined => {
return coreRefs.dslService?.fetchIndices(index);
const getIndexInfo = (
index: string,
dataSourceMDSId?: string
): Promise<OpenSearchDashboardsResponse> | undefined => {
return coreRefs.dslService?.fetchIndices(index, dataSourceMDSId);
};

const handleDetailsFetchingPromise = (
Expand All @@ -59,7 +68,7 @@ const handleDetailsFetchingPromise = (
};

export const AccelerationDetailsFlyout = (props: AccelerationDetailsFlyoutProps) => {
const { dataSourceName, acceleration, resetFlyout, handleRefresh } = props;
const { dataSourceName, acceleration, resetFlyout, handleRefresh, dataSourceMDSId } = props;
const { flintIndexName } = acceleration;
const [selectedTab, setSelectedTab] = useState('details');
const tabsMap: { [key: string]: any } = {
Expand Down Expand Up @@ -113,9 +122,9 @@ export const AccelerationDetailsFlyout = (props: AccelerationDetailsFlyoutProps)

const getAccDetail = (selectedIndex: string) => {
Promise.all([
handleDetailsFetchingPromise(getMappings(selectedIndex), 'getMappings'),
handleDetailsFetchingPromise(getSettings(selectedIndex), 'getSettings'),
handleDetailsFetchingPromise(getIndexInfo(selectedIndex), 'getIndexInfo'),
handleDetailsFetchingPromise(getMappings(selectedIndex, dataSourceMDSId), 'getMappings'),
handleDetailsFetchingPromise(getSettings(selectedIndex, dataSourceMDSId), 'getSettings'),
handleDetailsFetchingPromise(getIndexInfo(selectedIndex, dataSourceMDSId), 'getIndexInfo'),
])
.then((results) => {
updateMapping(results[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ export const CreateAcceleration = ({
setAccelerationFormData={setAccelerationFormData}
resetFlyout={resetFlyout}
refreshHandler={refreshHandler}
dataSourceMDSId={dataSourceMDSId}
/>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ interface CreateAccelerationButtonProps {
setAccelerationFormData: React.Dispatch<React.SetStateAction<CreateAccelerationForm>>;
resetFlyout: () => void;
refreshHandler?: () => void;
dataSourceMDSId?: string;
}

export const CreateAccelerationButton = ({
accelerationFormData,
setAccelerationFormData,
resetFlyout,
refreshHandler,
dataSourceMDSId,
}: CreateAccelerationButtonProps) => {
const { setToast } = useToast();
const { loadStatus: directqueryLoadStatus, startLoading: startDirectQuery } = useDirectQuery();
Expand All @@ -45,8 +47,7 @@ export const CreateAccelerationButton = ({
query: accelerationQueryBuilder(accelerationFormData).replaceAll(SANITIZE_QUERY_REGEX, ' '),
datasource: accelerationFormData.dataSource,
};

startDirectQuery(requestPayload);
startDirectQuery(requestPayload, dataSourceMDSId);
setIsLoading(true);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,10 @@ exports[`Metrics Grid Component renders Metrics Grid Component 1`] = `
"getCenter$": [MockFunction],
"getLeft$": [MockFunction],
"getLeftBottom$": [MockFunction],
"getPrimaryHeaderRight$": [MockFunction],
"getRight$": [MockFunction],
"registerCenter": [MockFunction],
"registerLeft": [MockFunction],
"registerLeftBottom": [MockFunction],
"registerPrimaryHeaderRight": [MockFunction],
"registerRight": [MockFunction],
},
"navGroup": Object {
Expand Down Expand Up @@ -279,12 +277,10 @@ exports[`Metrics Grid Component renders Metrics Grid Component 1`] = `
"getCenter$": [MockFunction],
"getLeft$": [MockFunction],
"getLeftBottom$": [MockFunction],
"getPrimaryHeaderRight$": [MockFunction],
"getRight$": [MockFunction],
"registerCenter": [MockFunction],
"registerLeft": [MockFunction],
"registerLeftBottom": [MockFunction],
"registerPrimaryHeaderRight": [MockFunction],
"registerRight": [MockFunction],
},
"navGroup": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,10 @@ exports[`Dashboard component renders dashboard 1`] = `
"getCenter$": [MockFunction],
"getLeft$": [MockFunction],
"getLeftBottom$": [MockFunction],
"getPrimaryHeaderRight$": [MockFunction],
"getRight$": [MockFunction],
"registerCenter": [MockFunction],
"registerLeft": [MockFunction],
"registerLeftBottom": [MockFunction],
"registerPrimaryHeaderRight": [MockFunction],
"registerRight": [MockFunction],
},
"navGroup": Object {
Expand Down Expand Up @@ -498,12 +496,10 @@ exports[`Dashboard component renders dashboard 1`] = `
"getCenter$": [MockFunction],
"getLeft$": [MockFunction],
"getLeftBottom$": [MockFunction],
"getPrimaryHeaderRight$": [MockFunction],
"getRight$": [MockFunction],
"registerCenter": [MockFunction],
"registerLeft": [MockFunction],
"registerLeftBottom": [MockFunction],
"registerPrimaryHeaderRight": [MockFunction],
"registerRight": [MockFunction],
},
"navGroup": Object {
Expand Down Expand Up @@ -2751,12 +2747,10 @@ exports[`Dashboard component renders empty dashboard 1`] = `
"getCenter$": [MockFunction],
"getLeft$": [MockFunction],
"getLeftBottom$": [MockFunction],
"getPrimaryHeaderRight$": [MockFunction],
"getRight$": [MockFunction],
"registerCenter": [MockFunction],
"registerLeft": [MockFunction],
"registerLeftBottom": [MockFunction],
"registerPrimaryHeaderRight": [MockFunction],
"registerRight": [MockFunction],
},
"navGroup": Object {
Expand Down Expand Up @@ -3145,12 +3139,10 @@ exports[`Dashboard component renders empty dashboard 1`] = `
"getCenter$": [MockFunction],
"getLeft$": [MockFunction],
"getLeftBottom$": [MockFunction],
"getPrimaryHeaderRight$": [MockFunction],
"getRight$": [MockFunction],
"registerCenter": [MockFunction],
"registerLeft": [MockFunction],
"registerLeftBottom": [MockFunction],
"registerPrimaryHeaderRight": [MockFunction],
"registerRight": [MockFunction],
},
"navGroup": Object {
Expand Down Expand Up @@ -5397,12 +5389,10 @@ exports[`Dashboard component renders empty jaeger dashboard 1`] = `
"getCenter$": [MockFunction],
"getLeft$": [MockFunction],
"getLeftBottom$": [MockFunction],
"getPrimaryHeaderRight$": [MockFunction],
"getRight$": [MockFunction],
"registerCenter": [MockFunction],
"registerLeft": [MockFunction],
"registerLeftBottom": [MockFunction],
"registerPrimaryHeaderRight": [MockFunction],
"registerRight": [MockFunction],
},
"navGroup": Object {
Expand Down Expand Up @@ -5793,12 +5783,10 @@ exports[`Dashboard component renders empty jaeger dashboard 1`] = `
"getCenter$": [MockFunction],
"getLeft$": [MockFunction],
"getLeftBottom$": [MockFunction],
"getPrimaryHeaderRight$": [MockFunction],
"getRight$": [MockFunction],
"registerCenter": [MockFunction],
"registerLeft": [MockFunction],
"registerLeftBottom": [MockFunction],
"registerPrimaryHeaderRight": [MockFunction],
"registerRight": [MockFunction],
},
"navGroup": Object {
Expand Down
Loading
Loading