Skip to content

Commit 89e47a5

Browse files
Merge pull request #886 from KelvinTegelaar/dev
Dev to release
2 parents 7f1b403 + 1f18dd2 commit 89e47a5

File tree

23 files changed

+1466
-1134
lines changed

23 files changed

+1466
-1134
lines changed

.stylelintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"extends": "stylelint-config-sass-guidelines",
33
"rules": {
44
"selector-class-pattern": null,
5-
"max-nesting-depth": 5,
5+
"max-nesting-depth": 6,
66
"selector-no-qualifying-type": [
77
true,
88
{

package-lock.json

Lines changed: 1181 additions & 998 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"react-papaparse": "^3.18.2",
6969
"react-redux": "^7.2.5",
7070
"react-router-dom": "^6.1.1",
71+
"react-select": "^5.3.0",
7172
"react-select-search": "^3.0.8",
7273
"react-syntax-highlighter": "^15.4.5",
7374
"redux": "4.1.1",

public/version_latest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.4.0
1+
2.5.0

src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const Page403 = React.lazy(() => import('./views/pages/page403/Page403'))
1616
const Page404 = React.lazy(() => import('./views/pages/page404/Page404'))
1717
const Page500 = React.lazy(() => import('./views/pages/page500/Page500'))
1818
const Login = React.lazy(() => import('./views/pages/login/Login'))
19+
const Logout = React.lazy(() => import('./views/pages/login/Logout'))
1920

2021
const App = () => {
2122
return (
@@ -31,6 +32,7 @@ const App = () => {
3132
<Route exact path="/404" name="Page 404" element={<Page404 />} />
3233
<Route exact path="/500" name="Page 500" element={<Page500 />} />
3334
<Route exact path="/login" name="Login" element={<Login />} />
35+
<Route exact path="/logout" name="Logout" element={<Logout />} />
3436
<Route
3537
path="/"
3638
element={

src/components/forms/RFFComponents.js

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import {
77
CFormSwitch,
88
CFormTextarea,
99
} from '@coreui/react'
10-
import SelectSearch, { fuzzySearch } from 'react-select-search'
10+
import Select from 'react-select'
1111
import { Field } from 'react-final-form'
1212
import React from 'react'
1313
import PropTypes from 'prop-types'
14-
import classNames from 'classnames'
1514

1615
/*
1716
wrapper classes for React Final Form with CoreUI
@@ -273,22 +272,6 @@ Condition.propTypes = {
273272
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
274273
}
275274

276-
const RFFSelectSearchClasses = {
277-
container: 'form-select is-valid',
278-
value: 'select-search__value',
279-
input: 'select-search__input form-select',
280-
select: 'select-search__select',
281-
row: 'select-search__row',
282-
options: 'select-search__options',
283-
option: 'select-search__option',
284-
group: 'select-search__group',
285-
'group-header': 'select-search__group-header',
286-
'is-selected': 'select-search.is-selected',
287-
'is-highlighted': 'select-search.is-highlighted',
288-
'is-loading': 'select-search.is-loading',
289-
'has-focus': 'select-search.has-focus',
290-
}
291-
292275
export const RFFSelectSearch = ({
293276
name,
294277
label,
@@ -298,35 +281,26 @@ export const RFFSelectSearch = ({
298281
onChange,
299282
disabled = false,
300283
}) => {
284+
const selectSearchvalues = values.map((val) => ({
285+
value: val.value,
286+
label: val.name,
287+
}))
288+
301289
return (
302290
<Field name={name} validate={validate}>
303291
{({ meta, input }) => {
304292
return (
305293
<div>
306294
<CFormLabel htmlFor={name}>{label}</CFormLabel>
307-
<SelectSearch
295+
<Select
296+
className="react-select-container"
297+
classNamePrefix="react-select"
308298
{...input}
309-
valid={!meta.error && meta.touched}
310-
invalid={meta.error && meta.touched}
311-
search
299+
isClearable={true}
312300
name={name}
313301
id={name}
314-
// @todo fix this override so the styling is the same as coreui or override render?
315-
className={(key) => {
316-
if (key === 'container') {
317-
return classNames('form-select', {
318-
'is-valid': !meta.error && meta.touched,
319-
'is-invalid': meta.error && meta.touched,
320-
})
321-
}
322-
return RFFSelectSearchClasses[key]
323-
}}
324302
disabled={disabled}
325-
options={values}
326-
filterOptions={fuzzySearch}
327-
value={input.value}
328-
//commented out this on change, because even when it was not set it was using the value, causing issues with the event.
329-
onChange={input.onChange}
303+
options={selectSearchvalues}
330304
placeholder={placeholder}
331305
/>
332306
<RFFCFormFeedback meta={meta} />

src/components/tables/CippTable.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,20 @@ export default function CippTable({
148148
])
149149
}
150150
if (!disableCSVExport) {
151+
const keys = []
152+
columns.map((col) => {
153+
if (col.exportSelector) keys.push(col.exportSelector)
154+
return null
155+
})
156+
157+
console.log(keys)
158+
const filtered = data.map((obj) =>
159+
// eslint-disable-next-line no-sequences
160+
keys.reduce((acc, curr) => ((acc[curr] = obj[curr]), acc), {}),
161+
)
162+
console.log(filtered)
151163
defaultActions.push([
152-
<ExportCsvButton key="export-csv-action" csvData={data} reportName={reportName} />,
164+
<ExportCsvButton key="export-csv-action" csvData={filtered} reportName={reportName} />,
153165
])
154166
}
155167
return (

src/components/utilities/TenantSelectorMultiple.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import { useListTenantsQuery } from 'src/store/api/tenants'
3-
import SelectSearch, { fuzzySearch } from 'react-select-search'
3+
import Select from 'react-select'
44
import PropTypes from 'prop-types'
55

66
const TenantSelectorMultiple = React.forwardRef(
@@ -17,23 +17,25 @@ const TenantSelectorMultiple = React.forwardRef(
1717
} else if (error) {
1818
placeholder = 'Error loading tenants'
1919
}
20-
20+
const mappedValue = values.map((val) => val.value)
2121
return (
22-
<SelectSearch
22+
<Select
23+
className="react-select-container"
24+
classNamePrefix="react-select"
2325
ref={ref}
24-
search
26+
isMulti={true}
2527
onChange={onChange}
26-
filterOptions={fuzzySearch}
2728
placeholder={placeholder}
28-
value={values}
29+
value={mappedValue.value}
30+
getOptionLabel={(option) => option.label}
31+
getOptionValue={(option) => option.value}
2932
disabled={isLoading}
3033
options={tenants.map(({ customerId, defaultDomainName, displayName }) => ({
3134
value: customerId,
32-
name: [displayName] + [` (${defaultDomainName})`],
35+
label: [displayName] + [` (${defaultDomainName})`],
3336
}))}
3437
multiple
3538
printOptions="on-focus"
36-
closeOnSelect={false}
3739
{...rest}
3840
/>
3941
)

src/scss/_custom.scss

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,3 +395,38 @@
395395
.sidebar-nav .nav-link {
396396
margin: 0.25rem 0;
397397
}
398+
.react-select-container {
399+
.react-select__control {
400+
background-color: var(--cipp-search-bg);
401+
border-color: var(--cipp-search-border-color);
402+
transition: none;
403+
404+
&:hover {
405+
border-color: var(--cipp-search-border-color);
406+
}
407+
}
408+
409+
.react-select__menu {
410+
background-color: var(--cipp-search-bg);
411+
border: 1px solid var(--cipp-search-border-color);
412+
}
413+
414+
.react-select__option {
415+
background-color: var(--cipp-search-bg);
416+
417+
&:hover {
418+
background-color: var(--cipp-search-border-color);
419+
}
420+
}
421+
.react-select__indicator {
422+
color: var(--cipp-search-border-color);
423+
}
424+
.react-select__indicator-separator {
425+
background-color: var(--cipp-search-border-color);
426+
}
427+
428+
.react-select__placeholder,
429+
.react-select__single-value {
430+
color: var(--text-primary);
431+
}
432+
}

src/views/cipp/CIPPSettings.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -107,25 +107,16 @@ const GeneralSettings = () => {
107107
const [selectedTenants, setSelectedTenants] = useState([])
108108
const [showMaxSelected, setShowMaxSelected] = useState(false)
109109
const [tokenOffcanvasVisible, setTokenOffcanvasVisible] = useState(false)
110-
const maxSelected = 3
110+
const maxSelected = 2
111111
const tenantSelectorRef = useRef(null)
112112

113-
const handleSetSelectedTenants = (values) => {
114-
if (values.length <= maxSelected) {
115-
setSelectedTenants(values)
113+
const handleSetSelectedTenants = (value) => {
114+
if (value.length <= maxSelected) {
115+
setSelectedTenants(value)
116116
setShowMaxSelected(false)
117117
} else {
118+
setSelectedTenants(value)
118119
setShowMaxSelected(true)
119-
// close the tenant selector, hacky but no other way to do this
120-
// without making a fully custom selector
121-
// https://github.com/tbleckert/react-select-search#headless-mode-with-hooks
122-
tenantSelectorRef.current?.firstChild?.firstChild?.blur()
123-
124-
// re-set selected tenants to force a re-render? nope doesnt work
125-
// https://github.com/tbleckert/react-select-search/issues/221
126-
const temp = selectedTenants
127-
setSelectedTenants([])
128-
setSelectedTenants(temp)
129120
}
130121
}
131122

@@ -320,22 +311,31 @@ const GeneralSettings = () => {
320311
</CCardHeader>
321312
<CCardBody>
322313
<div className="mb-3">
323-
Click the button below to start a tenant access check. You can select multiple
324-
tenants up to a maximum of {maxSelected} tenants at one time.
314+
Click the button below to start a tenant access check. You can select multiple a
315+
maximum of {maxSelected + 1} tenants is recommended.
325316
</div>
326317

327318
<TenantSelectorMultiple
328319
ref={tenantSelectorRef}
329320
values={selectedTenants}
330-
onChange={handleSetSelectedTenants}
321+
onChange={(value) =>
322+
handleSetSelectedTenants(
323+
value.map((val) => {
324+
return val.value
325+
}),
326+
)
327+
}
331328
/>
332329
{showMaxSelected && (
333330
<CCallout color="warning">
334-
A maximum of {maxSelected} tenants can be selected at once.
331+
A maximum of {maxSelected + 1} tenants is recommended.
335332
</CCallout>
336333
)}
337334
<br />
338-
<CButton onClick={() => handleCheckAccess()} disabled={accessCheckResult.isFetching}>
335+
<CButton
336+
onClick={() => handleCheckAccess()}
337+
disabled={accessCheckResult.isFetching || selectedTenants.length < 1}
338+
>
339339
{accessCheckResult.isFetching && (
340340
<FontAwesomeIcon icon={faCircleNotch} spin className="me-2" size="1x" />
341341
)}
@@ -523,7 +523,7 @@ const SecuritySettings = () => {
523523
<CCardTitle>Static Web App (Role Management)</CCardTitle>
524524
</CCardHeader>
525525
<CCardBody className="equalheight">
526-
The Statis Web App role management allows you to invite other users to the
526+
The Static Web App role management allows you to invite other users to the
527527
application.
528528
<br /> <br />
529529
<a

0 commit comments

Comments
 (0)