Skip to content

Commit

Permalink
fix(console): project page get undefined error (#1727)
Browse files Browse the repository at this point in the history
* fix(console):  project page PlatformTypeEnum undefined error

* fix(console): add open page for devserver
  • Loading branch information
jo-hnny committed Dec 24, 2021
1 parent 1fb2e73 commit a351a50
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 80 deletions.
10 changes: 1 addition & 9 deletions web/console/Wrapper.tsx
Expand Up @@ -24,7 +24,7 @@ import {
setConsoleAPIAddress
} from './helpers';
import { ResourceInfo, RequestParams } from './src/modules/common/models';
import { resourceConfig } from './config';
import { resourceConfig, PlatformTypeEnum } from './config';
import { isEmpty } from './src/modules/common/utils';
import * as classnames from 'classnames';
import { Icon, Text, Bubble, NavMenu, List, ExternalLink, StatusTip } from 'tea-component';
Expand All @@ -44,14 +44,6 @@ enum UserType {
init = 'init'
}

export enum PlatformTypeEnum {
/** 平台 */
Manager = 'manager',

/** 业务 */
Business = 'business'
}

export interface IPlatformContext {
type: PlatformTypeEnum;
}
Expand Down
1 change: 1 addition & 0 deletions web/console/config/index.ts
Expand Up @@ -18,3 +18,4 @@
export { resourceConfig } from './resourceConfig';
export { firstRouterNameMap, typeMapName, subRouterConfig } from './routerConfig';
export { apiServerVersion } from './apiServerVersion';
export * from './platform';
8 changes: 8 additions & 0 deletions web/console/config/platform.ts
Expand Up @@ -44,3 +44,11 @@ export enum ConsoleModuleEnum {
/** Helm应用模块 */
Application = 'application'
}

export enum PlatformTypeEnum {
/** 平台 */
Manager = 'manager',

/** 业务 */
Business = 'business'
}
3 changes: 2 additions & 1 deletion web/console/index.project.tsx
Expand Up @@ -20,13 +20,14 @@ import ReactDOM from 'react-dom';
import * as React from 'react';
import { Entry, insertCSS } from '@tencent/ff-redux';
import { t, Trans } from '@tencent/tea-app/lib/i18n';
import { Wrapper, PlatformTypeEnum } from './Wrapper';
import { Wrapper } from './Wrapper';
import { Init_Forbiddent_Config } from '@helper/reduceNetwork';
import { TipDialog } from '@src/modules/common';
import { Button, Alert, Text } from '@tencent/tea-component';
import { PersistentEvent } from '@src/modules/persistentEvent';
// 公有云的图表组件为异步加载,这里为了减少路径配置,还是保留为同步加载,预先import即可变成不split
import '@tencent/tchart/build/ChartsComponents';
import { PlatformTypeEnum } from './config';

const ApplicationPromise = import(/* webpackPrefetch: true */ './src/modules/cluster/index.project');
const Application = React.lazy(() => ApplicationPromise);
Expand Down
3 changes: 2 additions & 1 deletion web/console/index.tke.tsx
Expand Up @@ -19,7 +19,7 @@ import './i18n';
import * as React from 'react';
import { Entry, insertCSS } from '@tencent/ff-redux';
import { t, Trans } from '@tencent/tea-app/lib/i18n';
import { Wrapper, PlatformTypeEnum } from './Wrapper';
import { Wrapper } from './Wrapper';
import { Addon } from './src/modules/addon';
import { PersistentEvent } from './src/modules/persistentEvent';
import { Audit } from './src/modules/audit';
Expand All @@ -32,6 +32,7 @@ import { Init_Forbiddent_Config } from './helpers/reduceNetwork';
import '@tencent/tchart/build/ChartsComponents';
import { BlankPage } from './blankPage';
import { Overview } from '@src/modules/overview';
import { PlatformTypeEnum } from './config';

const ClusterPromise = import(/* webpackPrefetch: true */ './src/modules/cluster');
const Cluster = React.lazy(() => ClusterPromise);
Expand Down
Expand Up @@ -38,7 +38,7 @@ import { ChartInstancesPanel } from '@tencent/tchart';
import { t, Trans } from '@tencent/tea-app/lib/i18n';
import { Justify } from '@tencent/tea-component/lib/justify';

import { resourceConfig } from '../../../../../../config';
import { resourceConfig, PlatformTypeEnum } from '../../../../../../config';
import { dateFormatter, downloadCsv, reduceNs } from '../../../../../../helpers';
import { DisplayFiledProps, ResourceInfo } from '../../../../common/models';
import { includes, isEmpty } from '../../../../common/utils';
Expand All @@ -48,7 +48,7 @@ import { MonitorPanelProps, resourceMonitorFields } from '../../../models/Monito
import { router } from '../../../router';
import { RootProps } from '../../ClusterApp';
import { TellIsNeedFetchNS } from '../ResourceSidebarPanel';
import { PlatformContext, IPlatformContext, PlatformTypeEnum } from '@/Wrapper';
import { PlatformContext, IPlatformContext } from '@/Wrapper';

interface ResouceActionPanelState {
/** 是否开启自动刷新 */
Expand Down
Expand Up @@ -28,7 +28,8 @@ import { Clip, FormItem, GridTable } from '../../../../common/components';
import { allActions } from '../../../actions';
import { Event } from '../../../models';
import { RootProps } from '../../ClusterApp';
import { PlatformContext, PlatformTypeEnum, IPlatformContext } from '@/Wrapper';
import { PlatformContext, IPlatformContext } from '@/Wrapper';
import { PlatformTypeEnum } from '@config';

insertCSS(
'ResourceEventPanel',
Expand Down Expand Up @@ -117,7 +118,7 @@ export class ResourceEventPanel extends React.Component<RootProps, ResourceEvent
}

componentWillReceiveProps(nextProps: RootProps) {
let { namespaceList } = nextProps;
const { namespaceList } = nextProps;

if (
namespaceList.fetched === true &&
Expand All @@ -131,7 +132,7 @@ export class ResourceEventPanel extends React.Component<RootProps, ResourceEvent
}

componentWillUnmount() {
let { actions, route } = this.props;
const { actions, route } = this.props;
// 停止轮询
actions.resourceEvent.fetch({ noCache: true });
actions.resourceEvent.clearPollEvent();
Expand All @@ -150,7 +151,7 @@ export class ResourceEventPanel extends React.Component<RootProps, ResourceEvent

/** 展示条件筛选的部分 */
private _renderEventFilterBar() {
let { subRoot, namespaceList } = this.props,
const { subRoot, namespaceList } = this.props,
{ namespaceSelection, workloadType, workloadList, workloadSelection, isAutoRenew } = subRoot.resourceEventOption;

// 展示命名空间的选择列表
Expand All @@ -161,7 +162,7 @@ export class ResourceEventPanel extends React.Component<RootProps, ResourceEvent
return { ...gr, [clusterName]: <Tooltip title={value}>{value}</Tooltip> };
}, {});

let namespaceOptions = namespaceList.data.records.map(item => {
const namespaceOptions = namespaceList.data.records.map(item => {
const text = `${item.clusterDisplayName}-${item.namespace}`;

return {
Expand All @@ -179,7 +180,7 @@ export class ResourceEventPanel extends React.Component<RootProps, ResourceEvent
filter: (inputValue, { realText }: any) => (realText ? realText.includes(inputValue) : true)
};
} else {
let namespaceOptions = namespaceList.data.records.map(n => {
const namespaceOptions = namespaceList.data.records.map(n => {
return {
value: n.name,
text: n.displayName
Expand All @@ -192,21 +193,21 @@ export class ResourceEventPanel extends React.Component<RootProps, ResourceEvent
}

// 展示workloadType的选择列表
let workloadTypeOptions = workloadTypeList.map(w => ({
const workloadTypeOptions = workloadTypeList.map(w => ({
value: w.value,
text: w.label
}));

// 展示workloadList的选择列表
let workloadListOptions = workloadList.data.records.map(w => {
const workloadListOptions = workloadList.data.records.map(w => {
return {
value: w.metadata.name,
text: w.metadata.name
};
});

/** 加载中的样式 */
let loadingElement: JSX.Element = (
const loadingElement: JSX.Element = (
<div style={{ display: 'inline-block' }}>
<i className="n-loading-icon" />
&nbsp; <span className="text">{t('加载中...')}</span>
Expand Down Expand Up @@ -281,7 +282,7 @@ export class ResourceEventPanel extends React.Component<RootProps, ResourceEvent

/** 处理namespace的选择 */
private _handleSelectForNamespace(namespace: string) {
let { actions, subRoot } = this.props,
const { actions, subRoot } = this.props,
{ workloadType, workloadSelection } = subRoot.resourceEventOption;
actions.resourceEvent.selectNamespace(namespace);

Expand All @@ -291,7 +292,7 @@ export class ResourceEventPanel extends React.Component<RootProps, ResourceEvent

/** 处理workloadType的选择 */
private _handleSelectForWorkloadType(type: string) {
let { actions, subRoot } = this.props,
const { actions, subRoot } = this.props,
{ namespaceSelection } = subRoot.resourceEventOption;
actions.resourceEvent.workload.selectWorkloadType(type);

Expand All @@ -304,7 +305,7 @@ export class ResourceEventPanel extends React.Component<RootProps, ResourceEvent

/** 处理workload的选择 */
private _handleSelectForWorkload(workload: string) {
let { actions, subRoot } = this.props,
const { actions, subRoot } = this.props,
{ namespaceSelection, workloadType } = subRoot.resourceEventOption;
actions.resourceEvent.workload.selectWorkload(workload);

Expand All @@ -314,7 +315,7 @@ export class ResourceEventPanel extends React.Component<RootProps, ResourceEvent

/** 处理自动刷新按钮 */
private _handleSwitch(isChecked: boolean) {
let { actions, subRoot } = this.props,
const { actions, subRoot } = this.props,
{ namespaceSelection, workloadType, workloadSelection } = subRoot.resourceEventOption;

actions.resourceEvent.toggleAutoRenew();
Expand All @@ -328,12 +329,12 @@ export class ResourceEventPanel extends React.Component<RootProps, ResourceEvent

/** 展示事件列表 */
private _renderEventTablePanel() {
let { actions, subRoot } = this.props,
const { actions, subRoot } = this.props,
{ eventList, eventQuery } = subRoot.resourceEventOption;

/** 处理时间 */
const reduceTime = (time: string) => {
let [first, second] = dateFormatter(new Date(time), 'YYYY-MM-DD HH:mm:ss').split(' ');
const [first, second] = dateFormatter(new Date(time), 'YYYY-MM-DD HH:mm:ss').split(' ');

return <Text>{`${first} ${second}`}</Text>;
};
Expand Down Expand Up @@ -422,7 +423,7 @@ export class ResourceEventPanel extends React.Component<RootProps, ResourceEvent
}
];

let emptyTips: JSX.Element = <div>{t('事件列表为空')}</div>;
const emptyTips: JSX.Element = <div>{t('事件列表为空')}</div>;

return (
<GridTable
Expand Down

0 comments on commit a351a50

Please sign in to comment.