fix: Fix import circle
Fix import circle Change-Id: I3588254da48ade79c31c99a6f03bd48c82350116
This commit is contained in:
parent
f21c5a6daa
commit
535badf92e
@ -56,7 +56,6 @@
|
|||||||
"consistent-return": "warn",
|
"consistent-return": "warn",
|
||||||
"no-underscore-dangle": "warn",
|
"no-underscore-dangle": "warn",
|
||||||
"no-unused-expressions": "warn",
|
"no-unused-expressions": "warn",
|
||||||
"import/no-cycle": "warn",
|
|
||||||
"no-empty": [
|
"no-empty": [
|
||||||
2,
|
2,
|
||||||
{
|
{
|
||||||
@ -69,7 +68,8 @@
|
|||||||
"import/no-extraneous-dependencies": "warn",
|
"import/no-extraneous-dependencies": "warn",
|
||||||
"import/prefer-default-export": "off",
|
"import/prefer-default-export": "off",
|
||||||
"no-nested-ternary": "warn",
|
"no-nested-ternary": "warn",
|
||||||
"import/no-named-as-default": "warn"
|
"import/no-named-as-default": "warn",
|
||||||
|
"global-require": "off"
|
||||||
},
|
},
|
||||||
"globals": {
|
"globals": {
|
||||||
"t": true,
|
"t": true,
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import globalRootStore from 'stores/root';
|
|
||||||
import clientRequest from './request';
|
import clientRequest from './request';
|
||||||
|
|
||||||
export default class BaseClient {
|
export default class BaseClient {
|
||||||
@ -64,6 +63,7 @@ export default class BaseClient {
|
|||||||
if (!this.projectInUrl) {
|
if (!this.projectInUrl) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
const globalRootStore = require('stores/root').default;
|
||||||
const { project: { id } = {} } = globalRootStore.user || {};
|
const { project: { id } = {} } = globalRootStore.user || {};
|
||||||
return id || '';
|
return id || '';
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import globalRootStore from 'stores/root';
|
|
||||||
import { toJS } from 'mobx';
|
import { toJS } from 'mobx';
|
||||||
|
|
||||||
export const groupNameVersionMap = {
|
export const groupNameVersionMap = {
|
||||||
@ -48,6 +47,7 @@ const endpointsDefault = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getOpenstackEndpoint = (key) => {
|
export const getOpenstackEndpoint = (key) => {
|
||||||
|
const globalRootStore = require('stores/root').default;
|
||||||
const { endpoints = {} } = globalRootStore || {};
|
const { endpoints = {} } = globalRootStore || {};
|
||||||
const version = endpointVersionMap[key];
|
const version = endpointVersionMap[key];
|
||||||
const endpoint = endpoints[key] || endpointsDefault[key] || '';
|
const endpoint = endpoints[key] || endpointsDefault[key] || '';
|
||||||
@ -55,6 +55,7 @@ export const getOpenstackEndpoint = (key) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getOriginEndpoint = (key) => {
|
export const getOriginEndpoint = (key) => {
|
||||||
|
const globalRootStore = require('stores/root').default;
|
||||||
const endpoints = toJS((globalRootStore && globalRootStore.endpoints) || {});
|
const endpoints = toJS((globalRootStore && globalRootStore.endpoints) || {});
|
||||||
return endpoints[key];
|
return endpoints[key];
|
||||||
};
|
};
|
||||||
|
@ -16,9 +16,7 @@ import Axios from 'axios';
|
|||||||
import { getLocalStorageItem } from 'utils/local-storage';
|
import { getLocalStorageItem } from 'utils/local-storage';
|
||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
import qs from 'qs';
|
import qs from 'qs';
|
||||||
import globalRootStore from 'stores/root';
|
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import { getOpenstackApiVersion } from './constants';
|
|
||||||
|
|
||||||
const METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD'];
|
const METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD'];
|
||||||
/**
|
/**
|
||||||
@ -31,6 +29,7 @@ export class HttpRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gotoLoginPage(path) {
|
gotoLoginPage(path) {
|
||||||
|
const globalRootStore = require('stores/root').defaullt;
|
||||||
globalRootStore.gotoLoginPage(path);
|
globalRootStore.gotoLoginPage(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +45,7 @@ export class HttpRequest {
|
|||||||
const uuid = uuidv4();
|
const uuid = uuidv4();
|
||||||
config.headers['X-Openstack-Request-Id'] = `req-${uuid}`;
|
config.headers['X-Openstack-Request-Id'] = `req-${uuid}`;
|
||||||
const keystoneToken = getLocalStorageItem('keystone_token') || '';
|
const keystoneToken = getLocalStorageItem('keystone_token') || '';
|
||||||
|
const { getOpenstackApiVersion } = require('./constants');
|
||||||
const apiVersionMap = getOpenstackApiVersion(url);
|
const apiVersionMap = getOpenstackApiVersion(url);
|
||||||
if (keystoneToken) {
|
if (keystoneToken) {
|
||||||
config.headers['X-Auth-Token'] = keystoneToken;
|
config.headers['X-Auth-Token'] = keystoneToken;
|
||||||
|
@ -59,6 +59,10 @@ class SkylineClient extends Base {
|
|||||||
{
|
{
|
||||||
key: 'ports',
|
key: 'ports',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'computeServices',
|
||||||
|
key: 'compute-services',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { firstUpperCase } from 'utils/index';
|
import { firstUpperCase } from 'utils/index';
|
||||||
import BaseForm from '../../../components/Form';
|
import BaseForm from 'components/Form';
|
||||||
|
|
||||||
export default class ModalAction extends BaseForm {
|
export default class ModalAction extends BaseForm {
|
||||||
static id = 'modalAction';
|
static id = 'modalAction';
|
||||||
|
@ -436,6 +436,78 @@ export default class BaseList extends React.Component {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getBaseTableProps() {
|
||||||
|
const {
|
||||||
|
keyword,
|
||||||
|
selectedRowKeys,
|
||||||
|
total,
|
||||||
|
page,
|
||||||
|
limit,
|
||||||
|
silent,
|
||||||
|
sortKey,
|
||||||
|
sortOrder,
|
||||||
|
timerFilter,
|
||||||
|
} = this.list;
|
||||||
|
const pagination = {
|
||||||
|
total,
|
||||||
|
current: Number(page),
|
||||||
|
pageSize: limit || 10,
|
||||||
|
// eslint-disable-next-line no-shadow
|
||||||
|
showTotal: (total) => t('Total {total} items', { total }),
|
||||||
|
showSizeChanger: true,
|
||||||
|
};
|
||||||
|
if (this.pageSizeOptions) {
|
||||||
|
pagination.pageSizeOptions = this.pageSizeOptions;
|
||||||
|
}
|
||||||
|
const { autoRefresh, tableHeight } = this.state;
|
||||||
|
return {
|
||||||
|
resourceName: this.name,
|
||||||
|
data: this.getDataSource(),
|
||||||
|
// data:data,
|
||||||
|
columns: this.getColumns(),
|
||||||
|
filters: this.getFilters(),
|
||||||
|
timerFilter,
|
||||||
|
searchFilters: this.getSearchFilters(),
|
||||||
|
keyword,
|
||||||
|
pagination,
|
||||||
|
primaryActions: this.primaryActions,
|
||||||
|
batchActions: this.batchActions,
|
||||||
|
itemActions: this.itemActions,
|
||||||
|
getCheckboxProps: this.getCheckboxProps,
|
||||||
|
isLoading: this.isLoading,
|
||||||
|
silentLoading: silent,
|
||||||
|
rowKey: this.rowKey,
|
||||||
|
selectedRowKeys: toJS(selectedRowKeys),
|
||||||
|
scrollY: tableHeight,
|
||||||
|
sortKey,
|
||||||
|
sortOrder,
|
||||||
|
defaultSortKey: this.defaultSortKey,
|
||||||
|
defaultSortOrder: this.defaultSortOrder,
|
||||||
|
getDownloadData: this.getDownloadData,
|
||||||
|
containerProps: this.props,
|
||||||
|
expandable: this.expandable,
|
||||||
|
showTimeFilter: !!this.filterTimeKey,
|
||||||
|
filterTimeDefalutValue: this.filterTimeDefalutValue,
|
||||||
|
isPageByBack: this.isFilterByBackend,
|
||||||
|
isSortByBack: this.isSortByBackend,
|
||||||
|
isCourier: this.isCourier,
|
||||||
|
autoRefresh,
|
||||||
|
startRefreshAuto: this.startRefreshAuto,
|
||||||
|
stopRefreshAuto: this.onStopRefreshAuto,
|
||||||
|
onClickAction: this.onClickAction,
|
||||||
|
onFinishAction: this.onFinishAction,
|
||||||
|
onCancelAction: this.onCancelAction,
|
||||||
|
dataDurationAuto: this.dataDurationAuto,
|
||||||
|
handleInputFocus: this.handleInputFocus,
|
||||||
|
hideTotal: this.hideTotal,
|
||||||
|
hideDownload: this.hideDownload,
|
||||||
|
primaryActionsExtra: this.primaryActionsExtra,
|
||||||
|
isAdminPage: this.isAdminPage,
|
||||||
|
initFilter: this.initFilter,
|
||||||
|
...this.getEnabledTableProps(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
onStopRefreshAuto = () => {
|
onStopRefreshAuto = () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
autoRefresh: false,
|
autoRefresh: false,
|
||||||
@ -973,78 +1045,8 @@ export default class BaseList extends React.Component {
|
|||||||
|
|
||||||
renderTable() {
|
renderTable() {
|
||||||
try {
|
try {
|
||||||
const {
|
const props = this.getBaseTableProps();
|
||||||
keyword,
|
return <BaseTable {...props} />;
|
||||||
selectedRowKeys,
|
|
||||||
total,
|
|
||||||
page,
|
|
||||||
limit,
|
|
||||||
silent,
|
|
||||||
sortKey,
|
|
||||||
sortOrder,
|
|
||||||
timerFilter,
|
|
||||||
} = this.list;
|
|
||||||
const pagination = {
|
|
||||||
total,
|
|
||||||
current: Number(page),
|
|
||||||
pageSize: limit || 10,
|
|
||||||
// eslint-disable-next-line no-shadow
|
|
||||||
showTotal: (total) => t('Total {total} items', { total }),
|
|
||||||
showSizeChanger: true,
|
|
||||||
};
|
|
||||||
if (this.pageSizeOptions) {
|
|
||||||
pagination.pageSizeOptions = this.pageSizeOptions;
|
|
||||||
}
|
|
||||||
const { autoRefresh, tableHeight } = this.state;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<BaseTable
|
|
||||||
resourceName={this.name}
|
|
||||||
data={this.getDataSource()}
|
|
||||||
// data={data}
|
|
||||||
columns={this.getColumns()}
|
|
||||||
filters={this.getFilters()}
|
|
||||||
timerFilter={timerFilter}
|
|
||||||
searchFilters={this.getSearchFilters()}
|
|
||||||
keyword={keyword}
|
|
||||||
pagination={pagination}
|
|
||||||
primaryActions={this.primaryActions}
|
|
||||||
batchActions={this.batchActions}
|
|
||||||
itemActions={this.itemActions}
|
|
||||||
getCheckboxProps={this.getCheckboxProps}
|
|
||||||
isLoading={this.isLoading}
|
|
||||||
silentLoading={silent}
|
|
||||||
rowKey={this.rowKey}
|
|
||||||
selectedRowKeys={toJS(selectedRowKeys)}
|
|
||||||
scrollY={tableHeight}
|
|
||||||
sortKey={sortKey}
|
|
||||||
sortOrder={sortOrder}
|
|
||||||
defaultSortKey={this.defaultSortKey}
|
|
||||||
defaultSortOrder={this.defaultSortOrder}
|
|
||||||
getDownloadData={this.getDownloadData}
|
|
||||||
containerProps={this.props}
|
|
||||||
expandable={this.expandable}
|
|
||||||
showTimeFilter={!!this.filterTimeKey}
|
|
||||||
filterTimeDefalutValue={this.filterTimeDefalutValue}
|
|
||||||
isPageByBack={this.isFilterByBackend}
|
|
||||||
isSortByBack={this.isSortByBackend}
|
|
||||||
isCourier={this.isCourier}
|
|
||||||
autoRefresh={autoRefresh}
|
|
||||||
startRefreshAuto={this.startRefreshAuto}
|
|
||||||
stopRefreshAuto={this.onStopRefreshAuto}
|
|
||||||
onClickAction={this.onClickAction}
|
|
||||||
onFinishAction={this.onFinishAction}
|
|
||||||
onCancelAction={this.onCancelAction}
|
|
||||||
dataDurationAuto={this.dataDurationAuto}
|
|
||||||
handleInputFocus={this.handleInputFocus}
|
|
||||||
hideTotal={this.hideTotal}
|
|
||||||
hideDownload={this.hideDownload}
|
|
||||||
primaryActionsExtra={this.primaryActionsExtra}
|
|
||||||
isAdminPage={this.isAdminPage}
|
|
||||||
initFilter={this.initFilter}
|
|
||||||
{...this.getEnabledTableProps()}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
import { action } from 'mobx';
|
import { action } from 'mobx';
|
||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
import globalFloatingIpsStore from 'stores/neutron/floatingIp';
|
|
||||||
import client from 'client';
|
import client from 'client';
|
||||||
import Base from '../base';
|
import Base from '../base';
|
||||||
|
|
||||||
@ -59,6 +58,7 @@ export class LbaasStore extends Base {
|
|||||||
this.updateMarker(allData, page, result);
|
this.updateMarker(allData, page, result);
|
||||||
const allDataNew = allData.map(this.mapperBeforeFetchProject);
|
const allDataNew = allData.map(this.mapperBeforeFetchProject);
|
||||||
let newData = await this.listDidFetchProject(allDataNew, all_projects);
|
let newData = await this.listDidFetchProject(allDataNew, all_projects);
|
||||||
|
const globalFloatingIpsStore = require('stores/neutron/floatingIp').default;
|
||||||
const fipDetails = await Promise.all(
|
const fipDetails = await Promise.all(
|
||||||
newData.map((item) =>
|
newData.map((item) =>
|
||||||
globalFloatingIpsStore.pureFetchList({
|
globalFloatingIpsStore.pureFetchList({
|
||||||
@ -118,6 +118,8 @@ export class LbaasStore extends Base {
|
|||||||
try {
|
try {
|
||||||
const newItem = await this.detailDidFetch(item, all_projects);
|
const newItem = await this.detailDidFetch(item, all_projects);
|
||||||
const detail = this.mapper(newItem);
|
const detail = this.mapper(newItem);
|
||||||
|
const globalFloatingIpsStore =
|
||||||
|
require('stores/neutron/floatingIp').default;
|
||||||
const fipInfo = await globalFloatingIpsStore.fetchList({
|
const fipInfo = await globalFloatingIpsStore.fetchList({
|
||||||
fixed_ip_address: item.vip_address,
|
fixed_ip_address: item.vip_address,
|
||||||
});
|
});
|
||||||
|
@ -20,11 +20,11 @@ import { getQueryString } from 'utils/index';
|
|||||||
import { getLocalTime } from 'utils/time';
|
import { getLocalTime } from 'utils/time';
|
||||||
import { setLocalStorageItem } from 'utils/local-storage';
|
import { setLocalStorageItem } from 'utils/local-storage';
|
||||||
import { isEmpty, values } from 'lodash';
|
import { isEmpty, values } from 'lodash';
|
||||||
import checkItemPolicy, { onlyAdminCanReadPolicy } from 'resources/policy';
|
|
||||||
// global stores need to be clear data when change auth
|
|
||||||
import allGlobalStores from './index';
|
|
||||||
|
|
||||||
class RootStore {
|
const checkItemPolicy = require('resources/policy').default;
|
||||||
|
const { onlyAdminCanReadPolicy } = require('resources/policy');
|
||||||
|
|
||||||
|
export class RootStore {
|
||||||
@observable
|
@observable
|
||||||
user = null;
|
user = null;
|
||||||
|
|
||||||
@ -261,6 +261,8 @@ class RootStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
clearData() {
|
clearData() {
|
||||||
|
// global stores need to be clear data when change auth
|
||||||
|
const allGlobalStores = require('./index').default;
|
||||||
const stores = values(allGlobalStores);
|
const stores = values(allGlobalStores);
|
||||||
stores.forEach((store) => {
|
stores.forEach((store) => {
|
||||||
store.clearData();
|
store.clearData();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user