Skip to content

Commit c476851

Browse files
committed
Merge remote-tracking branch 'upstream/dev' into share
2 parents 18451fe + 959f59e commit c476851

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+298
-342
lines changed

frontend/src/app/pages/DashBoardPage/actions/widgetAction.ts

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
*/
1818
import { urlSearchTransfer } from 'app/pages/MainPage/pages/VizPage/utils';
1919
import { ChartMouseEventParams } from 'app/types/Chart';
20-
import history from 'app/utils/history';
20+
import { History } from 'history';
21+
import i18next from 'i18next';
2122
import { RootState } from 'types';
2223
import { jumpTypes } from '../constants';
2324
import { boardActions } from '../pages/Board/slice';
@@ -43,6 +44,7 @@ import {
4344
getEditWidgetData,
4445
} from '../pages/BoardEditor/slice/thunk';
4546
import { getValueByRowData } from '../utils/widget';
47+
4648
export const toggleLinkageAction =
4749
(boardEditing: boolean, boardId: string, widgetId: string, toggle: boolean) =>
4850
dispatch => {
@@ -105,11 +107,10 @@ export const tableChartClickAction =
105107

106108
export const widgetClickJumpAction =
107109
(
108-
boardId: string,
109-
editing: boolean,
110110
renderMode: VizRenderMode,
111111
widget: Widget,
112112
params: ChartMouseEventParams,
113+
history: History,
113114
) =>
114115
(dispatch, getState) => {
115116
const state = getState() as RootState;
@@ -118,17 +119,11 @@ export const widgetClickJumpAction =
118119
const jumpConfig = widget.config?.jumpConfig;
119120
const targetType = jumpConfig?.targetType || jumpTypes[0].value;
120121

121-
if (
122-
jumpConfig?.targetType === 'INTERNAL' &&
123-
!folderIds.includes(jumpConfig.target.relId)
124-
) {
125-
history.push(`/404/targetVizDeleted`);
126-
return;
127-
}
128122
const URL = jumpConfig?.URL || '';
129123
const queryName = jumpConfig?.queryName || '';
130124
const targetId = jumpConfig?.target?.relId;
131125
const jumpFieldName: string = jumpConfig?.field?.jumpFieldName || '';
126+
// table chart
132127
if (
133128
params.componentType === 'table' &&
134129
jumpFieldName !== params.seriesName
@@ -137,23 +132,33 @@ export const widgetClickJumpAction =
137132
return;
138133
}
139134
const rowDataValue = getValueByRowData(params.data, jumpFieldName);
140-
if (typeof jumpConfig?.filter === 'object' && targetType === 'INTERNAL') {
141-
const searchParamsStr = urlSearchTransfer.toUrlString({
142-
[jumpConfig?.filter?.filterId]: rowDataValue,
143-
});
144-
if (targetId) {
145-
history.push(
146-
`/organizations/${orgId}/vizs/${targetId}?${searchParamsStr}`,
147-
);
148-
}
149-
} else if (targetType === 'URL') {
135+
// jump url
136+
if (targetType === 'URL') {
150137
let jumpUrl;
151138
if (URL.indexOf('?') > -1) {
152139
jumpUrl = `${URL}&${queryName}=${rowDataValue}`;
153140
} else {
154141
jumpUrl = `${URL}?${queryName}=${rowDataValue}`;
155142
}
156143
window.location.href = jumpUrl;
144+
return;
145+
}
146+
// jump in datart
147+
if (jumpConfig?.targetType === 'INTERNAL') {
148+
if (!folderIds.includes(jumpConfig.target.relId)) {
149+
dispatch(
150+
showJumpErrorAction(renderMode, widget.dashboardId, widget.id),
151+
);
152+
return;
153+
}
154+
if (typeof jumpConfig?.filter === 'object') {
155+
const searchParamsStr = urlSearchTransfer.toUrlString({
156+
[jumpConfig?.filter?.filterId]: rowDataValue,
157+
});
158+
history.push(
159+
`/organizations/${orgId}/vizs/${targetId}?${searchParamsStr}`,
160+
);
161+
}
157162
}
158163
};
159164

@@ -246,6 +251,7 @@ export const widgetChartClickAction =
246251
renderMode: VizRenderMode,
247252
widget: Widget,
248253
params: ChartMouseEventParams,
254+
history: History,
249255
) =>
250256
dispatch => {
251257
//is tableChart
@@ -261,9 +267,7 @@ export const widgetChartClickAction =
261267
// jump
262268
const jumpConfig = widget.config?.jumpConfig;
263269
if (jumpConfig && jumpConfig.open) {
264-
dispatch(
265-
widgetClickJumpAction(boardId, editing, renderMode, widget, params),
266-
);
270+
dispatch(widgetClickJumpAction(renderMode, widget, params, history));
267271
return;
268272
}
269273
// linkage
@@ -293,3 +297,27 @@ export const widgetToClearLinkageAction =
293297
dispatch(widgetClearLinkageAction(widget, renderMode));
294298
}
295299
};
300+
301+
export const showJumpErrorAction =
302+
(renderMode: VizRenderMode, boardId: string, wid: string) => dispatch => {
303+
const errorInfo = i18next.t('viz.jump.jumpError');
304+
if (renderMode === 'edit') {
305+
dispatch(
306+
editWidgetInfoActions.setWidgetErrInfo({
307+
boardId,
308+
widgetId: wid,
309+
errInfo: errorInfo, // viz.linkage.linkageError
310+
errorType: 'interaction',
311+
}),
312+
);
313+
} else {
314+
dispatch(
315+
boardActions.setWidgetErrInfo({
316+
boardId,
317+
widgetId: wid,
318+
errInfo: errorInfo,
319+
errorType: 'interaction',
320+
}),
321+
);
322+
}
323+
};

