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

fix: DatasetVersionDetail pageChange issue #303

Merged
merged 2 commits into from
Apr 2, 2024
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: 3 additions & 3 deletions config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ const routes = [
path: '/model-app/detail/:name',
component: '@/pages/ModelAppDetail',
},
{
name: '对话管理',
process.env.NODE_ENV === 'production' ? undefined : {
name: 'GPTS chat debug (dev only)',
path: '/chat',
component: '@/pages/Chat',
},
Expand All @@ -135,7 +135,7 @@ const routes = [
},
],
},
];
].filter(Boolean);

const filterNameInProduction = routes => routes.map(route => ({
...route,
Expand Down
2 changes: 1 addition & 1 deletion src/__constants.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/pages/Chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const Chat: React.FC<IChat> = props => {
appName={appName as string}
appNamespace={appNamespace as string}
conversationId={selectedConversationId}
gpts
isDark={qiankun?.theme?.isDark}
onNewChat={onNewChat}
refresh={refresh}
Expand Down
49 changes: 31 additions & 18 deletions src/pages/DatasetVersionDetail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class DatasetVersionDetail$$Page extends React.Component {
) {
this.setState({
versionDetail:
this.props.useGetVersionedDataset.data?.VersionedDataset?.getVersionedDataset,
this.props.useGetVersionedDataset.data?.VersionedDataset?.getVersionedDataset,
});
}
}
Expand All @@ -147,16 +147,16 @@ class DatasetVersionDetail$$Page extends React.Component {
];
const body = isEdit
? {
updateLines: [
{
lineNumber: this.state.addCsvOriginData?.lineNumber,
values: line,
},
],
}
updateLines: [
{
lineNumber: this.state.addCsvOriginData?.lineNumber,
values: line,
},
],
}
: {
newLines: [line],
};
newLines: [line],
};
const errorMsg = isEdit ? '编辑数据失败' : '新增数据失败';
const res = await this.updateCsv(body, errorMsg);
if (res.status === 200) {
Expand Down Expand Up @@ -418,7 +418,7 @@ class DatasetVersionDetail$$Page extends React.Component {
this.state.cvsData?.current
}&size=10&bucket=${
this.utils.getAuthData?.()?.project
}&bucketPath=${this.getBucketPath()}&fileName=${encodeURIComponent(this.state.fileData?.path)}`,
}&bucketPath=${this.getBucketPath()}&fileName=${this.state.fileData?.path}`,
{
headers: {
Authorization: this.utils.getAuthorization(),
Expand Down Expand Up @@ -493,6 +493,19 @@ class DatasetVersionDetail$$Page extends React.Component {
});
}

onCsvPageChange(page, pageSize) {
// 页码或 pageSize 改变的回调
this.setState(
{
cvsData: {
...this.state.cvsData,
current: page,
},
},
this.getFile.bind(this)
);
}

onDatasourceChange(v) {
this.setState({
addFileDatasource: v,
Expand Down Expand Up @@ -579,9 +592,9 @@ class DatasetVersionDetail$$Page extends React.Component {
) {
this.fileUploadSuccessList = [];
this.state.upload.uploadThis?.state?.fileList?.length >= 2 &&
this.utils.notification.success({
message: '所有文件上传完成',
});
this.utils.notification.success({
message: '所有文件上传完成',
});
this.clearFileBuffer();
this.setState({
addFileLoading: false,
Expand Down Expand Up @@ -618,9 +631,9 @@ class DatasetVersionDetail$$Page extends React.Component {
)
.catch(e => {
errorMsg &&
this.utils.notification.warn({
message: errorMsg,
});
this.utils.notification.warn({
message: errorMsg,
});
});
return res;
}
Expand Down Expand Up @@ -1172,7 +1185,7 @@ class DatasetVersionDetail$$Page extends React.Component {
pagination={{
current: __$$eval(() => this.state.cvsData?.current || 1),
onChange: function () {
return this.onFilePageChange.apply(
return this.onCsvPageChange.apply(
this,
Array.prototype.slice.call(arguments).concat([])
);
Expand Down
15 changes: 15 additions & 0 deletions src/pages/ModelAppDetail/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { getUnifiedHistory } from '@tenx-ui/utils/es/UnifiedLink/index.prod';
import { Card } from 'antd';
import React, { useState } from 'react';

import { IS_PROD } from '@/__constants';
import I18N from '@/utils/kiwiI18N';

import utils from '../../../utils/__utils';
Expand Down Expand Up @@ -241,6 +242,13 @@ const Header: React.FC<HeaderProps> = props => {
key: 'delete',
label: I18N.DataHandle.shanChu,
},
// 用于 gpts 那边的对话调试
IS_PROD
? null
: {
key: 'GTPS',
label: 'GPTS chat debug (dev only)',
},
].filter(Boolean),
onClick: ({ key }) => {
switch (key) {
Expand Down Expand Up @@ -278,6 +286,13 @@ const Header: React.FC<HeaderProps> = props => {
);
break;
}
case 'GTPS': {
!IS_PROD &&
history.push(
`/chat?appNamespace=${data?.metadata?.namespace}&appName=${data?.metadata?.name}`
);
break;
}
// No default
}
},
Expand Down
Loading