♻️ refactor(channels): migrate edit components to modals structure

Move EditChannel and EditTagModal from standalone pages to modal components
within the channels module structure for consistency with other table modules.

Changes:
- Move EditChannel.js → components/table/channels/modals/EditChannelModal.jsx
- Move EditTagModal.js → components/table/channels/modals/EditTagModal.jsx
- Update import paths in channels/index.jsx
- Remove standalone routes for EditChannel from App.js
- Delete original files from pages/Channel/

This change aligns the channels module with the established modular pattern
used by tokens, users, redemptions, and other table modules, centralizing
all channel management functionality within integrated modal components
instead of separate page routes.

BREAKING CHANGE: EditChannel standalone routes (/console/channel/edit/:id
and /console/channel/add) have been removed. All channel editing is now
handled through modal components within the main channels page.
This commit is contained in:
t0ng7u
2025-07-19 00:58:18 +08:00
parent be16ad26b5
commit de9d18a2fe
4 changed files with 24 additions and 43 deletions

View File

@@ -12,7 +12,6 @@ import PasswordResetForm from './components/auth/PasswordResetForm.js';
import PasswordResetConfirm from './components/auth/PasswordResetConfirm.js'; import PasswordResetConfirm from './components/auth/PasswordResetConfirm.js';
import Channel from './pages/Channel'; import Channel from './pages/Channel';
import Token from './pages/Token'; import Token from './pages/Token';
import EditChannel from './pages/Channel/EditChannel';
import Redemption from './pages/Redemption'; import Redemption from './pages/Redemption';
import TopUp from './pages/TopUp'; import TopUp from './pages/TopUp';
import Log from './pages/Log'; import Log from './pages/Log';
@@ -61,22 +60,6 @@ function App() {
</PrivateRoute> </PrivateRoute>
} }
/> />
<Route
path='/console/channel/edit/:id'
element={
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
<EditChannel />
</Suspense>
}
/>
<Route
path='/console/channel/add'
element={
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
<EditChannel />
</Suspense>
}
/>
<Route <Route
path='/console/token' path='/console/token'
element={ element={

View File

@@ -8,8 +8,8 @@ import { useChannelsData } from '../../../hooks/channels/useChannelsData.js';
import BatchTagModal from './modals/BatchTagModal.jsx'; import BatchTagModal from './modals/BatchTagModal.jsx';
import ModelTestModal from './modals/ModelTestModal.jsx'; import ModelTestModal from './modals/ModelTestModal.jsx';
import ColumnSelectorModal from './modals/ColumnSelectorModal.jsx'; import ColumnSelectorModal from './modals/ColumnSelectorModal.jsx';
import EditChannel from '../../../pages/Channel/EditChannel.js'; import EditChannelModal from './modals/EditChannelModal.jsx';
import EditTagModal from '../../../pages/Channel/EditTagModal.js'; import EditTagModal from './modals/EditTagModal.jsx';
const ChannelsPage = () => { const ChannelsPage = () => {
const channelsData = useChannelsData(); const channelsData = useChannelsData();
@@ -24,7 +24,7 @@ const ChannelsPage = () => {
handleClose={() => channelsData.setShowEditTag(false)} handleClose={() => channelsData.setShowEditTag(false)}
refresh={channelsData.refresh} refresh={channelsData.refresh}
/> />
<EditChannel <EditChannelModal
refresh={channelsData.refresh} refresh={channelsData.refresh}
visible={channelsData.showEdit} visible={channelsData.showEdit}
handleClose={channelsData.closeEdit} handleClose={channelsData.closeEdit}

View File

@@ -1,5 +1,4 @@
import React, { useEffect, useState, useRef, useMemo } from 'react'; import React, { useEffect, useState, useRef, useMemo } from 'react';
import { useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { import {
API, API,
@@ -7,9 +6,9 @@ import {
showInfo, showInfo,
showSuccess, showSuccess,
verifyJSON, verifyJSON,
} from '../../helpers'; } from '../../../../helpers';
import { useIsMobile } from '../../hooks/common/useIsMobile.js'; import { useIsMobile } from '../../../../hooks/common/useIsMobile.js';
import { CHANNEL_OPTIONS } from '../../constants'; import { CHANNEL_OPTIONS } from '../../../../constants';
import { import {
SideSheet, SideSheet,
Space, Space,
@@ -28,7 +27,7 @@ import {
Col, Col,
Highlight, Highlight,
} from '@douyinfe/semi-ui'; } from '@douyinfe/semi-ui';
import { getChannelModels, copy, getChannelIcon, getModelCategories } from '../../helpers'; import { getChannelModels, copy, getChannelIcon, getModelCategories } from '../../../../helpers';
import { import {
IconSave, IconSave,
IconClose, IconClose,
@@ -76,9 +75,8 @@ function type2secretPrompt(type) {
} }
} }
const EditChannel = (props) => { const EditChannelModal = (props) => {
const { t } = useTranslation(); const { t } = useTranslation();
const navigate = useNavigate();
const channelId = props.editingChannel.id; const channelId = props.editingChannel.id;
const isEdit = channelId !== undefined; const isEdit = channelId !== undefined;
const [loading, setLoading] = useState(isEdit); const [loading, setLoading] = useState(isEdit);
@@ -193,7 +191,7 @@ const EditChannel = (props) => {
setInputs((inputs) => ({ ...inputs, models: localModels })); setInputs((inputs) => ({ ...inputs, models: localModels }));
} }
setBasicModels(localModels); setBasicModels(localModels);
// //
setUseManualInput(false); setUseManualInput(false);
} }
@@ -726,9 +724,9 @@ const EditChannel = (props) => {
onClick, onClick,
...rest ...rest
} = renderProps; } = renderProps;
const searchWords = channelSearchValue ? [channelSearchValue] : []; const searchWords = channelSearchValue ? [channelSearchValue] : [];
// //
const optionClassName = [ const optionClassName = [
'flex items-center gap-3 px-3 py-2 transition-all duration-200 rounded-lg mx-2 my-1', 'flex items-center gap-3 px-3 py-2 transition-all duration-200 rounded-lg mx-2 my-1',
@@ -738,12 +736,12 @@ const EditChannel = (props) => {
!disabled && 'hover:bg-gray-50 hover:shadow-md cursor-pointer', !disabled && 'hover:bg-gray-50 hover:shadow-md cursor-pointer',
className className
].filter(Boolean).join(' '); ].filter(Boolean).join(' ');
return ( return (
<div <div
style={style} style={style}
className={optionClassName} className={optionClassName}
onClick={() => !disabled && onClick()} onClick={() => !disabled && onClick()}
onMouseEnter={e => onMouseEnter()} onMouseEnter={e => onMouseEnter()}
> >
<div className="flex items-center gap-3 w-full"> <div className="flex items-center gap-3 w-full">
@@ -751,8 +749,8 @@ const EditChannel = (props) => {
{getChannelIcon(value)} {getChannelIcon(value)}
</div> </div>
<div className="flex-1 min-w-0"> <div className="flex-1 min-w-0">
<Highlight <Highlight
sourceString={label} sourceString={label}
searchWords={searchWords} searchWords={searchWords}
className="text-sm font-medium truncate" className="text-sm font-medium truncate"
/> />
@@ -760,7 +758,7 @@ const EditChannel = (props) => {
{selected && ( {selected && (
<div className="flex-shrink-0 text-blue-600"> <div className="flex-shrink-0 text-blue-600">
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor"> <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
<path d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"/> <path d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z" />
</svg> </svg>
</div> </div>
)} )}
@@ -926,7 +924,7 @@ const EditChannel = (props) => {
</Space> </Space>
</div> </div>
)} )}
{batch && ( {batch && (
<Banner <Banner
type='info' type='info'
@@ -934,7 +932,7 @@ const EditChannel = (props) => {
className='!rounded-lg mb-3' className='!rounded-lg mb-3'
/> />
)} )}
{useManualInput && !batch ? ( {useManualInput && !batch ? (
<Form.TextArea <Form.TextArea
field='key' field='key'
@@ -1466,4 +1464,4 @@ const EditChannel = (props) => {
); );
}; };
export default EditChannel; export default EditChannelModal;

View File

@@ -6,7 +6,7 @@ import {
showSuccess, showSuccess,
showWarning, showWarning,
verifyJSON, verifyJSON,
} from '../../helpers'; } from '../../../../helpers';
import { import {
SideSheet, SideSheet,
Space, Space,
@@ -26,7 +26,7 @@ import {
IconUser, IconUser,
IconCode, IconCode,
} from '@douyinfe/semi-icons'; } from '@douyinfe/semi-icons';
import { getChannelModels } from '../../helpers'; import { getChannelModels } from '../../../../helpers';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const { Text, Title } = Typography; const { Text, Title } = Typography;
@@ -441,4 +441,4 @@ const EditTagModal = (props) => {
); );
}; };
export default EditTagModal; export default EditTagModal;