fix: [code-411]: addressed comments

This commit is contained in:
calvin 2023-06-01 11:15:27 -06:00
parent 8ef7a3f98a
commit c3b945623b
2 changed files with 12 additions and 8 deletions

View File

@ -92,7 +92,7 @@ export function FileContent({
},
[space]
)
function checkPermTagTooltip(): { disabled: boolean; tooltip: JSX.Element | string | undefined } {
const permsFinal = useMemo(() => {
const perms = permissionProps(permPushResult, standalone)
if (isRefATag(gitRef) && perms) {
return { tooltip: perms.tooltip, disabled: true }
@ -103,8 +103,8 @@ export function FileContent({
} else if (perms?.disabled) {
return { disabled: perms.disabled, tooltip: perms.tooltip }
}
return { disabled: isRefATag(gitRef), tooltip: undefined }
}
return { disabled: isRefATag(gitRef) || false, tooltip: undefined }
}, [permPushResult, gitRef])
return (
<Container className={css.tabsContainer}>
@ -139,7 +139,8 @@ export function FileContent({
text={getString('edit')}
icon="code-edit"
tooltipProps={{ isDark: true }}
{...checkPermTagTooltip()}
tooltip={permsFinal.tooltip}
disabled={permsFinal.disabled}
onClick={() => {
history.push(
routes.toCODEFileEdit({

View File

@ -1,4 +1,4 @@
import React from 'react'
import React, { useMemo } from 'react'
import { Container, Color, Layout, FlexExpander, ButtonVariation, Heading, Icon, ButtonSize } from '@harness/uicore'
import { Render } from 'react-jsx-match'
import { useHistory } from 'react-router-dom'
@ -51,7 +51,8 @@ function ReadmeViewer({ metadata, gitRef, readmeInfo, contentOnly, maxWidth }: F
},
[space]
)
function checkPermTagTooltip(): { disabled: boolean; tooltip: JSX.Element | string | undefined } {
const permsFinal = useMemo(() => {
const perms = permissionProps(permPushResult, standalone)
if (gitRef && isRefATag(gitRef) && perms) {
return { tooltip: perms.tooltip, disabled: true }
@ -63,7 +64,8 @@ function ReadmeViewer({ metadata, gitRef, readmeInfo, contentOnly, maxWidth }: F
return { disabled: perms.disabled, tooltip: perms.tooltip }
}
return { disabled: (gitRef && isRefATag(gitRef)) || false, tooltip: undefined }
}
}, [permPushResult, gitRef])
return (
<Container
className={cx(css.readmeContainer, { [css.contentOnly]: contentOnly })}
@ -81,7 +83,8 @@ function ReadmeViewer({ metadata, gitRef, readmeInfo, contentOnly, maxWidth }: F
iconProps={{ size: 16 }}
text={getString('edit')}
icon="code-edit"
{...checkPermTagTooltip()}
tooltip={permsFinal.tooltip}
disabled={permsFinal.disabled}
onClick={() => {
history.push(
routes.toCODEFileEdit({