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

Refactor url structure #277

Merged
merged 1 commit into from
Apr 1, 2024
Merged
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
Refactor url structure
  • Loading branch information
yang1666204 committed Apr 1, 2024
commit b5b71a266d535fa096d5eeafa813c39197eea3d6
8 changes: 4 additions & 4 deletions ui/config/routes.ts
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ export default [
],
},
{
path: 'cluster/:clusterId',
path: 'cluster/:ns/:name/:clusterName',
component: 'Cluster/Detail',
name: '集群详情',
routes: [
@@ -71,14 +71,14 @@ export default [
name: '集群下的租户',
},
{
path: '/cluster/:clusterId',
path: '/cluster/:ns/:name/:clusterName',
redirect: 'overview',
name: '概览页',
},
],
},
{
path: 'tenant/:tenantId',
path: 'tenant/:ns/:name/:tenantName',
component: 'Tenant/Detail',
name: '租户详情',
routes: [
@@ -108,7 +108,7 @@ export default [
name: '租户详情监控',
},
{
path: '/tenant/:tenantId',
path: '/tenant/:ns/:name/:tenantName',
redirect: 'overview',
name: '概览页',
},
7 changes: 3 additions & 4 deletions ui/src/components/TopoComponent/index.tsx
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import { useRequest,useUpdateEffect } from 'ahooks';
import { message } from 'antd';
import _ from 'lodash';
import { ReactElement,useEffect,useMemo,useRef,useState } from 'react';
import { useModel } from '@umijs/max';
import { useParams } from '@umijs/max';

import showDeleteConfirm from '@/components/customModal/DeleteModal';
import OperateModal from '@/components/customModal/OperateModal';
@@ -16,7 +16,6 @@ import { getClusterFromTenant, getOriginResourceUsages, getZonesOptions } from '
import { getClusterDetailReq } from '@/services';
import { deleteClusterReportWrap, deleteObzoneReportWrap } from '@/services/reportRequest/clusterReportReq';
import { deleteObtenantPool } from '@/services/tenant';
import { getNSName } from '../../pages/Cluster/Detail/Overview/helper';
import { ReactNode,config } from './G6register';
import type { OperateTypeLabel } from './constants';
import {
@@ -48,6 +47,7 @@ export default function TopoComponent({
refreshTenant,
defaultUnitCount,
}: TopoProps) {
const { ns:urlNs, name:urlName } = useParams();
const clusterOperateList = tenantReplicas
? clusterOperateOfTenant
: clusterOperate;
@@ -61,7 +61,7 @@ export default function TopoComponent({
const [[ns, name]] = useState(
namespace && clusterNameOfKubectl
? [namespace, clusterNameOfKubectl]
: getNSName(),
: [urlNs, urlName],
);

//Control the visibility of operation and maintenance modal
@@ -194,7 +194,6 @@ export default function TopoComponent({
};
// delete resource pool
const deleteResourcePool = async (zoneName: string) => {
const [ns, name] = getNSName();
const res = await deleteObtenantPool({ ns, name, zoneName });
if (res.successful) {
if (refreshTenant) refreshTenant();
4 changes: 2 additions & 2 deletions ui/src/components/customModal/ActivateTenantModal.tsx
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { intl } from '@/utils/intl';
import { useRequest } from 'ahooks';
import { message } from 'antd';

import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
import { useParams } from '@umijs/max';
import { changeTenantRole } from '@/services/tenant';
import type { CommonModalType } from '.';
import CustomModal from '.';
@@ -12,6 +12,7 @@ export default function ActivateTenantModal({
setVisible,
successCallback,
}: CommonModalType) {
const { ns, name } = useParams();
const { run: activateTenant } = useRequest(changeTenantRole, {
manual: true,
onSuccess: ({ successful }) => {
@@ -28,7 +29,6 @@ export default function ActivateTenantModal({
},
});
const handleSubmit = async () => {
const [ns, name] = getNSName();
await activateTenant({ ns, name, failover: true });
};
const handleCancel = () => setVisible(false);
4 changes: 2 additions & 2 deletions ui/src/components/customModal/AddZoneModal.tsx
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { intl } from '@/utils/intl';
import { Form, Input, message } from 'antd';

import { RULER_ZONE } from '@/constants/rules';
import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
import { useParams } from '@umijs/max';
import { addObzoneReportWrap } from '@/services/reportRequest/clusterReportReq';
import InputNumber from '../InputNumber';
import type { CommonModalType } from '.';
@@ -19,6 +19,7 @@ export default function AddZoneModal({
successCallback,
}: CommonModalType) {
const [form] = Form.useForm();
const { ns:namespace, name } = useParams();
const handleSubmit = async () => {
try {
await form.validateFields();
@@ -31,7 +32,6 @@ export default function AddZoneModal({
setVisible(false);
}
const onFinish = async (values: any) => {
const [namespace, name] = getNSName();
const res = await addObzoneReportWrap({ namespace, name, ...values});
if (res.successful) {
message.success(res.message);
6 changes: 3 additions & 3 deletions ui/src/components/customModal/LogReplayModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
import { useParams } from '@umijs/max';

import { replayLogOfTenant } from '@/services/tenant';
import { intl } from '@/utils/intl';
import { DatePicker, Form, TimePicker, message } from 'antd';
@@ -15,7 +16,7 @@ export default function LogReplayModal({
successCallback,
}: CommonModalType) {
const [form] = Form.useForm();

const { ns:namespace, name } = useParams();
const handleSubmit = async () => {
try {
await form.validateFields();
@@ -25,7 +26,6 @@ export default function LogReplayModal({

const handleCancel = () => setVisible(false);
const onFinish = async (values: any) => {
const [namespace, name] = getNSName();
const res = await replayLogOfTenant({ namespace, name, ...values });
if (res.successful) {
message.success(res.message);
6 changes: 3 additions & 3 deletions ui/src/components/customModal/ModifyPasswordModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
import { useParams } from '@umijs/max';
import { changeTenantPassword } from '@/services/tenant';
import { intl } from '@/utils/intl';
import { Form, Input, message } from 'antd';
@@ -16,6 +16,7 @@ export default function ModifyPasswordModal({
successCallback,
}: CommonModalType) {
const [form] = Form.useForm();
const { ns, name } = useParams();
const publicKey = usePublicKey()

const handleSubmit = async () => {
@@ -27,9 +28,8 @@ export default function ModifyPasswordModal({

const handleCancel = () => setVisible(false);
const onFinish = async (values: any) => {
const [namespace, name] = getNSName();
const res = await changeTenantPassword({
ns: namespace,
ns,
name,
User: 'root',
Password: encryptText(values.password,publicKey) as string,
8 changes: 4 additions & 4 deletions ui/src/components/customModal/ModifyUnitDetailModal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import InputNumber from '@/components/InputNumber';
import { SUFFIX_UNIT,getMinResource } from '@/constants';
import { RULER_ZONE } from '@/constants/rules';
import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
import { useParams } from '@umijs/max';
import { TooltipItemContent } from '@/pages/Cluster/New/Observer';
import type {
MaxResourceType,
@@ -14,7 +14,7 @@ modifyZoneCheckedStatus,
} from '@/pages/Tenant/helper';
import {
patchObtenantPoolReportWrap,
createTenantReportWrap
createObtenantPoolReportWrap
} from '@/services/reportRequest/tenantReportReq';
import { formatPatchPoolData } from '@/utils/helper';
import { intl } from '@/utils/intl';
@@ -84,6 +84,7 @@ export default function ModifyUnitDetailModal({
},
}: CommonModalType & UnitConfigType) {
const [form] = Form.useForm<PoolDetailType>();
const { ns, name } = useParams();
const [maxResource, setMaxResource] = useState<MaxResourceType>({});
const [minResource, setMinResource] = useState<MinResourceConfig>(
getMinResource({ minMemory: essentialParameter.minPoolMemory }),
@@ -93,7 +94,7 @@ export default function ModifyUnitDetailModal({
);
const selectZone = Form.useWatch('selectZone', form);
const obtenantPoolReq = newResourcePool
? createTenantReportWrap
? createObtenantPoolReportWrap
: patchObtenantPoolReportWrap;

const handleSubmit = async () => {
@@ -112,7 +113,6 @@ export default function ModifyUnitDetailModal({
};

const onFinish = async (values: any) => {
const [ns, name] = getNSName();
const { zoneName, ...reqData } = formatPatchPoolData(
values,
newResourcePool ? 'create' : 'edit',
6 changes: 3 additions & 3 deletions ui/src/components/customModal/ModifyUnitModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
import { useParams } from '@umijs/max';
import { modifyUnitNumReportWrap } from '@/services/reportRequest/tenantReportReq';
import { intl } from '@/utils/intl';
import { Form,InputNumber,message } from 'antd';
@@ -19,6 +19,7 @@ export default function ModifyUnitModal({
successCallback,
}: CommonModalType & { params: { defaultUnitCount: number } }) {
const [form] = Form.useForm();
const { ns, name } = useParams();
const { defaultUnitCount } = params;
const handleSubmit = async () => {
try {
@@ -29,9 +30,8 @@ export default function ModifyUnitModal({

const handleCancel = () => setVisible(false);
const onFinish = async (values: any) => {
const [namespace, name] = getNSName();
const res = await modifyUnitNumReportWrap({
ns: namespace,
ns,
name,
...values,
});
4 changes: 2 additions & 2 deletions ui/src/components/customModal/ScaleModal.tsx
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { intl } from '@/utils/intl';
import { Form, InputNumber, message } from 'antd';
import CustomModal from '.';

import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
import { useParams } from '@umijs/max';
import { scaleObserverReportWrap } from '@/services/reportRequest/clusterReportReq';
import { useEffect } from 'react';
import type { CommonModalType } from '.';
@@ -21,6 +21,7 @@ export default function ScaleModal({
params,
}: ScaleModalProps & CommonModalType) {
const zoneName = params?.zoneName;
const { ns:namespace, name } = useParams();
const defaultValue = params?.defaultValue;
const [form] = Form.useForm();
const handleSubmit = async () => {
@@ -31,7 +32,6 @@ export default function ScaleModal({
};
const onFinish = async (val: any) => {
if (!zoneName) throw new Error('zoneName is not defined');
const [namespace, name] = getNSName();
const res = await scaleObserverReportWrap({
namespace,
name,
4 changes: 2 additions & 2 deletions ui/src/components/customModal/SwitchTenantModal.tsx
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { intl } from '@/utils/intl';
import { useRequest } from 'ahooks';
import { message } from 'antd';

import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
import { useParams } from '@umijs/max';
import { changeTenantRole } from '@/services/tenant';
import type { CommonModalType } from '.';
import CustomModal from '.';
@@ -12,6 +12,7 @@ export default function SwitchTenantModal({
setVisible,
successCallback,
}: CommonModalType) {
const { ns, name } = useParams();
const { run: activateTenant } = useRequest(changeTenantRole, {
manual: true,
onSuccess: ({ successful }) => {
@@ -23,7 +24,6 @@ export default function SwitchTenantModal({
},
});
const handleSubmit = async () => {
const [ns, name] = getNSName();
await activateTenant({ ns, name, switchover: true });
};
const handleCancel = () => setVisible(false);
4 changes: 2 additions & 2 deletions ui/src/components/customModal/UpgradeModal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { intl } from '@/utils/intl';
import { Form, Input, message } from 'antd';

import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
import { useParams } from '@umijs/max';
import { upgradeClusterReportWrap } from '@/services/reportRequest/clusterReportReq';
import type { CommonModalType } from '.';
import CustomModal from '.';
@@ -15,6 +15,7 @@ export default function UpgradeModal({
successCallback,
}: CommonModalType) {
const [form] = Form.useForm();
const { ns, name } = useParams();
const handleSubmit = async () => {
try {
await form.validateFields();
@@ -24,7 +25,6 @@ export default function UpgradeModal({

const handleCancel = () => setVisible(false);
const onFinish = async ({ image }: any) => {
const [ns, name] = getNSName();
const res = await upgradeClusterReportWrap({ ns, name, image });
if (res.successful) {
message.success(res.message);
4 changes: 2 additions & 2 deletions ui/src/components/customModal/UpgradeTenantModal.tsx
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { intl } from '@/utils/intl';
import { useRequest } from 'ahooks';
import { message } from 'antd';

import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
import { useParams } from '@umijs/max';
import { upgradeTenantCompatibilityVersion } from '@/services/tenant';
import type { CommonModalType } from '.';
import CustomModal from '.';
@@ -12,6 +12,7 @@ export default function UpgradeTenantModal({
setVisible,
successCallback,
}: CommonModalType) {
const { ns, name } = useParams();
const { run: upgradeTenant } = useRequest(upgradeTenantCompatibilityVersion, {
manual: true,
onSuccess: ({ successful }) => {
@@ -28,7 +29,6 @@ export default function UpgradeTenantModal({
},
});
const handleSubmit = async () => {
const [ns, name] = getNSName();
await upgradeTenant({ ns, name });
};
const handleCancel = () => setVisible(false);
2 changes: 1 addition & 1 deletion ui/src/pages/Cluster/ClusterList.tsx
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ const columns: ColumnsType<DataType> = [
key: 'clusterName',
render: (value, record) => (
<Link
to={`ns=${record.namespace}&nm=${record.name}&clusterName=${record.clusterName}`}
to={`${record.namespace}/${record.name}/${record.clusterName}`}
>
{value}
</Link>
4 changes: 2 additions & 2 deletions ui/src/pages/Cluster/Detail/Monitor/index.tsx
Original file line number Diff line number Diff line change
@@ -3,14 +3,14 @@ import { getClusterDetailReq } from '@/services';
import { useRequest } from 'ahooks';
import { useEffect, useState } from 'react';
import BasicInfo from '../Overview/BasicInfo';
import { getNSName } from '../Overview/helper';
import { useParams } from '@umijs/max';
import type { FilterDataType,LabelType } from '@/components/MonitorDetail';

import { getFilterData } from '@/components/MonitorDetail/helper';


export default function Monitor() {
const [[ns, name, clusterName]] = useState(getNSName());
const { ns, name, clusterName } = useParams();
const [filterData, setFilterData] = useState<FilterDataType>({
zoneList: [],
serverList: [],
5 changes: 2 additions & 3 deletions ui/src/pages/Cluster/Detail/Overview/ZoneTable.tsx
Original file line number Diff line number Diff line change
@@ -5,8 +5,7 @@ import type { ColumnType } from 'antd/es/table';
import showDeleteConfirm from '@/components/customModal/DeleteModal';
import { COLOR_MAP } from '@/constants';
import { deleteObzoneReportWrap } from '@/services/reportRequest/clusterReportReq';
import { getNSName } from './helper';

import { useParams } from '@umijs/max';
interface ZoneTableProps {
zones: API.Zone[];
setVisible: React.Dispatch<React.SetStateAction<boolean>>;
@@ -24,6 +23,7 @@ export default function ZoneTable({
setChooseServerNum,
clusterStatus,
}: ZoneTableProps) {
const { ns, name } = useParams();
const getZoneColumns = (remove, clickScale) => {
const columns: ColumnType<API.Zone> = [
{
@@ -133,7 +133,6 @@ export default function ZoneTable({
};
//删除的ns和name是集群的
const handleDelete = async (zoneName: string) => {
const [ns, name] = getNSName();
const res = await deleteObzoneReportWrap({
ns,
name,
Loading