-
Notifications
You must be signed in to change notification settings - Fork 20
Страница репозитория: Popover для клонирования #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a3a7da3
feat(repo-explorer): added clone repo popover
niyazm524 dca3e7f
feat(repo-details): refactored clone menu
niyazm524 6a7d73d
styles(repo-details): adjusted field width
niyazm524 b7f0218
feat(clone-popover): improved UX by adding result tooltip
niyazm524 8d538aa
style(clone-popover): fixed style lint
niyazm524 38d3b12
Merge branch 'dev' into feature/clone-popover
azinit a633ad0
Merge branch 'dev' into feature/clone-popover
niyazm524 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/features/repo-explorer/components/toolbar/clone-menu.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import React, { useCallback, useEffect, useRef, useState } from "react"; | ||
| import { CopyOutlined } from "@ant-design/icons"; | ||
| import { Button, Input, Tooltip } from "antd"; | ||
|
|
||
| type Props = { url: string }; | ||
|
|
||
| export default function CloneMenu({ url }: Props) { | ||
| const cloneField = useRef<Input>(null); | ||
| const [isUrlCopied, setUrlCopied] = useState<boolean | null>(null); | ||
| useEffect(() => { | ||
| if (isUrlCopied == null) return; | ||
| setTimeout(() => setUrlCopied(null), 1000); | ||
| }, [isUrlCopied]); | ||
|
|
||
| const copyUrl = useCallback(() => { | ||
| const input = cloneField.current?.input; | ||
| if (!input) return; | ||
| input.focus(); | ||
| input.select(); | ||
| try { | ||
| document.execCommand("copy"); | ||
| setUrlCopied(true); | ||
| } catch (err) { | ||
| setUrlCopied(false); | ||
| } finally { | ||
| input.blur(); | ||
| } | ||
| }, [cloneField]); | ||
|
|
||
| return ( | ||
| <div className="clone-content"> | ||
| <Input | ||
| ref={cloneField} | ||
| value={url} | ||
| onClick={(e) => e.currentTarget.select()} | ||
| addonAfter={ | ||
| <Tooltip | ||
| title={isUrlCopied === false ? "Ошибка копирования" : "Скопировано"} | ||
| placement="bottom" | ||
| visible={isUrlCopied != null} | ||
| > | ||
| <Button onClick={copyUrl} icon={<CopyOutlined className="copy-button" />} /> | ||
| </Tooltip> | ||
| } | ||
| /> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| .clone-content { | ||
| .ant-input { | ||
| min-width: 360px; | ||
| border-right: none; | ||
| } | ||
|
|
||
| .ant-input-group-addon { | ||
| padding: 0; | ||
| border: 0; | ||
| } | ||
|
|
||
| .copy-button { | ||
| border-radius: 0 2px 2px 0; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.