frontend/src/app/pages/DashBoardPage/components/ActionProvider/WidgetActionProvider.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { ChartMouseEventParams } from 'app/types/Chart';
2222
import debounce from 'lodash/debounce';
2323
import { createContext, FC, memo, useMemo } from 'react';
2424
import { useDispatch } from 'react-redux';
25+
import { useHistory } from 'react-router-dom';
2526
import {
2627
widgetChartClickAction,
2728
widgetGetDataAction,
@@ -76,7 +77,7 @@ export const WidgetActionProvider: FC<{
7677
renderMode: VizRenderMode;
7778
}> = memo(({ boardEditing, boardId, orgId, renderMode, children }) => {
7879
const dispatch = useDispatch();
79-
80+
const history = useHistory();
8081
const methods = useMemo(() => {
8182
const contextValue: WidgetActionContextProps = {
8283
onEditLayerToTop: () => {
@@ -183,9 +184,11 @@ export const WidgetActionProvider: FC<{
183184
renderMode,
184185
widget,
185186
params,
187+
history,
186188
),
187189
);
188190
},
191+
189192
onWidgetClearLinkage: (widget: Widget) => {
190193
dispatch(widgetToClearLinkageAction(boardEditing, widget, renderMode));
191194
},
@@ -256,6 +259,7 @@ export const WidgetActionProvider: FC<{
256259
},
257260
};
258261
return contextValue;
262+
// eslint-disable-next-line react-hooks/exhaustive-deps
259263
}, [boardEditing, boardId, dispatch, orgId, renderMode]);
260264

261265
return (

frontend/src/app/pages/DashBoardPage/components/WidgetComponents/StatusIcon.tsx

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ import {
2525
} from '@ant-design/icons';
2626
import { Button, Tooltip } from 'antd';
2727
import useI18NPrefix from 'app/hooks/useI18NPrefix';
28-
import React, { memo, useContext } from 'react';
28+
import React, { memo, useCallback, useContext } from 'react';
2929
import styled from 'styled-components/macro';
3030
import { ERROR, PRIMARY } from 'styles/StyleConstants';
31+
import { Widget, WidgetErrorType } from '../../pages/Board/slice/types';
3132
import { WidgetActionContext } from '../ActionProvider/WidgetActionProvider';
3233

33-
export const LockFnIcon: React.FC<{
34+
export const LockIconFn: React.FC<{
3435
boardEditing: boolean;
3536
wid: string;
3637
lock: boolean;
@@ -57,7 +58,23 @@ export const LockIcon: React.FC<{
5758
</Tooltip>
5859
);
5960
};
60-
61+
export const WaitIconFn: React.FC<{ rendered: boolean; widget: Widget }> = memo(
62+
({ rendered, widget }) => {
63+
const { onWidgetGetData } = useContext(WidgetActionContext);
64+
const t = useI18NPrefix(`viz.widget.tips`);
65+
const onRefreshWidget = useCallback(() => {
66+
onWidgetGetData(widget);
67+
}, [onWidgetGetData, widget]);
68+
if (rendered) return null;
69+
return (
70+
<WaitingIcon
71+
onClick={onRefreshWidget}
72+
onMouseEnter={onRefreshWidget}
73+
title={t('waiting')}
74+
/>
75+
);
76+
},
77+
);
6178
export const WaitingIcon: React.FC<{
6279
title: React.ReactNode;
6380
onClick?: React.MouseEventHandler<HTMLSpanElement> | undefined;
@@ -88,6 +105,7 @@ export const LoadingIcon: React.FC<{ loading?: boolean }> = ({ loading }) => {
88105
/>
89106
);
90107
};
108+
91109
export const CancelLinkageIcon: React.FC<{
92110
title: React.ReactNode | undefined;
93111
onClick: React.MouseEventHandler<HTMLSpanElement> | undefined;
@@ -107,23 +125,50 @@ export const CanLinkageIcon: React.FC<{
107125
</Tooltip>
108126
);
109127
};
110-
128+
export const LinkageIconFn: React.FC<{ inLinking: boolean; widget: Widget }> =
129+
memo(({ inLinking, widget }) => {
130+
const { onWidgetClearLinkage } = useContext(WidgetActionContext);
131+
const t = useI18NPrefix(`viz.widget.tips`);
132+
if (inLinking) {
133+
return (
134+
<CancelLinkageIcon
135+
title={t('cancelLinkage')}
136+
onClick={() => onWidgetClearLinkage(widget)}
137+
/>
138+
);
139+
} else {
140+
return widget.config?.linkageConfig?.open ? (
141+
<CanLinkageIcon title={t('canLinkage')} />
142+
) : null;
143+
}
144+
});
111145
const StyledErrorIcon = styled(Button)`
112146
background: ${p => p.theme.componentBackground};
113147
&:hover,
114148
&:focus {
115149
background: ${p => p.theme.componentBackground};
116150
}
117151
`;
152+
118153
export const ErrorIcon: React.FC<{
119-
errInfo: React.ReactNode;
120-
}> = ({ errInfo }) => {
154+
errInfo?: Record<WidgetErrorType, string>;
155+
}> = memo(({ errInfo }) => {
156+
if (!errInfo) return null;
157+
const errorInfos = Object.values(errInfo);
158+
if (!errorInfos.length) return null;
159+
const errHtml = (
160+
<div style={{ maxHeight: '200px', maxWidth: '400px', overflow: 'auto' }}>
161+
{errorInfos.map((item, i) => {
162+
return <p key={i}>{String(item)}</p>;
163+
})}
164+
</div>
165+
);
121166
return (
122-
<Tooltip title={errInfo}>
167+
<Tooltip title={errHtml}>
123168
<StyledErrorIcon
124169
icon={<WarningTwoTone twoToneColor={ERROR} />}
125170
type="link"
126171
/>
127172
</Tooltip>
128173
);
129-
};
174+
});

frontend/src/app/utils/history.ts renamed to frontend/src/app/pages/DashBoardPage/components/WidgetComponents/WidgetDropdown.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,21 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
19-
import { createBrowserHistory } from 'history';
20-
const history = createBrowserHistory();
21-
export default history;
18+
import { EllipsisOutlined } from '@ant-design/icons';
19+
import { Button, Dropdown } from 'antd';
20+
import { memo, ReactElement } from 'react';
21+
export const WidgetDropdown: React.FC<{ overlay: ReactElement }> = memo(
22+
({ overlay }) => {
23+
return (
24+
<Dropdown
25+
className="widget-tool-dropdown"
26+
overlay={overlay}
27+
placement="bottomCenter"
28+
trigger={['click']}
29+
arrow
30+
>
31+
<Button icon={<EllipsisOutlined />} type="link" />
32+
</Dropdown>
33+
);
34+
},
35+
);

frontend/src/app/pages/DashBoardPage/components/WidgetComponents/WidgetWrapper.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,8 @@ const Wrapper = styled.div`
3737
display: flex;
3838
flex: 1;
3939
min-height: 0;
40+
41+
&:hover .widget-tool-dropdown {
42+
visibility: visible;
43+
}
4044
`;

frontend/src/app/pages/DashBoardPage/components/WidgetMapper/WidgetMapper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { memo, useContext } from 'react';
1919
import { BoardType, MediaWidgetType } from '../../pages/Board/slice/types';
2020
import { WidgetDataProvider } from '../WidgetProvider/WidgetDataProvider';
2121
import { WidgetContext } from '../WidgetProvider/WidgetProvider';
22-
import { ControllerWidget } from '../Widgets/ControlWidget/ControlWidget';
22+
import { ControllerWidget } from '../Widgets/ControllerWidget/ControllerWidget';
2323
import { DataChartWidget } from '../Widgets/DataChartWidget/DataChartWidget';
2424
import { IframeWidget } from '../Widgets/IframeWidget/IframeWidget';
2525
import { ImageWidget } from '../Widgets/ImageWidget/ImageWidget';

frontend/src/app/pages/DashBoardPage/components/Widgets/ControlWidget/Controller/CheckboxGroupController.tsx renamed to frontend/src/app/pages/DashBoardPage/components/Widgets/ControllerWidget/Controller/CheckboxGroupController.tsx

File renamed without changes.

frontend/src/app/pages/DashBoardPage/components/Widgets/ControlWidget/Controller/MultiSelectController.tsx renamed to frontend/src/app/pages/DashBoardPage/components/Widgets/ControllerWidget/Controller/MultiSelectController.tsx

File renamed without changes.

frontend/src/app/pages/DashBoardPage/components/Widgets/ControlWidget/Controller/NumberController.tsx renamed to frontend/src/app/pages/DashBoardPage/components/Widgets/ControllerWidget/Controller/NumberController.tsx

File renamed without changes.

frontend/src/app/pages/DashBoardPage/components/Widgets/ControlWidget/Controller/RadioGroupController.tsx renamed to frontend/src/app/pages/DashBoardPage/components/Widgets/ControllerWidget/Controller/RadioGroupController.tsx

File renamed without changes.

0 commit comments

Comments
 (0)