Fix line wrapping in PR when file name is long (#1012)

This commit is contained in:
Tan Nhu 2024-02-01 23:29:07 +00:00 committed by Harness
parent c270b8f7b9
commit 92be6ec51b
8 changed files with 57 additions and 13 deletions

View File

@ -234,6 +234,10 @@
box-shadow: 0px 2px 4px 0px rgba(96, 97, 112, 0.16), 0px 0px 1px 0px rgba(40, 41, 61, 0.04); box-shadow: 0px 2px 4px 0px rgba(96, 97, 112, 0.16), 0px 0px 1px 0px rgba(40, 41, 61, 0.04);
z-index: 4; z-index: 4;
.fnamePopover {
display: flex;
}
.chevron { .chevron {
align-self: center; align-self: center;
height: 24px; height: 24px;
@ -244,6 +248,7 @@
align-self: center; align-self: center;
align-items: center; align-items: center;
text-align: left; text-align: left;
max-width: calc(100vw - 600px);
a { a {
font-size: 13px; font-size: 13px;
@ -363,4 +368,14 @@
} }
} }
.popover {
:global {
.bp3-popover-content {
padding: var(--spacing-medium);
max-width: 700px;
word-break: break-all;
}
}
}
// TODO: Restyle DiffView to match latest design (https://www.figma.com/file/PgBvi804VdQNyLS8fD9K0p/Code?node-id=9391%3A118114&mode=dev) // TODO: Restyle DiffView to match latest design (https://www.figma.com/file/PgBvi804VdQNyLS8fD9K0p/Code?node-id=9391%3A118114&mode=dev)

View File

@ -24,8 +24,10 @@ export declare const diffContent: string
export declare const diffHeader: string export declare const diffHeader: string
export declare const fileChanged: string export declare const fileChanged: string
export declare const fname: string export declare const fname: string
export declare const fnamePopover: string
export declare const main: string export declare const main: string
export declare const navV2: string export declare const navV2: string
export declare const popover: string
export declare const readOnly: string export declare const readOnly: string
export declare const sidebarCollapsed: string export declare const sidebarCollapsed: string
export declare const standalone: string export declare const standalone: string

View File

@ -467,7 +467,14 @@ const DiffViewerInternal: React.FC<DiffViewerProps> = ({
}} }}
className={css.chevron} className={css.chevron}
/> />
<Text inline className={css.fname}> <Text
inline
className={css.fname}
lineClamp={1}
tooltipProps={{
portalClassName: css.popover,
className: css.fnamePopover
}}>
<Link <Link
to={routes.toCODERepository({ to={routes.toCODERepository({
repoPath: repoMetadata.path as string, repoPath: repoMetadata.path as string,

View File

@ -16,7 +16,7 @@
import React, { useEffect } from 'react' import React, { useEffect } from 'react'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { Container, Layout } from '@harnessio/uicore' import { Container, Layout, Text } from '@harnessio/uicore'
import { Diff2HtmlUI } from 'diff2html/lib-esm/ui/js/diff2html-ui' import { Diff2HtmlUI } from 'diff2html/lib-esm/ui/js/diff2html-ui'
import * as Diff2Html from 'diff2html' import * as Diff2Html from 'diff2html'
import { get } from 'lodash-es' import { get } from 'lodash-es'
@ -70,8 +70,15 @@ export const CodeCommentHeader: React.FC<CodeCommentHeaderProps> = ({
<Container className={css.snapshot}> <Container className={css.snapshot}>
<Layout.Vertical> <Layout.Vertical>
<Container className={css.title}> <Container className={css.title}>
<Link <Text
inline
className={css.fname} className={css.fname}
lineClamp={1}
tooltipProps={{
portalClassName: css.popover
}}>
<Link
// className={css.fname}
to={`${routes.toCODEPullRequest({ to={`${routes.toCODEPullRequest({
repoPath: repoMetadata?.path as string, repoPath: repoMetadata?.path as string,
pullRequestId: String(pullReqMetadata?.number), pullRequestId: String(pullReqMetadata?.number),
@ -79,6 +86,7 @@ export const CodeCommentHeader: React.FC<CodeCommentHeaderProps> = ({
})}?path=${commentItems[0].payload?.code_comment?.path}&commentId=${commentItems[0].payload?.id}`}> })}?path=${commentItems[0].payload?.code_comment?.path}&commentId=${commentItems[0].payload?.id}`}>
{commentItems[0].payload?.code_comment?.path} {commentItems[0].payload?.code_comment?.path}
</Link> </Link>
</Text>
</Container> </Container>
<Container className={css.snapshotContent} id={id} /> <Container className={css.snapshotContent} id={id} />
</Layout.Vertical> </Layout.Vertical>

View File

@ -144,7 +144,7 @@
border-top-left-radius: var(--radius); border-top-left-radius: var(--radius);
border-top-right-radius: var(--radius); border-top-right-radius: var(--radius);
.fname { .fname a {
font-size: 13px !important; font-size: 13px !important;
font-weight: 600 !important; font-weight: 600 !important;
color: var(--grey-900) !important; color: var(--grey-900) !important;
@ -241,3 +241,13 @@
.commitContainer { .commitContainer {
padding-top: 1px; padding-top: 1px;
} }
.popover {
:global {
.bp3-popover-content {
padding: var(--spacing-medium);
max-width: 700px;
word-break: break-all;
}
}
}

View File

@ -35,6 +35,7 @@ export declare const menuWrapper: string
export declare const mergeContainer: string export declare const mergeContainer: string
export declare const mergedBox: string export declare const mergedBox: string
export declare const optionMenuIcon: string export declare const optionMenuIcon: string
export declare const popover: string
export declare const refreshIcon: string export declare const refreshIcon: string
export declare const repeatBtn: string export declare const repeatBtn: string
export declare const selectButton: string export declare const selectButton: string

View File

@ -96,7 +96,7 @@ export function ContentHeader({
}} }}
onCreateBranch={openCreateNewBranchModal} onCreateBranch={openCreateNewBranchModal}
/> />
<Container style={{ maxWidth: 'calc(100vw - 750px)' }}> <Container style={{ maxWidth: 'calc(100vw - 800px)' }}>
<Layout.Horizontal spacing="small"> <Layout.Horizontal spacing="small">
<Link <Link
id="repository-ref-root" id="repository-ref-root"
@ -136,6 +136,7 @@ export function ContentHeader({
/> />
<Button <Button
text={getString('newFile')} text={getString('newFile')}
style={{ whiteSpace: 'nowrap' }}
icon={CodeIcon.Add} icon={CodeIcon.Add}
variation={ButtonVariation.PRIMARY} variation={ButtonVariation.PRIMARY}
disabled={isRefATag(gitRef) || isGitRev(gitRef)} disabled={isRefATag(gitRef) || isGitRev(gitRef)}

View File

@ -167,7 +167,7 @@ export const GitBlame: React.FC<
// TODO: Normalize loading and error rendering when implementing new Design layout // TODO: Normalize loading and error rendering when implementing new Design layout
// that have Blame in a separate tab. // that have Blame in a separate tab.
if (loading) { if (loading) {
return <Container padding="xlarge">{getString('loading')}</Container> return <Container padding={{ left: 'small' }}>{getString('loading')}</Container>
} }
if (error) { if (error) {