-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(admin): more work toward chat users
- Loading branch information
Showing
25 changed files
with
1,085 additions
and
753 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
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,32 @@ | ||
import { Classes, Dialog, IDialogProps } from '@blueprintjs/core' | ||
import React, { FC } from 'react' | ||
|
||
type Props = { | ||
onSubmit?: (event: any) => void | ||
} & Partial<IDialogProps> | ||
|
||
export const BaseDialog: FC<Props> = props => { | ||
return ( | ||
<Dialog transitionDuration={0} canOutsideClickClose={false} enforceFocus={false} {...props}> | ||
{props.onSubmit ? <form onSubmit={props.onSubmit}>{props.children}</form> : props.children} | ||
</Dialog> | ||
) | ||
} | ||
|
||
export const DialogBody = ({ children }) => { | ||
return <div className={Classes.DIALOG_BODY}>{children}</div> | ||
} | ||
|
||
export const DialogFooter = ({ children }) => { | ||
return ( | ||
<div className={Classes.DIALOG_FOOTER}> | ||
<div className={Classes.DIALOG_FOOTER_ACTIONS}>{children}</div> | ||
</div> | ||
) | ||
} | ||
|
||
export const BPDialog = { | ||
Container: BaseDialog, | ||
Body: DialogBody, | ||
Footer: DialogFooter | ||
} |
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
92 changes: 92 additions & 0 deletions
92
src/bp/ui-admin/src/Pages/Workspace/Users/AuthStrategyDropdown.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,92 @@ | ||
import { Button, Classes, MenuItem } from '@blueprintjs/core' | ||
import { ItemPredicate, ItemRenderer, Select } from '@blueprintjs/select' | ||
import { AuthStrategyConfig } from 'common/typings' | ||
import React, { FC, useEffect, useState } from 'react' | ||
import { connect } from 'react-redux' | ||
|
||
import { fetchAuthConfig } from '../../../reducers/user' | ||
|
||
interface OwnProps { | ||
onChange: (strategy: AuthStrategyConfig) => void | ||
} | ||
|
||
interface DispatchProps { | ||
fetchAuthConfig: () => void | ||
} | ||
|
||
interface StateProps { | ||
authConfig: AuthStrategyConfig[] | ||
} | ||
|
||
type Props = DispatchProps & StateProps & OwnProps | ||
|
||
const SelectDropdown = Select.ofType<AuthStrategyConfig>() | ||
|
||
const AuthStrategyDropdown: FC<Props> = props => { | ||
const [selected, setSelected] = useState<AuthStrategyConfig>() | ||
|
||
useEffect(() => { | ||
if (!props.authConfig) { | ||
props.fetchAuthConfig() | ||
} else if (props.authConfig.length) { | ||
selectOption(props.authConfig[0]) | ||
} | ||
}, [props.authConfig]) | ||
|
||
const selectOption = item => { | ||
if (item) { | ||
setSelected(item) | ||
props.onChange(item) | ||
} | ||
} | ||
|
||
if (!props.authConfig || !selected) { | ||
return null | ||
} | ||
|
||
return ( | ||
<SelectDropdown | ||
items={props.authConfig} | ||
itemPredicate={filterOptions} | ||
itemRenderer={renderOption} | ||
activeItem={selected} | ||
popoverProps={{ minimal: true }} | ||
noResults={<MenuItem disabled={true} text="No results." />} | ||
onItemSelect={option => selectOption(option)} | ||
onActiveItemChange={option => selectOption(option)} | ||
> | ||
<Button text={selected.label || selected.strategyId} rightIcon="double-caret-vertical" /> | ||
</SelectDropdown> | ||
) | ||
} | ||
|
||
const filterOptions: ItemPredicate<AuthStrategyConfig> = (query, option, _index) => { | ||
const normalizedLabel = option.label && option.label.toLowerCase() | ||
const normalizedQuery = query.toLowerCase() | ||
|
||
return `${normalizedLabel} ${option.strategyId}`.indexOf(normalizedQuery) >= 0 | ||
} | ||
|
||
const renderOption: ItemRenderer<AuthStrategyConfig> = (option, { handleClick, modifiers, query }) => { | ||
if (!modifiers.matchesPredicate) { | ||
return null | ||
} | ||
|
||
return ( | ||
<MenuItem | ||
className={Classes.SMALL} | ||
active={modifiers.active} | ||
disabled={modifiers.disabled} | ||
key={option.strategyId} | ||
onClick={handleClick} | ||
text={option.label || option.strategyId} | ||
/> | ||
) | ||
} | ||
|
||
const mapStateToProps = state => ({ authConfig: state.user.authConfig }) | ||
|
||
export default connect<StateProps, DispatchProps>( | ||
mapStateToProps, | ||
{ fetchAuthConfig } | ||
)(AuthStrategyDropdown) |
Oops, something went wrong.