-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Users/Groups): simpilfy CommaSeparatedListWithRestCounter compone…
…nt, now user always will be able to see all group members and all groups of specific user [#704]
- Loading branch information
Showing
9 changed files
with
94 additions
and
312 deletions.
There are no files selected for viewing
251 changes: 0 additions & 251 deletions
251
...ui/src/ui/components/CommaSeparateListWithRestCounter/CommaSeparateListWithRestCounter.js
This file was deleted.
Oops, something went wrong.
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
77 changes: 77 additions & 0 deletions
77
...i/src/ui/components/CommaSeparateListWithRestCounter/CommaSeparateListWithRestCounter.tsx
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,77 @@ | ||
import React from 'react'; | ||
import cn from 'bem-cn-lite'; | ||
|
||
import SimpleModal from '../../components/Modal/SimpleModal'; | ||
|
||
import './CommaSeparateListWithRestCounter.scss'; | ||
import {VisibleValues} from '../../components/VisibleValues/VisibleValues'; | ||
|
||
const block = cn('comma-separated-list-with-rest-counter'); | ||
|
||
const MAX_CHARACTERS_PER_ROW = 80; | ||
|
||
type Props = { | ||
className?: string; | ||
items?: string[]; | ||
itemRenderer?: (item: string) => React.ReactNode; | ||
maxCharactersPerRow?: number; | ||
}; | ||
|
||
type State = { | ||
showDialog: boolean; | ||
}; | ||
|
||
export default class CommaSeparatedListWithRestCounter extends React.Component<Props, State> { | ||
state = { | ||
showDialog: false, | ||
}; | ||
|
||
renderItem = (item: string) => { | ||
const {itemRenderer} = this.props; | ||
return itemRenderer ? itemRenderer(item) : item; | ||
}; | ||
|
||
closeDialog = () => { | ||
this.setState({showDialog: false}); | ||
}; | ||
|
||
openDialog = () => { | ||
this.setState({showDialog: true}); | ||
}; | ||
|
||
renderModalContent() { | ||
const {items = []} = this.props; | ||
|
||
return ( | ||
<div className={block('tooltip', 'yc-root')}> | ||
{items.map((item) => { | ||
return <div key={item}>{this.renderItem(item)}</div>; | ||
})} | ||
</div> | ||
); | ||
} | ||
|
||
render() { | ||
const {className, maxCharactersPerRow, items = []} = this.props; | ||
const maxTextLength = maxCharactersPerRow || MAX_CHARACTERS_PER_ROW; | ||
const {showDialog} = this.state; | ||
|
||
const value = items.length ? items : items.concat(''); | ||
|
||
return ( | ||
<div className={block(null, className)}> | ||
<VisibleValues | ||
onCounterClick={this.openDialog} | ||
value={value} | ||
maxTextLength={maxTextLength} | ||
renderItem={this.renderItem} | ||
width="max" | ||
counter="missing-values" | ||
/> | ||
<SimpleModal title={'All items'} visible={showDialog} onCancel={this.closeDialog}> | ||
{showDialog && this.renderModalContent()} | ||
</SimpleModal> | ||
</div> | ||
); | ||
} | ||
} |
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.