Skip to content

Commit

Permalink
adding dropdown disable
Browse files Browse the repository at this point in the history
  • Loading branch information
marckong committed Aug 29, 2022
1 parent e22cb13 commit 1a27523
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ AuthItem.displayName = DropdownItem.name;

interface Props {
authTypes?: AuthType[];
disabled?: boolean;
}
export const AuthDropdown: FC<Props> = ({ authTypes = defaultTypes }) => {
export const AuthDropdown: FC<Props> = ({ authTypes = defaultTypes, disabled = false }) => {
const activeRequest = useSelector(selectActiveRequest);

const onClick = useCallback(async (type: AuthType) => {
Expand Down Expand Up @@ -189,7 +190,7 @@ export const AuthDropdown: FC<Props> = ({ authTypes = defaultTypes }) => {
return (
<Dropdown beside>
<DropdownDivider>Auth Types</DropdownDivider>
<DropdownButton className="tall">
<DropdownButton className="tall" disabled={disabled}>
{'authentication' in activeRequest ? getAuthTypeName(activeRequest.authentication.type) || 'Auth' : 'Auth'}
<i className="fa fa-caret-down space-left" />
</DropdownButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ interface Props {
// TODO: @gatzjames discuss above assertion in light of request and settings drills
export const WebSocketRequestPane: FC<Props> = ({ request, workspaceId }) => {
const readyState = useWSReadyState(request._id);
const disabled = readyState === ReadyState.OPEN || readyState === ReadyState.CLOSING;
const handleOnChange = (event: ChangeEvent<HTMLInputElement>) => {
const url = event.currentTarget.value || '';
if (url !== request.url) {
Expand Down Expand Up @@ -106,7 +107,10 @@ export const WebSocketRequestPane: FC<Props> = ({ request, workspaceId }) => {
<button>Headers</button>
</Tab>
<Tab tabIndex="-1" >
<AuthDropdown authTypes={supportedAuthTypes} />
<AuthDropdown
authTypes={supportedAuthTypes}
disabled={disabled}
/>
</Tab>
</TabList>
<TabPanel className="react-tabs__tab-panel">
Expand All @@ -131,7 +135,7 @@ export const WebSocketRequestPane: FC<Props> = ({ request, workspaceId }) => {
</TabPanel>
<TabPanel className="react-tabs__tab-panel">
<AuthWrapper
key={`${request._id}-${readyState}-auth-header`}
key={`${request._id}-${request.authentication.type}-auth-header`}
disabled={readyState === ReadyState.OPEN || readyState === ReadyState.CLOSING}
/>
</TabPanel>
Expand Down

0 comments on commit 1a27523

Please sign in to comment.