From 21a2a2bdf4db91923729867cfdd5e5040a10058d Mon Sep 17 00:00:00 2001 From: Piyush Date: Fri, 26 Feb 2021 12:28:47 +0530 Subject: [PATCH] Redirect URL for oAuth Auth code flow (#3232) --- .../src/components/ads/CopyToClipBoard.tsx | 60 +++++++++++++++++++ .../appsmith/CopyToClipBoard.tsx | 23 +++---- .../formControls/DropDownControl.tsx | 18 +++++- .../formControls/InputTextControl.tsx | 32 ++++++++-- .../RestAPIDatasourceForm.tsx | 24 +++++++- .../pages/organization/AppInviteUsersForm.tsx | 2 +- 6 files changed, 140 insertions(+), 19 deletions(-) create mode 100644 app/client/src/components/ads/CopyToClipBoard.tsx diff --git a/app/client/src/components/ads/CopyToClipBoard.tsx b/app/client/src/components/ads/CopyToClipBoard.tsx new file mode 100644 index 0000000000..e6ff4633a3 --- /dev/null +++ b/app/client/src/components/ads/CopyToClipBoard.tsx @@ -0,0 +1,60 @@ +import React, { createRef, useState } from "react"; +import styled from "styled-components"; +import copy from "copy-to-clipboard"; +import TextInput from "components/ads/TextInput"; +import Button, { Category, Size } from "components/ads/Button"; + +const Wrapper = styled.div` + display: flex; + + div { + flex-basis: calc(100% - 110px); + } + a { + flex-basis: 110px; + } +`; + +const CopyToClipboard = (props: any) => { + const { copyText } = props; + const copyURLInput = createRef(); + const [isCopied, setIsCopied] = useState(false); + + const copyToClipboard = (url: string) => { + copy(url); + setIsCopied(true); + setTimeout(() => { + setIsCopied(false); + }, 3000); + }; + + const selectText = () => { + if (copyURLInput.current) { + copyURLInput.current.setSelectionRange(0, copyText.length); + } + }; + return ( + + { + selectText(); + }} + defaultValue={copyText} + /> + +