Skip to content

Commit 8bb9fd8

Browse files
authored
Label is cut off when resizing PR webview (#7854)
* Fix some types * Label is cut off when resizing PR webview Fixes #7738
1 parent e7673e6 commit 8bb9fd8

File tree

3 files changed

+57
-8
lines changed

3 files changed

+57
-8
lines changed

src/github/views.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,10 @@ export interface OverviewContext {
154154
owner: string;
155155
repo: string;
156156
number: number;
157+
[key: string]: boolean | string | number;
157158
}
158159

159160
export interface CodingAgentContext extends SessionLinkInfo {
160161
'preventDefaultContextMenuItems': true;
162+
[key: string]: boolean | string | number | undefined;
161163
}

webviews/components/header.tsx

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,20 @@ export function Header({
6969
);
7070
}
7171

72-
function Title({ title, titleHTML, number, url, inEditMode, setEditMode, setCurrentTitle, canEdit, owner, repo }) {
72+
interface TitleProps {
73+
title: string;
74+
titleHTML: string;
75+
number: number;
76+
url: string;
77+
inEditMode: boolean;
78+
setEditMode: React.Dispatch<React.SetStateAction<boolean>>;
79+
setCurrentTitle: React.Dispatch<React.SetStateAction<string>>;
80+
canEdit: boolean;
81+
owner: string;
82+
repo: string;
83+
}
84+
85+
function Title({ title, titleHTML, number, url, inEditMode, setEditMode, setCurrentTitle, canEdit, owner, repo }: TitleProps): JSX.Element {
7386
const { setTitle, copyPrLink } = useContext(PullRequestContext);
7487

7588
const titleForm = (
@@ -114,7 +127,7 @@ function Title({ title, titleHTML, number, url, inEditMode, setEditMode, setCurr
114127
</a>
115128
</h2>
116129
{canEdit ?
117-
<button title="Rename" onClick={setEditMode} className="icon-button">
130+
<button title="Rename" onClick={() => setEditMode(true)} className="icon-button">
118131
{editIcon}
119132
</button>
120133
: null}
@@ -128,7 +141,17 @@ function Title({ title, titleHTML, number, url, inEditMode, setEditMode, setCurr
128141
return editableTitle;
129142
}
130143

131-
function ButtonGroup({ isCurrentlyCheckedOut, isIssue, repositoryDefaultBranch, owner, repo, number, busy }) {
144+
interface ButtonGroupProps {
145+
isCurrentlyCheckedOut: boolean;
146+
isIssue: boolean;
147+
repositoryDefaultBranch: string;
148+
owner: string;
149+
repo: string;
150+
number: number;
151+
busy?: boolean;
152+
}
153+
154+
function ButtonGroup({ isCurrentlyCheckedOut, isIssue, repositoryDefaultBranch, owner, repo, number, busy }: ButtonGroupProps): JSX.Element {
132155
const { refresh } = useContext(PullRequestContext);
133156

134157
return (
@@ -146,7 +169,7 @@ function ButtonGroup({ isCurrentlyCheckedOut, isIssue, repositoryDefaultBranch,
146169
);
147170
}
148171

149-
function CancelCodingAgentButton({ canEdit, codingAgentEvent }: { canEdit: boolean, codingAgentEvent: TimelineEvent | undefined }) {
172+
function CancelCodingAgentButton({ canEdit, codingAgentEvent }: { canEdit: boolean; codingAgentEvent: TimelineEvent | undefined }): JSX.Element | null {
150173
const { cancelCodingAgent, updatePR, openSessionLog } = useContext(PullRequestContext);
151174
const [isBusy, setBusy] = useState(false);
152175

@@ -214,8 +237,19 @@ function CancelCodingAgentButton({ canEdit, codingAgentEvent }: { canEdit: boole
214237
/>;
215238
}
216239

217-
function Subtitle({ state, stateReason, isDraft, isIssue, author, base, head, codingAgentEvent }) {
218-
const { text, color, icon } = getStatus(state, isDraft, isIssue, stateReason);
240+
interface SubtitleProps {
241+
state: GithubItemStateEnum;
242+
stateReason?: StateReason;
243+
isDraft?: boolean;
244+
isIssue: boolean;
245+
author: PullRequest['author'];
246+
base: string;
247+
head: string;
248+
codingAgentEvent: TimelineEvent | undefined;
249+
}
250+
251+
function Subtitle({ state, stateReason, isDraft, isIssue, author, base, head, codingAgentEvent }: SubtitleProps): JSX.Element {
252+
const { text, color, icon } = getStatus(state, !!isDraft, isIssue, stateReason);
219253
const copilotStatus = copilotEventToStatus(codingAgentEvent);
220254
let copilotStatusIcon: JSX.Element | undefined;
221255
if (copilotStatus === CopilotPRStatus.Started) {
@@ -245,7 +279,16 @@ function Subtitle({ state, stateReason, isDraft, isIssue, author, base, head, co
245279
);
246280
}
247281

248-
const CheckoutButton = ({ isCurrentlyCheckedOut, isIssue, repositoryDefaultBranch, owner, repo, number }) => {
282+
interface CheckoutButtonProps {
283+
isCurrentlyCheckedOut: boolean;
284+
isIssue: boolean;
285+
repositoryDefaultBranch: string;
286+
owner: string;
287+
repo: string;
288+
number: number;
289+
}
290+
291+
const CheckoutButton: React.FC<CheckoutButtonProps> = ({ isCurrentlyCheckedOut, isIssue, repositoryDefaultBranch, owner, repo, number }) => {
249292
const { exitReviewMode, checkout, openChanges } = useContext(PullRequestContext);
250293
const [isBusy, setBusy] = useState(false);
251294

@@ -320,7 +363,7 @@ const CheckoutButton = ({ isCurrentlyCheckedOut, isIssue, repositoryDefaultBranc
320363
/>;
321364
};
322365

323-
export function getStatus(state: GithubItemStateEnum, isDraft: boolean, isIssue: boolean, stateReason: StateReason) {
366+
export function getStatus(state: GithubItemStateEnum, isDraft: boolean, isIssue: boolean, stateReason?: StateReason) {
324367
const closed = isIssue ? issueClosedIcon : prClosedIcon;
325368
const open = isIssue ? issueIcon : prOpenIcon;
326369

webviews/editorWebview/index.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,6 +1555,10 @@ svg.octicon path {
15551555
border-radius: 20px;
15561556
margin-right: 2px;
15571557
border-style: none;
1558+
text-overflow: ellipsis;
1559+
max-width: -webkit-fill-available;
1560+
overflow: hidden;
1561+
display: inline-block;
15581562
}
15591563

15601564
.pill-overflow {

0 commit comments

Comments
 (0)