-
-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(cherry picked from commit 7a768b5d0faf9aa57e78aee19cefee8fb19a42d5)
- Loading branch information
1 parent
4781675
commit d0df761
Showing
59 changed files
with
877 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,9 @@ | |
|
||
width: 80px; | ||
} | ||
|
||
.indexerFlags { | ||
composes: cell from '~Components/Table/Cells/TableRowCell.css'; | ||
|
||
width: 50px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import createIndexerFlagsSelector from 'Store/Selectors/createIndexerFlagsSelector'; | ||
|
||
interface IndexerFlagsProps { | ||
indexerFlags: number; | ||
} | ||
|
||
function IndexerFlags({ indexerFlags = 0 }: IndexerFlagsProps) { | ||
const allIndexerFlags = useSelector(createIndexerFlagsSelector); | ||
|
||
const flags = allIndexerFlags.items.filter( | ||
// eslint-disable-next-line no-bitwise | ||
(item) => (indexerFlags & item.id) === item.id | ||
); | ||
|
||
return flags.length ? ( | ||
<ul> | ||
{flags.map((flag, index) => { | ||
return <li key={index}>{flag.name}</li>; | ||
})} | ||
</ul> | ||
) : null; | ||
} | ||
|
||
export default IndexerFlags; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React, { useCallback } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import { createSelector } from 'reselect'; | ||
import AppState from 'App/State/AppState'; | ||
import EnhancedSelectInput from './EnhancedSelectInput'; | ||
|
||
const selectIndexerFlagsValues = (selectedFlags: number) => | ||
createSelector( | ||
(state: AppState) => state.settings.indexerFlags, | ||
(indexerFlags) => { | ||
const value = indexerFlags.items.reduce((acc: number[], { id }) => { | ||
// eslint-disable-next-line no-bitwise | ||
if ((selectedFlags & id) === id) { | ||
acc.push(id); | ||
} | ||
|
||
return acc; | ||
}, []); | ||
|
||
const values = indexerFlags.items.map(({ id, name }) => ({ | ||
key: id, | ||
value: name, | ||
})); | ||
|
||
return { | ||
value, | ||
values, | ||
}; | ||
} | ||
); | ||
|
||
interface IndexerFlagsSelectInputProps { | ||
name: string; | ||
indexerFlags: number; | ||
onChange(payload: object): void; | ||
} | ||
|
||
function IndexerFlagsSelectInput(props: IndexerFlagsSelectInputProps) { | ||
const { indexerFlags, onChange } = props; | ||
|
||
const { value, values } = useSelector(selectIndexerFlagsValues(indexerFlags)); | ||
|
||
const onChangeWrapper = useCallback( | ||
({ name, value }: { name: string; value: number[] }) => { | ||
const indexerFlags = value.reduce((acc, flagId) => acc + flagId, 0); | ||
|
||
onChange({ name, value: indexerFlags }); | ||
}, | ||
[onChange] | ||
); | ||
|
||
return ( | ||
<EnhancedSelectInput | ||
{...props} | ||
value={value} | ||
values={values} | ||
onChange={onChangeWrapper} | ||
/> | ||
); | ||
} | ||
|
||
export default IndexerFlagsSelectInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.