@bento-core/query-bar 1.0.1-icdc.21 → 1.0.1-icdc.23
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.
- package/CopyURL_README.md +42 -0
- package/README.md +11 -1
- package/dist/components/QueryUrl.js +98 -26
- package/dist/generators/styles.js +1 -1
- package/package.json +1 -1
- package/src/components/QueryUrl.js +115 -27
- package/src/generators/styles.js +1 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# DQB copy URL button Configuration
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
DashTemplateController.js
|
|
5
|
+
|
|
6
|
+
export const setActiveFilterByPathQuery = (match) => {
|
|
7
|
+
const query = decodeURI(match.params.filterQuery || '');
|
|
8
|
+
const filterObject = JSON.parse(query);
|
|
9
|
+
const { autocomplete = [], upload = [], uploadMetadata } = filterObject;
|
|
10
|
+
|
|
11
|
+
const activeFilterValues = Object.keys(filterObject).reduce((curr, key) => {
|
|
12
|
+
if (Array.isArray(filterObject[key])) {
|
|
13
|
+
const activeFilters = filterObject[key].reduce((value, item) => ({
|
|
14
|
+
...value,
|
|
15
|
+
[item]: true,
|
|
16
|
+
}), {});
|
|
17
|
+
return {
|
|
18
|
+
...curr,
|
|
19
|
+
[key]: activeFilters,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return curr;
|
|
23
|
+
}, {});
|
|
24
|
+
store.dispatch(clearAllAndSelectFacet(activeFilterValues));
|
|
25
|
+
store.dispatch(updateAutocompleteData(autocomplete));
|
|
26
|
+
store.dispatch(updateUploadData(upload));
|
|
27
|
+
store.dispatch(updateUploadMetadata(uploadMetadata));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// redirect
|
|
32
|
+
if (match.params.filterQuery) {
|
|
33
|
+
setActiveFilterByPathQuery(match);
|
|
34
|
+
const redirectUrl = '/explore';
|
|
35
|
+
history.push(redirectUrl);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
# DQB copy URL button theme style
|
|
41
|
+
|
|
42
|
+
``` https://github.com/CBIIT/bento-icdc-frontend/tree/v4.0.1/src/pages/dashboard/filterQueryBar```
|
package/README.md
CHANGED
|
@@ -63,6 +63,16 @@ const CONFIG = {
|
|
|
63
63
|
* @var {boolean}
|
|
64
64
|
*/
|
|
65
65
|
displayAllActiveFilters: false,
|
|
66
|
+
/**
|
|
67
|
+
* set root path for copy url (COPYURL_README)
|
|
68
|
+
* @var {boolean}
|
|
69
|
+
*/
|
|
70
|
+
rootPath: `${window.location.href}/`,
|
|
71
|
+
/**
|
|
72
|
+
* display copy url button (COPYURL_README)
|
|
73
|
+
* @var {boolean}
|
|
74
|
+
*/
|
|
75
|
+
viewQueryURL: true,
|
|
66
76
|
},
|
|
67
77
|
|
|
68
78
|
/* Component Helper Functions */
|
|
@@ -144,4 +154,4 @@ This component, which is generated by the provided generator, accepts the follow
|
|
|
144
154
|
/>
|
|
145
155
|
```
|
|
146
156
|
|
|
147
|
-
> **Warning**: The `statusReducer` prop requires the dashboard API data merged with the `facetsConfig` property. Please see the example in the demo implementation [here](https://github.com/CBIIT/bento-frontend/blob/7efd62cd3da0c29326e523055d30118244dc2f2f/packages/bento-frontend/src/pages/dashTemplate/filterQueryBar/QueryBarView.js#LL20C14-L20C14).
|
|
157
|
+
> **Warning**: The `statusReducer` prop requires the dashboard API data merged with the `facetsConfig` property. Please see the example in the demo implementation [here](https://github.com/CBIIT/bento-frontend/blob/7efd62cd3da0c29326e523055d30118244dc2f2f/packages/bento-frontend/src/pages/dashTemplate/filterQueryBar/QueryBarView.js#LL20C14-L20C14).
|
|
@@ -16,15 +16,61 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
16
16
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
17
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
18
18
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
19
|
-
const
|
|
19
|
+
const ViewFullLinkComponent = _ref => {
|
|
20
|
+
let {
|
|
21
|
+
classes,
|
|
22
|
+
url,
|
|
23
|
+
maxWidth = 1200
|
|
24
|
+
} = _ref;
|
|
25
|
+
const linkRef = (0, _react.useRef)(null);
|
|
26
|
+
const [collapseLink, setCollapseLink] = (0, _react.useState)(false);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Compute url link width based on the windowsize
|
|
30
|
+
*/
|
|
31
|
+
(0, _react.useEffect)(() => {
|
|
32
|
+
var _linkRef$current;
|
|
33
|
+
const urlWidth = linkRef === null || linkRef === void 0 ? void 0 : (_linkRef$current = linkRef.current) === null || _linkRef$current === void 0 ? void 0 : _linkRef$current.offsetWidth;
|
|
34
|
+
if (urlWidth > maxWidth / 2) {
|
|
35
|
+
setCollapseLink(true);
|
|
36
|
+
}
|
|
37
|
+
}, []);
|
|
38
|
+
const expandUrl = () => {
|
|
39
|
+
setCollapseLink(false);
|
|
40
|
+
};
|
|
41
|
+
const collapseUrl = () => {
|
|
42
|
+
setCollapseLink(true);
|
|
43
|
+
};
|
|
44
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
|
|
45
|
+
ref: linkRef,
|
|
46
|
+
className: classes.link
|
|
47
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
48
|
+
className: (0, _clsx.default)(classes.viewLink, {
|
|
49
|
+
[classes.collapseLink]: collapseLink
|
|
50
|
+
})
|
|
51
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
52
|
+
className: (0, _clsx.default)(classes.urlView, {
|
|
53
|
+
[classes.urlViewBtn]: !collapseLink
|
|
54
|
+
}),
|
|
55
|
+
type: "button",
|
|
56
|
+
onClick: collapseUrl
|
|
57
|
+
}, url), collapseLink && /*#__PURE__*/_react.default.createElement("span", {
|
|
58
|
+
className: classes.expandLinkBtn,
|
|
59
|
+
type: "button",
|
|
60
|
+
onClick: expandUrl
|
|
61
|
+
}, "..."))));
|
|
62
|
+
};
|
|
63
|
+
const QueryUrl = _ref2 => {
|
|
64
|
+
var _queryRef$current;
|
|
20
65
|
let {
|
|
21
66
|
classes,
|
|
22
67
|
filterItems,
|
|
23
68
|
localFind = {},
|
|
24
69
|
rootPath
|
|
25
|
-
} =
|
|
70
|
+
} = _ref2;
|
|
26
71
|
const [display, setDisplay] = (0, _react.useState)(false);
|
|
27
72
|
const toggleDisplay = () => setDisplay(!display);
|
|
73
|
+
const [expand, setExpand] = (0, _react.useState)(false);
|
|
28
74
|
const [open, toggleOpen] = (0, _react.useState)(false);
|
|
29
75
|
const pathFilterParams = filterItems.reduce((acc, item) => {
|
|
30
76
|
const {
|
|
@@ -47,10 +93,15 @@ const QueryUrl = _ref => {
|
|
|
47
93
|
}, /*#__PURE__*/_react.default.createElement(_core.Button, {
|
|
48
94
|
onClick: toggleDisplay,
|
|
49
95
|
className: classes.viewLinkToggleBtn
|
|
50
|
-
}, display ? 'Hide Query URL' : 'Show Query URL'), display && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("
|
|
96
|
+
}, display ? 'Hide Query URL' : 'Show Query URL'), display && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, expand ? /*#__PURE__*/_react.default.createElement("span", {
|
|
51
97
|
type: "button",
|
|
52
|
-
|
|
53
|
-
|
|
98
|
+
onClick: () => setExpand(!expand),
|
|
99
|
+
className: (0, _clsx.default)(classes.link, classes.viewLink, classes.expandLink)
|
|
100
|
+
}, url) : /*#__PURE__*/_react.default.createElement(ViewFullLinkComponent, {
|
|
101
|
+
url: url,
|
|
102
|
+
classes: classes,
|
|
103
|
+
maxWidth: queryRef === null || queryRef === void 0 ? void 0 : (_queryRef$current = queryRef.current) === null || _queryRef$current === void 0 ? void 0 : _queryRef$current.offsetWidth
|
|
104
|
+
}), /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
|
|
54
105
|
arrow: true,
|
|
55
106
|
title: "Copy to Clipboard"
|
|
56
107
|
}, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
@@ -76,43 +127,48 @@ const QueryUrl = _ref => {
|
|
|
76
127
|
const styles = () => ({
|
|
77
128
|
urlContainer: {
|
|
78
129
|
display: 'flex',
|
|
79
|
-
marginTop: '
|
|
130
|
+
marginTop: '10px',
|
|
80
131
|
minHeight: '10px'
|
|
81
132
|
},
|
|
82
|
-
|
|
133
|
+
link: {
|
|
134
|
+
lineBreak: 'anywhere',
|
|
83
135
|
overflow: 'hidden',
|
|
84
|
-
textOverflow: 'ellipsis',
|
|
85
136
|
fontFamily: 'Nunito',
|
|
86
137
|
fontSize: '12px',
|
|
87
138
|
fontWeight: '500',
|
|
88
139
|
lineHeight: '16px',
|
|
89
140
|
letterSpacing: '0em',
|
|
90
|
-
padding: '
|
|
141
|
+
padding: '5px',
|
|
91
142
|
borderRadius: '5px',
|
|
92
143
|
float: 'left',
|
|
93
144
|
color: '#1D79A8',
|
|
94
145
|
backgroundColor: '#fff',
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
maxWidth: '1800px'
|
|
100
|
-
},
|
|
101
|
-
'@media (max-width: 2000px)': {
|
|
102
|
-
maxWidth: '1500px'
|
|
103
|
-
},
|
|
104
|
-
'@media (max-width: 1600px)': {
|
|
105
|
-
maxWidth: '1100px'
|
|
106
|
-
},
|
|
107
|
-
'@media (max-width: 1300px)': {
|
|
108
|
-
maxWidth: '900px'
|
|
109
|
-
}
|
|
146
|
+
maxWidth: '80%'
|
|
147
|
+
},
|
|
148
|
+
viewLink: {
|
|
149
|
+
margin: '0'
|
|
110
150
|
},
|
|
111
151
|
urlViewBtn: {
|
|
112
152
|
cursor: 'pointer'
|
|
113
153
|
},
|
|
154
|
+
collapseLink: {
|
|
155
|
+
maxHeight: '1em',
|
|
156
|
+
display: 'block',
|
|
157
|
+
// display: '-webkit-box',
|
|
158
|
+
'-webkit-box-orient': 'vertical',
|
|
159
|
+
'-webkit-line-clamp': '1',
|
|
160
|
+
overflow: 'hidden'
|
|
161
|
+
},
|
|
162
|
+
expandLink: {
|
|
163
|
+
cursor: 'pointer'
|
|
164
|
+
},
|
|
165
|
+
expandLinkBtn: {
|
|
166
|
+
float: 'left',
|
|
167
|
+
'&:hover': {
|
|
168
|
+
cursor: 'pointer'
|
|
169
|
+
}
|
|
170
|
+
},
|
|
114
171
|
viewLinkToggleBtn: {
|
|
115
|
-
padding: '5px 10px 5px 10px',
|
|
116
172
|
height: '20px',
|
|
117
173
|
fontFamily: 'Nunito',
|
|
118
174
|
fontSize: '12px',
|
|
@@ -125,12 +181,28 @@ const styles = () => ({
|
|
|
125
181
|
color: '#fff',
|
|
126
182
|
float: 'left',
|
|
127
183
|
margin: '0px 10px 0px 0px',
|
|
128
|
-
whiteSpace: 'nowrap',
|
|
129
184
|
'&:hover': {
|
|
130
185
|
backgroundColor: '#1D79A8',
|
|
131
186
|
color: '#fff'
|
|
132
187
|
}
|
|
133
188
|
},
|
|
189
|
+
urlView: {
|
|
190
|
+
float: 'left',
|
|
191
|
+
width: 'calc(100% - 13px)',
|
|
192
|
+
minWidth: '840px',
|
|
193
|
+
'@media (max-width: 2560px)': {
|
|
194
|
+
maxWidth: '1800px'
|
|
195
|
+
},
|
|
196
|
+
'@media (max-width: 2000px)': {
|
|
197
|
+
maxWidth: '1400px'
|
|
198
|
+
},
|
|
199
|
+
'@media (max-width: 1600px)': {
|
|
200
|
+
maxWidth: '1200px'
|
|
201
|
+
},
|
|
202
|
+
'@media (max-width: 1300px)': {
|
|
203
|
+
maxWidth: '1050px'
|
|
204
|
+
}
|
|
205
|
+
},
|
|
134
206
|
copyIconBtn: {
|
|
135
207
|
padding: '0px',
|
|
136
208
|
height: '20px',
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useRef } from 'react';
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import {
|
|
4
4
|
Button,
|
|
@@ -12,6 +12,62 @@ import {
|
|
|
12
12
|
} from '@material-ui/core';
|
|
13
13
|
import CopyIcon from '../assets/CopyIcon.svg';
|
|
14
14
|
|
|
15
|
+
const ViewFullLinkComponent = ({
|
|
16
|
+
classes,
|
|
17
|
+
url,
|
|
18
|
+
maxWidth = 1200,
|
|
19
|
+
}) => {
|
|
20
|
+
const linkRef = useRef(null);
|
|
21
|
+
const [collapseLink, setCollapseLink] = useState(false);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Compute url link width based on the windowsize
|
|
25
|
+
*/
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const urlWidth = linkRef?.current?.offsetWidth;
|
|
28
|
+
if (urlWidth > maxWidth / 2) {
|
|
29
|
+
setCollapseLink(true);
|
|
30
|
+
}
|
|
31
|
+
}, []);
|
|
32
|
+
|
|
33
|
+
const expandUrl = () => {
|
|
34
|
+
setCollapseLink(false);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const collapseUrl = () => {
|
|
38
|
+
setCollapseLink(true);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<>
|
|
43
|
+
<span ref={linkRef} className={classes.link}>
|
|
44
|
+
<span
|
|
45
|
+
className={clsx(classes.viewLink,
|
|
46
|
+
{ [classes.collapseLink]: collapseLink })}
|
|
47
|
+
>
|
|
48
|
+
<span
|
|
49
|
+
className={clsx(classes.urlView,
|
|
50
|
+
{ [classes.urlViewBtn]: !collapseLink })}
|
|
51
|
+
type="button"
|
|
52
|
+
onClick={collapseUrl}
|
|
53
|
+
>
|
|
54
|
+
{url}
|
|
55
|
+
</span>
|
|
56
|
+
{(collapseLink) && (
|
|
57
|
+
<span
|
|
58
|
+
className={classes.expandLinkBtn}
|
|
59
|
+
type="button"
|
|
60
|
+
onClick={expandUrl}
|
|
61
|
+
>
|
|
62
|
+
...
|
|
63
|
+
</span>
|
|
64
|
+
)}
|
|
65
|
+
</span>
|
|
66
|
+
</span>
|
|
67
|
+
</>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
15
71
|
const QueryUrl = ({
|
|
16
72
|
classes,
|
|
17
73
|
filterItems,
|
|
@@ -21,6 +77,8 @@ const QueryUrl = ({
|
|
|
21
77
|
const [display, setDisplay] = useState(false);
|
|
22
78
|
const toggleDisplay = () => setDisplay(!display);
|
|
23
79
|
|
|
80
|
+
const [expand, setExpand] = useState(false);
|
|
81
|
+
|
|
24
82
|
const [open, toggleOpen] = useState(false);
|
|
25
83
|
|
|
26
84
|
const pathFilterParams = filterItems.reduce((acc, item) => {
|
|
@@ -54,12 +112,21 @@ const QueryUrl = ({
|
|
|
54
112
|
{
|
|
55
113
|
(display) && (
|
|
56
114
|
<>
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
115
|
+
{(expand) ? (
|
|
116
|
+
<span
|
|
117
|
+
type="button"
|
|
118
|
+
onClick={() => setExpand(!expand)}
|
|
119
|
+
className={clsx(classes.link, classes.viewLink, classes.expandLink)}
|
|
120
|
+
>
|
|
121
|
+
{url}
|
|
122
|
+
</span>
|
|
123
|
+
) : (
|
|
124
|
+
<ViewFullLinkComponent
|
|
125
|
+
url={url}
|
|
126
|
+
classes={classes}
|
|
127
|
+
maxWidth={queryRef?.current?.offsetWidth}
|
|
128
|
+
/>
|
|
129
|
+
)}
|
|
63
130
|
<Tooltip
|
|
64
131
|
arrow
|
|
65
132
|
title="Copy to Clipboard"
|
|
@@ -97,43 +164,48 @@ const QueryUrl = ({
|
|
|
97
164
|
const styles = () => ({
|
|
98
165
|
urlContainer: {
|
|
99
166
|
display: 'flex',
|
|
100
|
-
marginTop: '
|
|
167
|
+
marginTop: '10px',
|
|
101
168
|
minHeight: '10px',
|
|
102
169
|
},
|
|
103
|
-
|
|
170
|
+
link: {
|
|
171
|
+
lineBreak: 'anywhere',
|
|
104
172
|
overflow: 'hidden',
|
|
105
|
-
textOverflow: 'ellipsis',
|
|
106
173
|
fontFamily: 'Nunito',
|
|
107
174
|
fontSize: '12px',
|
|
108
175
|
fontWeight: '500',
|
|
109
176
|
lineHeight: '16px',
|
|
110
177
|
letterSpacing: '0em',
|
|
111
|
-
padding: '
|
|
178
|
+
padding: '5px',
|
|
112
179
|
borderRadius: '5px',
|
|
113
180
|
float: 'left',
|
|
114
181
|
color: '#1D79A8',
|
|
115
182
|
backgroundColor: '#fff',
|
|
183
|
+
maxWidth: '80%',
|
|
184
|
+
},
|
|
185
|
+
viewLink: {
|
|
116
186
|
margin: '0',
|
|
117
|
-
whiteSpace: 'nowrap',
|
|
118
|
-
wordBreak: 'break-all',
|
|
119
|
-
'@media (max-width: 2560px)': {
|
|
120
|
-
maxWidth: '1800px',
|
|
121
|
-
},
|
|
122
|
-
'@media (max-width: 2000px)': {
|
|
123
|
-
maxWidth: '1500px',
|
|
124
|
-
},
|
|
125
|
-
'@media (max-width: 1600px)': {
|
|
126
|
-
maxWidth: '1100px',
|
|
127
|
-
},
|
|
128
|
-
'@media (max-width: 1300px)': {
|
|
129
|
-
maxWidth: '900px',
|
|
130
|
-
},
|
|
131
187
|
},
|
|
132
188
|
urlViewBtn: {
|
|
133
189
|
cursor: 'pointer',
|
|
134
190
|
},
|
|
191
|
+
collapseLink: {
|
|
192
|
+
maxHeight: '1em',
|
|
193
|
+
display: 'block',
|
|
194
|
+
// display: '-webkit-box',
|
|
195
|
+
'-webkit-box-orient': 'vertical',
|
|
196
|
+
'-webkit-line-clamp': '1',
|
|
197
|
+
overflow: 'hidden',
|
|
198
|
+
},
|
|
199
|
+
expandLink: {
|
|
200
|
+
cursor: 'pointer',
|
|
201
|
+
},
|
|
202
|
+
expandLinkBtn: {
|
|
203
|
+
float: 'left',
|
|
204
|
+
'&:hover': {
|
|
205
|
+
cursor: 'pointer',
|
|
206
|
+
},
|
|
207
|
+
},
|
|
135
208
|
viewLinkToggleBtn: {
|
|
136
|
-
padding: '5px 10px 5px 10px',
|
|
137
209
|
height: '20px',
|
|
138
210
|
fontFamily: 'Nunito',
|
|
139
211
|
fontSize: '12px',
|
|
@@ -146,12 +218,28 @@ const styles = () => ({
|
|
|
146
218
|
color: '#fff',
|
|
147
219
|
float: 'left',
|
|
148
220
|
margin: '0px 10px 0px 0px',
|
|
149
|
-
whiteSpace: 'nowrap',
|
|
150
221
|
'&:hover': {
|
|
151
222
|
backgroundColor: '#1D79A8',
|
|
152
223
|
color: '#fff',
|
|
153
224
|
},
|
|
154
225
|
},
|
|
226
|
+
urlView: {
|
|
227
|
+
float: 'left',
|
|
228
|
+
width: 'calc(100% - 13px)',
|
|
229
|
+
minWidth: '840px',
|
|
230
|
+
'@media (max-width: 2560px)': {
|
|
231
|
+
maxWidth: '1800px',
|
|
232
|
+
},
|
|
233
|
+
'@media (max-width: 2000px)': {
|
|
234
|
+
maxWidth: '1400px',
|
|
235
|
+
},
|
|
236
|
+
'@media (max-width: 1600px)': {
|
|
237
|
+
maxWidth: '1200px',
|
|
238
|
+
},
|
|
239
|
+
'@media (max-width: 1300px)': {
|
|
240
|
+
maxWidth: '1050px',
|
|
241
|
+
},
|
|
242
|
+
},
|
|
155
243
|
copyIconBtn: {
|
|
156
244
|
padding: '0px',
|
|
157
245
|
height: '20px',
|