Skip to content

Commit ff4e486

Browse files
babyleafymeta-codesync[bot]
authored andcommitted
Add copy from parent to editing field buttons
Summary: The "copy from parent" action already exists in the commit info header, but it's not easily discoverable when editing individual fields. This adds an additional entrypoint for "copy from parent" directly in the editing field toolbar, making it more accessible during the commit message editing workflow. Reviewed By: nsblake Differential Revision: D93452994 fbshipit-source-id: c292fb1df980ca8e2899e201eda5d2279638628c
1 parent 2d9855f commit ff4e486

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

addons/isl/src/CommitInfoView/CommitInfoField.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ export function CommitInfoField({
129129
autoFocus={autofocus ?? false}
130130
editedMessage={editedFieldContent}
131131
setEditedField={setEditedField}
132+
copyFromParent={copyFromParent}
132133
/>
133134
)}
134135
{extra}

addons/isl/src/CommitInfoView/TextArea.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
import type {ReactNode, RefObject} from 'react';
99

10+
import {Button} from 'isl-components/Button';
11+
import {Icon} from 'isl-components/Icon';
1012
import {TextArea} from 'isl-components/TextArea';
13+
import {Tooltip} from 'isl-components/Tooltip';
1114
import {useEffect, useRef} from 'react';
1215
import {InternalFieldName} from 'shared/constants';
1316
import {
@@ -30,12 +33,14 @@ export function CommitInfoTextArea({
3033
autoFocus,
3134
editedMessage,
3235
setEditedField,
36+
copyFromParent,
3337
}: {
3438
kind: 'title' | 'textarea' | 'field';
3539
name: string;
3640
autoFocus: boolean;
3741
editedMessage: string;
3842
setEditedField: (fieldValue: string) => unknown;
43+
copyFromParent?: () => void;
3944
}) {
4045
const ref = useRef<HTMLTextAreaElement>(null);
4146
useEffect(() => {
@@ -93,6 +98,7 @@ export function CommitInfoTextArea({
9398
fieldName={name}
9499
uploadFiles={supportsImageUpload ? uploadFiles : undefined}
95100
textAreaRef={ref}
101+
copyFromParent={copyFromParent}
96102
/>
97103
</div>
98104
);
@@ -110,10 +116,12 @@ export function EditorToolbar({
110116
fieldName,
111117
textAreaRef,
112118
uploadFiles,
119+
copyFromParent,
113120
}: {
114121
fieldName: string;
115122
uploadFiles?: (files: Array<File>) => unknown;
116123
textAreaRef: RefObject<HTMLTextAreaElement>;
124+
copyFromParent?: () => void;
117125
}) {
118126
const parts: Array<ReactNode> = [];
119127
if (uploadFiles != null) {
@@ -127,6 +135,15 @@ export function EditorToolbar({
127135
if (fieldName === InternalFieldName.Summary && Internal.GenerateSummaryButton) {
128136
parts.push(<Internal.GenerateSummaryButton key="generate-summary" />);
129137
}
138+
if (copyFromParent != null) {
139+
parts.push(
140+
<Tooltip title="Copy from previous commit" key="copy-parent">
141+
<Button icon onClick={copyFromParent}>
142+
<Icon icon="clippy" />
143+
</Button>
144+
</Tooltip>,
145+
);
146+
}
130147
if (uploadFiles != null) {
131148
parts.push(<FilePicker key="picker" uploadFiles={uploadFiles} />);
132149
}

0 commit comments

Comments
 (0)