Skip to content
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

Add copy link button #1001

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/components/omnisearch/CourseSearchResultVideo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from "react";
import { getCourseVideoUrl, getStreamUrl } from "../../utils/UrlUtilities";
import { Bookmarkable } from "../../model/Bookmark";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faBookmark, faCloudDownloadAlt, faEye, faEyeSlash } from "@fortawesome/free-solid-svg-icons";
import { faBookmark, faCloudDownloadAlt, faEye, faEyeSlash, faCopy } from "@fortawesome/free-solid-svg-icons";
import { Watchable } from "../../model/WatchStatus";
import classNames from "classnames";

Expand All @@ -31,6 +31,12 @@ export function CourseSearchResultVideo(props: SearchResultVideoProps): React.Re
const watchToggleIcon = isWatched ? faEyeSlash : faEye;
const watchToggleHint = isWatched ? "Mark as unwatched" : "Watch as watched";
const textStyle = isWatched ? "has-text-grey-lighter" : "";
const copyLinkIcon = faCopy;
const copyLinkHint = "Copy link to clipboard";

const onCopyLink = () => {
void navigator.clipboard.writeText(link);
};

return (
<li>
Expand All @@ -53,6 +59,13 @@ export function CourseSearchResultVideo(props: SearchResultVideoProps): React.Re
>
<FontAwesomeIcon icon={watchToggleIcon} />
</button>
<button
onClick={onCopyLink}
className="video-watched-button tag is-small is-outlined is-inverted is-rounded"
title={copyLinkHint}
>
<FontAwesomeIcon icon={copyLinkIcon} />
</button>
{isDownloadEnabled && (
<a
href={getStreamUrl(video)}
Expand Down