Fix 2FA sizing issue, add support for copying text from xterm.js (#1825)

closes #1812, closes #1813
This commit is contained in:
Matthew Penner 2020-02-11 10:37:12 -07:00 committed by GitHub
parent 1b1c95d8ce
commit b05048871c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 69 additions and 35 deletions

View File

@ -8,6 +8,27 @@ import { StaticContext } from 'react-router';
import FlashMessageRender from '@/components/FlashMessageRender'; import FlashMessageRender from '@/components/FlashMessageRender';
import { ApplicationStore } from '@/state'; import { ApplicationStore } from '@/state';
import Spinner from '@/components/elements/Spinner'; import Spinner from '@/components/elements/Spinner';
import styled from 'styled-components';
import { breakpoint } from 'styled-components-breakpoint';
const Container = styled.div`
${breakpoint('sm')`
${tw`w-4/5 mx-auto`}
`};
${breakpoint('md')`
${tw`p-10`}
`};
${breakpoint('lg')`
${tw`w-3/5`}
`};
${breakpoint('xl')`
${tw`w-full`}
max-width: 660px;
`};
`;
export default ({ history, location: { state } }: RouteComponentProps<{}, StaticContext, { token?: string }>) => { export default ({ history, location: { state } }: RouteComponentProps<{}, StaticContext, { token?: string }>) => {
const [ code, setCode ] = useState(''); const [ code, setCode ] = useState('');
@ -52,6 +73,7 @@ export default ({ history, location: { state } }: RouteComponentProps<{}, Static
<h2 className={'text-center text-neutral-100 font-medium py-4'}> <h2 className={'text-center text-neutral-100 font-medium py-4'}>
Device Checkpoint Device Checkpoint
</h2> </h2>
<Container>
<FlashMessageRender/> <FlashMessageRender/>
<LoginFormContainer onSubmit={submit}> <LoginFormContainer onSubmit={submit}>
<div className={'mt-6'}> <div className={'mt-6'}>
@ -87,6 +109,7 @@ export default ({ history, location: { state } }: RouteComponentProps<{}, Static
</Link> </Link>
</div> </div>
</LoginFormContainer> </LoginFormContainer>
</Container>
</React.Fragment> </React.Fragment>
); );
}; };

View File

@ -81,6 +81,17 @@ export default () => {
// @see https://github.com/xtermjs/xterm.js/issues/2265 // @see https://github.com/xtermjs/xterm.js/issues/2265
// @see https://github.com/xtermjs/xterm.js/issues/2230 // @see https://github.com/xtermjs/xterm.js/issues/2230
TerminalFit.fit(terminal); TerminalFit.fit(terminal);
// Add support for copying terminal text.
terminal.attachCustomKeyEventHandler((e: KeyboardEvent) => {
// Ctrl + C
if (e.ctrlKey && (e.key === 'c')) {
document.execCommand('copy');
return false;
}
return true;
});
} }
}, [ terminal, connected, terminalElement ]); }, [ terminal, connected, terminalElement ]);