Skip to content

Commit 99fb03d

Browse files
committed
fix(chart): fix merge chart data view hierarchy issue
1 parent a8906c7 commit 99fb03d

File tree

5 files changed

+22
-21
lines changed

5 files changed

+22
-21
lines changed

frontend/src/app/pages/ChartWorkbenchPage/slice/thunks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { ChartDTO } from 'app/types/ChartDTO';
2525
import { View } from 'app/types/View';
2626
import {
2727
buildUpdateChartRequest,
28-
convertToChartDTO2,
28+
convertToChartDto,
2929
} from 'app/utils/ChartDtoHelper';
3030
import { filterSqlOperatorName } from 'app/utils/internalChartHelper';
3131
import { request2 } from 'utils/request';
@@ -220,7 +220,7 @@ export const fetchChartAction = createAsyncThunk<
220220
method: 'GET',
221221
url: `viz/datacharts/${arg.chartId}`,
222222
});
223-
return convertToChartDTO2(response?.data);
223+
return convertToChartDto(response?.data);
224224
}
225225
return arg.backendChart as any;
226226
});

frontend/src/app/pages/MainPage/pages/VizPage/slice/thunks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { getLoggedInUserPermissions } from 'app/pages/MainPage/slice/thunks';
2727
import { StoryBoard } from 'app/pages/StoryBoardPage/slice/types';
2828
import { IChartDrillOption } from 'app/types/ChartDrillOption';
2929
import { ChartDTO } from 'app/types/ChartDTO';
30-
import { convertToChartDTO } from 'app/utils/ChartDtoHelper';
30+
import { convertToChartDto } from 'app/utils/ChartDtoHelper';
3131
import { filterSqlOperatorName } from 'app/utils/internalChartHelper';
3232
import { RootState } from 'types';
3333
import { request2 } from 'utils/request';
@@ -263,7 +263,7 @@ export const fetchVizChartAction = createAsyncThunk(
263263
url: `viz/datacharts/${arg.backendChartId}`,
264264
});
265265
return {
266-
data: convertToChartDTO(response?.data),
266+
data: convertToChartDto(response?.data),
267267
filterSearchParams: arg.filterSearchParams,
268268
};
269269
},

frontend/src/app/pages/SharePage/slice/thunks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
import { handleServerStoryAction } from 'app/pages/StoryBoardPage/slice/actions';
3030
import { ServerStoryBoard } from 'app/pages/StoryBoardPage/slice/types';
3131
import { IChartDrillOption } from 'app/types/ChartDrillOption';
32-
import { convertToChartDTO } from 'app/utils/ChartDtoHelper';
32+
import { convertToChartDto } from 'app/utils/ChartDtoHelper';
3333
import { RootState } from 'types';
3434
import persistence from 'utils/persistence';
3535
import { request2 } from 'utils/request';
@@ -99,7 +99,7 @@ export const fetchShareVizInfo = createAsyncThunk(
9999
case 'DATACHART':
100100
const shareVizInfo = {
101101
...data,
102-
vizDetail: convertToChartDTO(data.vizDetail),
102+
vizDetail: convertToChartDto(data.vizDetail),
103103
};
104104
thunkAPI.dispatch(
105105
shareActions.setDataChart({ data: shareVizInfo, filterSearchParams }),

frontend/src/app/utils/ChartDtoHelper.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,21 @@
1616
* limitations under the License.
1717
*/
1818

19+
import beginViewModelMigration from 'app/migration/ViewConfig/migrationViewModelConfig';
1920
import { ChartConfig, ChartStyleConfig } from 'app/types/ChartConfig';
2021
import { ChartConfigDTO, ChartDetailConfigDTO } from 'app/types/ChartConfigDTO';
2122
import { ChartDTO } from 'app/types/ChartDTO';
2223
import {
2324
mergeChartDataConfigs,
2425
mergeChartStyleConfigs,
2526
transformHierarchyMeta,
26-
transformMeta,
2727
} from 'app/utils/internalChartHelper';
2828
import { Omit } from 'utils/object';
2929

30-
export function convertToChartDTO(data): ChartDTO {
31-
return Object.assign({}, data, {
32-
config: JSON.parse(data?.config),
33-
view: {
34-
...Omit(data?.view, ['model']),
35-
meta: transformMeta(data?.view?.model),
36-
},
37-
});
38-
}
39-
40-
export function convertToChartDTO2(data): ChartDTO {
30+
export function convertToChartDto(data): ChartDTO {
31+
if (data?.view?.model) {
32+
data.view.model = beginViewModelMigration(data.view.model);
33+
}
4134
return Object.assign({}, data, {
4235
config: JSON.parse(data?.config),
4336
view: {

frontend/src/app/utils/__tests__/chartDtoHelper.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import {
2020
buildUpdateChartRequest,
2121
convertToChartConfigDTO,
22-
convertToChartDTO,
22+
convertToChartDto,
2323
mergeToChartConfig,
2424
} from '../ChartDtoHelper';
2525

@@ -31,11 +31,19 @@ describe('chartDtoHelper Test', () => {
3131
model: JSON.stringify({ name: 2 }),
3232
},
3333
};
34-
const dto = convertToChartDTO(data);
34+
const dto = convertToChartDto(data);
3535
expect(dto).toEqual({
3636
config: { id: 1 },
3737
view: {
38-
meta: [{ id: 'name', category: 'field' }],
38+
meta: [
39+
{
40+
name: 'name',
41+
id: 'name',
42+
subType: undefined,
43+
category: 'field',
44+
children: undefined,
45+
},
46+
],
3947
},
4048
});
4149
});

0 commit comments

Comments
 (0)