Skip to content

Commit

Permalink
[Bug] fix datasource detail bug (DataLinkDC#2613)
Browse files Browse the repository at this point in the history
* fixbug-datasource-detail

* Spotless Apply

---------

Co-authored-by: Zzm0809 <[email protected]>
  • Loading branch information
Zzm0809 and Zzm0809 authored Dec 6, 2023
1 parent 6a438e5 commit 71f5d01
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 23 deletions.
3 changes: 1 addition & 2 deletions dinky-web/src/pages/Other/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { chooseTenantSubmit, login, queryDataByParams } from '@/services/Busines
import { API } from '@/services/data';
import { API_CONSTANTS } from '@/services/endpoints';
import { UserBaseInfo } from '@/types/AuthCenter/data';
import { setLocalThemeToStorage, setTenantStorageAndCookie} from '@/utils/function';
import { setLocalThemeToStorage, setTenantStorageAndCookie } from '@/utils/function';
import { useLocalStorage } from '@/utils/hook/useLocalStorage';
import { l } from '@/utils/intl';
import { ErrorMessage, SuccessMessageAsync } from '@/utils/messages';
Expand Down Expand Up @@ -84,7 +84,6 @@ const Login: React.FC = () => {

const handleChooseTenant = async (chooseTenantResult: API.Result) => {
if (chooseTenantResult.code === 0) {

await SuccessMessageAsync(
l('login.chooseTenantSuccess', '', {
msg: chooseTenantResult.msg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ import { RESPONSE_CODE } from '@/services/constants';
import { API_CONSTANTS } from '@/services/endpoints';
import { DataSources } from '@/types/RegCenter/data';
import { l } from '@/utils/intl';
import { connect } from '@@/exports';
import { BackwardOutlined, ReloadOutlined } from '@ant-design/icons';
import { Key, ProCard } from '@ant-design/pro-components';
import { useNavigate } from '@umijs/max';
import { connect, history } from '@umijs/max';
import { Button, Space } from 'antd';
import { useCallback, useEffect, useState } from 'react';

const DataSourceDetail = (props: any) => {
const navigate = useNavigate();

interface DataSourceDetailProps {
dataSource: DataSources.DataSource;
backClick: () => void;
}
const DataSourceDetail = (props: DataSourceDetailProps & connect) => {
const {
dataSource,
backClick,
Expand All @@ -56,9 +57,7 @@ const DataSourceDetail = (props: any) => {

const handleBackClick = () => {
// go back
navigate('/registration/database', {
state: { from: `/registration/database/detail/${dataSource.id}` }
});
history.push(`/registration/datasource`);
// back click callback
backClick();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,39 @@ import { API_CONSTANTS } from '@/services/endpoints';
import { DataSources } from '@/types/RegCenter/data.d';
import { l } from '@/utils/intl';
import { WarningMessage } from '@/utils/messages';
import { useNavigate } from '@@/exports';
import {
CheckCircleOutlined,
CopyTwoTone,
ExclamationCircleOutlined,
HeartTwoTone
} from '@ant-design/icons';
import { ActionType, ProList } from '@ant-design/pro-components';
import { history } from '@umijs/max';
import { Button, Descriptions, Input, Modal, Space, Tag, Tooltip } from 'antd';
import DescriptionsItem from 'antd/es/descriptions/Item';
import React, { useEffect, useState } from 'react';
import { connect } from 'umi';
import DataSourceModal from '../DataSourceModal';

const DataSourceTable: React.FC<connect & StateType> = (props) => {
const { dispatch } = props;
const navigate = useNavigate();
const { dispatch, database } = props;

/**
* state
*/
const [loading, setLoading] = React.useState<boolean>(false);
const [modalVisible, setModalVisible] = useState<boolean>(false);
const [detailPage, setDetailPage] = useState<boolean>(false);
const [dataSource, setDataSource] = useState<DataSources.DataSource[]>([]);
const [formValues, setFormValues] = useState<Partial<DataSources.DataSource>>({});
const actionRef = React.useRef<ActionType>();

const queryDataSourceList = async (keyword = '') => {
queryDataByParams(API_CONSTANTS.DATASOURCE, { keyword }).then((res) =>
setDataSource(res as DataSources.DataSource[])
);
queryDataByParams(API_CONSTANTS.DATASOURCE, { keyword }).then((res) => {
dispatch({
type: STUDIO_MODEL.saveDataBase,
payload: res
});
});
};

/**
Expand Down Expand Up @@ -176,9 +177,7 @@ const DataSourceTable: React.FC<connect & StateType> = (props) => {
payload: item.id
});
setFormValues(item);
navigate(`/registration/datasource/detail/${item.id}`, {
state: { from: '/registration/datasource' }
});
history.push(`/registration/datasource/detail/${item.id}`);
setDetailPage(!detailPage);
} else {
await WarningMessage(l('rc.ds.enter.error'));
Expand Down Expand Up @@ -243,7 +242,7 @@ const DataSourceTable: React.FC<connect & StateType> = (props) => {
/**
* render data source
*/
const renderDataSource = dataSource.map((item) => ({
const renderDataSource = database.dbData.map((item: DataSources.DataSource) => ({
subTitle: renderDataSourceSubTitle(item),
actions: <DataAction>{renderDataSourceActionButton(item)}</DataAction>,
avatar: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const DataSourceModal: React.FC<DataSourceModalProps> = (props) => {
const submitForm = async () => {
const fieldsValue = await form.validateFields();
setSubmitting(true);
await onSubmit({ ...values, ...fieldsValue });
onSubmit({ ...values, ...fieldsValue });
handleCancel();
};

Expand Down
2 changes: 1 addition & 1 deletion dinky-web/src/utils/function.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export function getLocalTheme(): string {
}

export function setLocalThemeToStorage(defaultTheme?: string) {
localStorage.setItem(THEME.NAV_THEME,defaultTheme ?? getLocalTheme()) ;
localStorage.setItem(THEME.NAV_THEME, defaultTheme ?? getLocalTheme());
}

/**
Expand Down

0 comments on commit 71f5d01

Please sign in to comment.