From 0371cfd292fe515042afc2b70e4e82900cff302f Mon Sep 17 00:00:00 2001 From: Surma Date: Tue, 1 Dec 2020 13:12:28 +0000 Subject: [PATCH 1/7] Add CLI button --- .../lazy-app/Compress/Options/index.tsx | 23 ++++++++- .../lazy-app/util/cli-invocation-generator.ts | 51 +++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 src/client/lazy-app/util/cli-invocation-generator.ts diff --git a/src/client/lazy-app/Compress/Options/index.tsx b/src/client/lazy-app/Compress/Options/index.tsx index ede3b056..233b8c5a 100644 --- a/src/client/lazy-app/Compress/Options/index.tsx +++ b/src/client/lazy-app/Compress/Options/index.tsx @@ -18,6 +18,8 @@ import Select from './Select'; import { Options as QuantOptionsComponent } from 'features/processors/quantize/client'; import { Options as ResizeOptionsComponent } from 'features/processors/resize/client'; +import { generateCliInvocation } from '../../util/cli-invocation-generator'; + interface Props { mobileView: boolean; source?: SourceImage; @@ -97,6 +99,23 @@ export default class Options extends Component { ); }; + private onCreateCLIInvocation = () => { + if (!this.props.encoderState) { + return; + } + + try { + const cliInvocation = generateCliInvocation( + this.props.encoderState, + this.props.processorState, + ); + navigator.clipboard.writeText(cliInvocation); + } catch (e) { + // Show toast + console.error(e); + } + }; + render( { source, encoderState, processorState, onEncoderOptionsChange }: Props, { supportedEncoderMap }: State, @@ -110,7 +129,9 @@ export default class Options extends Component { {!encoderState ? null : (
-

Edit

+

+ Edit +