@yeeyoon/library 3.0.3 → 3.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -183,9 +183,6 @@ const Header = (props) => {
183
183
  allProduct = data;
184
184
  leftProduct = _xorBy(allProduct, currentProduct, 'id');
185
185
  }
186
- if (!data.filter((item) => item.code === 200000728).length) {
187
- handleException && handleException();
188
- }
189
186
  };
190
187
 
191
188
  const doLogout = async (userId) => {
@@ -7,7 +7,7 @@ import { fetchUserInfo } from './service';
7
7
  const { Option } = Select;
8
8
 
9
9
  const TenantSelector = (props) => {
10
- const { tenantId, tenantIdChangeCb } = props;
10
+ const { tenantId, tenantIdChangeCb, appId, handleException } = props;
11
11
  const [tenantList, setTenantList] = useState([]);
12
12
  const [currentTenantId, setCurrentTenantId] = useState('');
13
13
 
@@ -17,7 +17,17 @@ const TenantSelector = (props) => {
17
17
  let id;
18
18
  let name;
19
19
  if (success) {
20
- const { tenants } = data;
20
+ let { tenants } = data;
21
+ if (appId) {
22
+ tenants = tenants.filter((item) => {
23
+ const { applications } = item;
24
+ return applications.filter((item) => item.id === appId).length;
25
+ });
26
+ }
27
+ if (!tenants.length) {
28
+ handleException && handleException();
29
+ return;
30
+ }
21
31
  const result = tenants.filter((item) => item.id === tenantId);
22
32
  if (result.length) {
23
33
  id = tenantId;
@@ -28,7 +38,7 @@ const TenantSelector = (props) => {
28
38
  }
29
39
  setTenantList(tenants);
30
40
  setCurrentTenantId(id);
31
- tenantIdChangeCb(id, name);
41
+ tenantIdChangeCb && tenantIdChangeCb(id, name);
32
42
  }
33
43
  }, []);
34
44
 
@@ -43,9 +53,7 @@ const TenantSelector = (props) => {
43
53
  onChange={(value, option) => {
44
54
  const { children } = option;
45
55
  setCurrentTenantId(value);
46
- if (tenantIdChangeCb) {
47
- tenantIdChangeCb(value, children);
48
- }
56
+ tenantIdChangeCb && tenantIdChangeCb(value, children);
49
57
  }}
50
58
  >
51
59
  {tenantList.map((item) => {
@@ -61,7 +69,9 @@ const TenantSelector = (props) => {
61
69
 
62
70
  TenantSelector.propTypes = {
63
71
  tenantId: PropTypes.string,
72
+ appId: PropTypes.string,
64
73
  tenantIdChangeCb: PropTypes.func,
74
+ handleException: PropTypes.func,
65
75
  };
66
76
 
67
77
  export default TenantSelector;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeeyoon/library",
3
- "version": "3.0.3",
3
+ "version": "3.0.7",
4
4
  "description": "宜云前端组件库和通用服务",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -1,7 +1,17 @@
1
1
  import React from 'react';
2
2
  import Header from '../../lib/components/Header/';
3
+ import TenantSelector from '../../lib/components/TenantSelector';
3
4
 
4
5
  // eslint-disable-next-line react/display-name
5
6
  export default function () {
6
- return <Header productName="bpm" slot={<div>nasa</div>} />;
7
+ return (
8
+ <>
9
+ <Header productName="bpm" slot={<div>nasa</div>} />
10
+ <TenantSelector
11
+ tenantId="b7b0e19414927b878814094f33b43543"
12
+ appId="bbe5c8f0063711ecb0c00c42a1ff8370"
13
+ tenantIdChangeCb={() => {}}
14
+ />
15
+ </>
16
+ );
7
17
  }