mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-07 22:18:33 +00:00
* mask support for SingleLineEditor * add secret visibility toggle button * move visibility toggle into SingleLineComponent Co-authored-by: Liz MacLean <18120837+lizziemac@users.noreply.github.com> * fix eye button focus state * center enabled and secret toggle * fix input field scales to 100% width * Using a prvacy toggle for all sensitive auth details. * Applied privacy toggle to Collection Auth settings. --------- Co-authored-by: Max Bauer <krummbar@pm.me> Co-authored-by: Liz MacLean <18120837+lizziemac@users.noreply.github.com>
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
import React from 'react';
|
|
import get from 'lodash/get';
|
|
import { useTheme } from 'providers/Theme';
|
|
import { useDispatch } from 'react-redux';
|
|
import SingleLineEditor from 'components/SingleLineEditor';
|
|
import { updateCollectionAuth } from 'providers/ReduxStore/slices/collections';
|
|
import { saveCollectionRoot } from 'providers/ReduxStore/slices/collections/actions';
|
|
import StyledWrapper from './StyledWrapper';
|
|
|
|
const BearerAuth = ({ collection }) => {
|
|
const dispatch = useDispatch();
|
|
const { storedTheme } = useTheme();
|
|
|
|
const bearerToken = get(collection, 'root.request.auth.bearer.token', '');
|
|
|
|
const handleSave = () => dispatch(saveCollectionRoot(collection.uid));
|
|
|
|
const handleTokenChange = (token) => {
|
|
dispatch(
|
|
updateCollectionAuth({
|
|
mode: 'bearer',
|
|
collectionUid: collection.uid,
|
|
content: {
|
|
token: token
|
|
}
|
|
})
|
|
);
|
|
};
|
|
|
|
return (
|
|
<StyledWrapper className="mt-2 w-full">
|
|
<label className="block font-medium mb-2">Token</label>
|
|
<div className="single-line-editor-wrapper">
|
|
<SingleLineEditor
|
|
value={bearerToken}
|
|
theme={storedTheme}
|
|
onSave={handleSave}
|
|
onChange={(val) => handleTokenChange(val)}
|
|
collection={collection}
|
|
isSecret={true}
|
|
/>
|
|
</div>
|
|
</StyledWrapper>
|
|
);
|
|
};
|
|
|
|
export default BearerAuth;
|