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

feat: add tips on create Board #844

Merged
merged 3 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 4 additions & 2 deletions frontend/src/app/pages/DashBoardPage/utils/board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { migrateBoardConfig } from 'app/migration/BoardConfig/migrateBoardConfig
import {
BoardInfo,
BoardType,
BoardTypeMap,
Dashboard,
DashboardConfig,
DataChart,
Expand Down Expand Up @@ -131,8 +132,9 @@ export const getInitBoardInfo = (obj: {
return boardInfo;
};

export const getInitBoardConfig = (boardType: BoardType) => {
export const getInitBoardConfig = (boardType?: BoardType) => {
const dashboardConfig: DashboardConfig = {
type: boardType || BoardTypeMap.auto,
version: '',
background: BackgroundDefault,
widgetDefaultSettings: {
Expand All @@ -143,14 +145,14 @@ export const getInitBoardConfig = (boardType: BoardType) => {
initialQuery: true,
hasQueryControl: false,
hasResetControl: false,

// auto
margin: [16, 16], //0-100
containerPadding: [16, 16], //0-100
cols: LAYOUT_COLS_MAP, //2-48 step 2
mobileMargin: [MIN_MARGIN, MIN_MARGIN],
mobileContainerPadding: [MIN_PADDING, MIN_PADDING],
// free
type: boardType,
width: 1920,
height: 1080,
gridStep: [10, 10],
Expand Down
16 changes: 15 additions & 1 deletion frontend/src/app/pages/MainPage/pages/VizPage/SaveForm.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { InfoCircleOutlined } from '@ant-design/icons';
import { Form, FormInstance, Input, Radio, TreeSelect } from 'antd';
import { ModalForm, ModalFormProps } from 'app/components';
import useI18NPrefix from 'app/hooks/useI18NPrefix';
Expand Down Expand Up @@ -133,7 +134,20 @@ export function SaveForm({ formProps, ...modalProps }: SaveFormProps) {
</Form.Item>
)}
{vizType === 'DASHBOARD' && type === CommonFormTypes.Add && (
<Form.Item name="boardType" label={t('boardType.label')}>
<Form.Item
rules={[
{
required: true,
message: t('boardType.requiredMessage'),
},
]}
name="boardType"
label={t('boardType.label')}
tooltip={{
title: t('boardType.tips'),
icon: <InfoCircleOutlined />,
}}
>
<Radio.Group>
<Radio.Button value={BoardTypeMap.auto}>
{t('boardType.auto')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { ListNav, ListPane, ListTitle } from 'app/components';
import { useDebouncedSearch } from 'app/hooks/useDebouncedSearch';
import useGetVizIcon from 'app/hooks/useGetVizIcon';
import useI18NPrefix, { I18NComponentProps } from 'app/hooks/useI18NPrefix';
import { BoardTypeMap } from 'app/pages/DashBoardPage/pages/Board/slice/types';
import { selectOrgId } from 'app/pages/MainPage/slice/selectors';
import { dispatchResize } from 'app/utils/dispatchResize';
import { CommonFormTypes } from 'globalConstants';
Expand All @@ -17,7 +16,7 @@ import { useHistory } from 'react-router';
import styled from 'styled-components/macro';
import { SPACE_XS } from 'styles/StyleConstants';
import { useAddViz } from '../../hooks/useAddViz';
import { SaveFormContext, SaveFormModel } from '../../SaveFormContext';
import { SaveFormContext } from '../../SaveFormContext';
import {
makeSelectVizTree,
selectArchivedDashboardLoading,
Expand All @@ -29,7 +28,7 @@ import {
getArchivedDashboards,
getArchivedDatacharts,
} from '../../slice/thunks';
import { FolderViewModel, VizType } from '../../slice/types';
import { FolderViewModel } from '../../slice/types';
import { Recycle } from '../Recycle';
import { FolderTree } from './FolderTree';

Expand All @@ -55,15 +54,6 @@ export const Folders = memo(
const history = useHistory();
const { showSaveForm } = useContext(SaveFormContext);
const addVizFn = useAddViz({ showSaveForm });
const getInitValues = useCallback((relType: VizType) => {
if (relType === 'DASHBOARD') {
return {
name: '',
boardType: BoardTypeMap.auto,
} as SaveFormModel;
}
return undefined;
}, []);

const getIcon = useGetVizIcon();

Expand All @@ -82,10 +72,10 @@ export const Folders = memo(
);
const archivedDatacharts = useSelector(selectArchivedDatacharts);
const archivedDashboards = useSelector(selectArchivedDashboards);
const archivedDatachartloading = useSelector(
const archivedDataChartLoading = useSelector(
selectArchivedDatachartLoading,
);
const archivedDashboardloading = useSelector(
const archivedDashboardLoading = useSelector(
selectArchivedDashboardLoading,
);
const { filteredData: filteredListData, debouncedSearch: listSearch } =
Expand Down Expand Up @@ -113,10 +103,10 @@ export const Folders = memo(
vizType: key,
type: CommonFormTypes.Add,
visible: true,
initialValues: getInitValues(key),
initialValues: undefined,
});
},
[getInitValues, orgId, history, addVizFn],
[orgId, history, addVizFn],
);

const titles = useMemo(
Expand Down Expand Up @@ -190,7 +180,7 @@ export const Folders = memo(
type="viz"
orgId={orgId}
list={filteredListData}
listLoading={archivedDashboardloading || archivedDatachartloading}
listLoading={archivedDashboardLoading || archivedDataChartLoading}
selectedId={selectedId}
onInit={recycleInit}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { BoardTypeMap } from 'app/pages/DashBoardPage/pages/Board/slice/types';
import { getInitBoardConfig } from 'app/pages/DashBoardPage/utils/board';
import { selectOrgId } from 'app/pages/MainPage/slice/selectors';
import { CommonFormTypes } from 'globalConstants';
Expand Down Expand Up @@ -50,7 +49,7 @@ export function useAddViz({ showSaveForm }) {
if (relType === 'DASHBOARD') {
try {
dataValues.config = JSON.stringify(
getInitBoardConfig(values.boardType || BoardTypeMap.auto),
getInitBoardConfig(values.boardType),
);
} catch (error) {
throw error;
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -952,9 +952,11 @@
"name": "Name",
"description": "Description",
"boardType": {
"label": "Board type",
"label": "Layout",
"auto": "Auto",
"free": "Free"
"free": "Free",
"tips": "Auto : create responsive dashboard Free : create ensure size dashboard",
"requiredMessage": "Select a Layout Type"
},
"parent": "Parent",
"root": "Root",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,9 @@
"boardType": {
"label": "布局类型",
"auto": "自动",
"free": "自由"
"free": "自由",
"tips": "自动布局 :方便快速创建响应式仪表板 自由布局 :创建精美大屏类数字应用",
"requiredMessage": "请选择一种布局方式"
},
"parent": "所属目录",
"root": "根目录",
Expand Down