Skip to content

Commit 25a5b64

Browse files
fix: db popup inconsistent position
1 parent 9b15304 commit 25a5b64

File tree

2 files changed

+39
-22
lines changed

2 files changed

+39
-22
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import {Ref, Button} from 'semantic-ui-react';
4+
import classNames from 'classnames';
5+
6+
const DbBtn = ({fetchDbDetails}, ref) => {
7+
const successFetchDbDetails = fetchDbDetails.filter(d => d.success);
8+
const isFailed = successFetchDbDetails.length !== fetchDbDetails.length;
9+
const value = `${successFetchDbDetails.length}/${fetchDbDetails.length}`;
10+
const content = `Databases loaded: ${value}`;
11+
const className = classNames(
12+
'db-info',
13+
{'db-info_failed': isFailed}
14+
);
15+
16+
return (
17+
<Ref innerRef={ref}>
18+
<Button
19+
content={content}
20+
icon="angle down"
21+
className={className}
22+
basic
23+
/>
24+
</Ref>
25+
);
26+
};
27+
28+
const ForwardedDbBtn = React.forwardRef(DbBtn);
29+
30+
ForwardedDbBtn.propTypes = {
31+
fetchDbDetails: PropTypes.arrayOf(PropTypes.shape({
32+
success: PropTypes.bool
33+
})).isRequired
34+
};
35+
36+
export default ForwardedDbBtn;

lib/static/components/header/summary/dbSummary.js

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React, {Component} from 'react';
2-
import {Dropdown, Button, Ref} from 'semantic-ui-react';
2+
import {Dropdown} from 'semantic-ui-react';
33
import PropTypes from 'prop-types';
4-
import classNames from 'classnames';
54

5+
import DbBtn from './dbBtn';
66
import Popup from '../../popup';
77

88
export default class DbSummaryKey extends Component {
@@ -28,38 +28,19 @@ export default class DbSummaryKey extends Component {
2828
return null;
2929
}
3030

31-
const successFetchDbDetails = fetchDbDetails.filter(d => d.success);
32-
const isFailed = successFetchDbDetails.length !== fetchDbDetails.length;
33-
const value = `${successFetchDbDetails.length}/${fetchDbDetails.length}`;
3431
const additionalInfo = fetchDbDetails.map(({url, status, success}) => (
3532
<Dropdown.Item key={url} className="db-info__row">
3633
{' '}
3734
{url} responded with
3835
<span className={success ? 'db-info__row_success' : 'db-info__row_fail'}>{' ' + status}</span>
3936
</Dropdown.Item>
4037
));
41-
const title = `Databases loaded: ${value}`;
42-
const btnClassNames = classNames(
43-
'db-info',
44-
{'db-info_failed': isFailed}
45-
);
46-
47-
const DbBtn = React.forwardRef((props, ref) => (
48-
<Ref innerRef={ref}>
49-
<Button
50-
content={title}
51-
icon="angle down"
52-
className={btnClassNames}
53-
basic
54-
/>
55-
</Ref>
56-
));
5738

5839
return (
5940
<Popup
6041
className="db-info__popup"
6142
action="hover"
62-
target={<DbBtn />}
43+
target={<DbBtn fetchDbDetails={fetchDbDetails} />}
6344
>
6445
{additionalInfo}
6546
</Popup>

0 commit comments

Comments
 (0)