fix: [CODE-2414] remove CODE_PULLREQ_LABELS (#3192)

* chore: [CODE-2414] remove CODE_PULLREQ_LABELS
This commit is contained in:
Ritik Kapoor 2024-12-31 16:40:35 +00:00 committed by Harness
parent aac9ace779
commit da756c486f
6 changed files with 98 additions and 125 deletions

View File

@ -33,21 +33,16 @@ export default function ManageRepositories() {
const space = useGetSpaceParam() const space = useGetSpaceParam()
const pageScope = useGetCurrentPageScope() const pageScope = useGetCurrentPageScope()
const history = useHistory() const history = useHistory()
const { routes, hooks, standalone } = useAppContext() const { routes } = useAppContext()
const { CODE_PULLREQ_LABELS: isLabelEnabled } = hooks?.useFeatureFlags()
const [activeTab, setActiveTab] = React.useState<string>(settingSection || SettingsTab.labels) const [activeTab, setActiveTab] = React.useState<string>(settingSection || SettingsTab.labels)
const { getString } = useStrings() const { getString } = useStrings()
const tabListArray = [ const tabListArray = [
...(isLabelEnabled || standalone {
? [ id: SettingsTab.labels,
{ title: getString('labels.labels'),
id: SettingsTab.labels, panel: <LabelsListing activeTab={activeTab} currentPageScope={pageScope} space={space} />
title: getString('labels.labels'), },
panel: <LabelsListing activeTab={activeTab} currentPageScope={pageScope} space={space} />
}
]
: []),
{ {
id: SettingsTab.branchProtection, id: SettingsTab.branchProtection,
title: getString('branchProtection.title'), title: getString('branchProtection.title'),

View File

@ -100,8 +100,7 @@ export const Conversation: React.FC<ConversationProps> = ({
refetchPullReq refetchPullReq
}) => { }) => {
const { getString } = useStrings() const { getString } = useStrings()
const { currentUser, routes, hooks } = useAppContext() const { currentUser, routes } = useAppContext()
const { CODE_PULLREQ_LABELS: isLabelEnabled } = hooks?.useFeatureFlags()
const location = useLocation() const location = useLocation()
const activities = usePullReqActivities() const activities = usePullReqActivities()
const { const {
@ -270,8 +269,7 @@ export const Conversation: React.FC<ConversationProps> = ({
() => () =>
activityBlocks?.map((commentItems, index) => { activityBlocks?.map((commentItems, index) => {
const threadId = commentItems[0].payload?.id const threadId = commentItems[0].payload?.id
const renderLabelActivities = const renderLabelActivities = commentItems[0].payload?.type !== CommentType.LABEL_MODIFY
commentItems[0].payload?.type !== CommentType.LABEL_MODIFY || isLabelEnabled || standalone
if (isSystemComment(commentItems)) { if (isSystemComment(commentItems)) {
return ( return (
<Render key={`thread-${threadId}`} when={renderLabelActivities}> <Render key={`thread-${threadId}`} when={renderLabelActivities}>

View File

@ -22,8 +22,6 @@ import cx from 'classnames'
import { Container, Layout, Text, Avatar, FlexExpander, useToaster, Utils, stringSubstitute } from '@harnessio/uicore' import { Container, Layout, Text, Avatar, FlexExpander, useToaster, Utils, stringSubstitute } from '@harnessio/uicore'
import { Icon, IconName } from '@harnessio/icons' import { Icon, IconName } from '@harnessio/icons'
import { Color, FontVariation } from '@harnessio/design-system' import { Color, FontVariation } from '@harnessio/design-system'
import { Render } from 'react-jsx-match'
import { useAppContext } from 'AppContext'
import { OptionsMenuButton } from 'components/OptionsMenuButton/OptionsMenuButton' import { OptionsMenuButton } from 'components/OptionsMenuButton/OptionsMenuButton'
import { useStrings } from 'framework/strings' import { useStrings } from 'framework/strings'
import type { TypesPullReq, RepoRepositoryOutput, EnumPullReqReviewDecision, TypesScopesLabels } from 'services/code' import type { TypesPullReq, RepoRepositoryOutput, EnumPullReqReviewDecision, TypesScopesLabels } from 'services/code'
@ -47,8 +45,6 @@ interface PullRequestSideBarProps {
} }
const PullRequestSideBar = (props: PullRequestSideBarProps) => { const PullRequestSideBar = (props: PullRequestSideBarProps) => {
const { standalone, hooks } = useAppContext()
const { CODE_PULLREQ_LABELS: isLabelEnabled } = hooks?.useFeatureFlags()
const [labelQuery, setLabelQuery] = useState<string>('') const [labelQuery, setLabelQuery] = useState<string>('')
const { reviewers, repoMetadata, pullRequestMetadata, refetchReviewers, labels, refetchLabels, refetchActivities } = const { reviewers, repoMetadata, pullRequestMetadata, refetchReviewers, labels, refetchLabels, refetchActivities } =
props props
@ -406,74 +402,73 @@ const PullRequestSideBar = (props: PullRequestSideBarProps) => {
</Text> </Text>
)} */} )} */}
</Layout.Vertical> </Layout.Vertical>
<Render when={isLabelEnabled || standalone}>
<Layout.Vertical>
<Layout.Horizontal>
<Text style={{ lineHeight: '24px' }} font={{ variation: FontVariation.H6 }}>
{getString('labels.labels')}
</Text>
<FlexExpander />
<LabelSelector <Layout.Vertical>
pullRequestMetadata={pullRequestMetadata} <Layout.Horizontal>
allLabelsData={labelsList} <Text style={{ lineHeight: '24px' }} font={{ variation: FontVariation.H6 }}>
refetchLabels={refetchLabels} {getString('labels.labels')}
refetchlabelsList={refetchlabelsList} </Text>
repoMetadata={repoMetadata} <FlexExpander />
query={labelQuery}
setQuery={setLabelQuery} <LabelSelector
labelListLoading={labelListLoading} pullRequestMetadata={pullRequestMetadata}
refetchActivities={refetchActivities} allLabelsData={labelsList}
/> refetchLabels={refetchLabels}
refetchlabelsList={refetchlabelsList}
repoMetadata={repoMetadata}
query={labelQuery}
setQuery={setLabelQuery}
labelListLoading={labelListLoading}
refetchActivities={refetchActivities}
/>
</Layout.Horizontal>
<Container padding={{ top: 'medium', bottom: 'large' }}>
<Layout.Horizontal className={css.labelsLayout}>
{labels && labels.label_data?.length !== 0 ? (
labels?.label_data?.map((label, index) => (
<Label
key={index}
name={label.key as string}
label_color={label.color as ColorName}
label_value={{
name: label.assigned_value?.value as string,
color: label.assigned_value?.color as ColorName
}}
scope={label.scope}
removeLabelBtn={true}
disableRemoveBtnTooltip={true}
handleRemoveClick={() => {
removeLabel({}, { pathParams: { label_id: label.id } })
.then(() => {
label.assigned_value?.value
? showSuccess(
stringSubstitute(getString('labels.removedLabel'), {
label: `${label.key}:${label.assigned_value?.value}`
}) as string
)
: showSuccess(
stringSubstitute(getString('labels.removedLabel'), {
label: label.key
}) as string
)
refetchActivities()
})
.catch(err => {
showError(getErrorMessage(err))
})
refetchLabels()
}}
/>
))
) : (
<Text color={Color.GREY_300} font={{ variation: FontVariation.BODY2_SEMI, size: 'small' }}>
{getString('labels.noLabels')}
</Text>
)}
{removingLabel && <Spinner size={16} />}
</Layout.Horizontal> </Layout.Horizontal>
<Container padding={{ top: 'medium', bottom: 'large' }}> </Container>
<Layout.Horizontal className={css.labelsLayout}> </Layout.Vertical>
{labels && labels.label_data?.length !== 0 ? (
labels?.label_data?.map((label, index) => (
<Label
key={index}
name={label.key as string}
label_color={label.color as ColorName}
label_value={{
name: label.assigned_value?.value as string,
color: label.assigned_value?.color as ColorName
}}
scope={label.scope}
removeLabelBtn={true}
disableRemoveBtnTooltip={true}
handleRemoveClick={() => {
removeLabel({}, { pathParams: { label_id: label.id } })
.then(() => {
label.assigned_value?.value
? showSuccess(
stringSubstitute(getString('labels.removedLabel'), {
label: `${label.key}:${label.assigned_value?.value}`
}) as string
)
: showSuccess(
stringSubstitute(getString('labels.removedLabel'), {
label: label.key
}) as string
)
refetchActivities()
})
.catch(err => {
showError(getErrorMessage(err))
})
refetchLabels()
}}
/>
))
) : (
<Text color={Color.GREY_300} font={{ variation: FontVariation.BODY2_SEMI, size: 'small' }}>
{getString('labels.noLabels')}
</Text>
)}
{removingLabel && <Spinner size={16} />}
</Layout.Horizontal>
</Container>
</Layout.Vertical>
</Render>
</Container> </Container>
</Container> </Container>
) )

View File

@ -77,7 +77,6 @@ export default function PullRequests() {
const { getString } = useStrings() const { getString } = useStrings()
const history = useHistory() const history = useHistory()
const { routes, hooks, standalone, routingId } = useAppContext() const { routes, hooks, standalone, routingId } = useAppContext()
const { CODE_PULLREQ_LABELS: isLabelEnabled } = hooks?.useFeatureFlags()
const [searchTerm, setSearchTerm] = useState<string | undefined>() const [searchTerm, setSearchTerm] = useState<string | undefined>()
const browserParams = useQueryParams<PageBrowserProps>() const browserParams = useQueryParams<PageBrowserProps>()
const [filter, setFilter] = useState(browserParams?.state || (PullRequestFilterOption.OPEN as string)) const [filter, setFilter] = useState(browserParams?.state || (PullRequestFilterOption.OPEN as string))
@ -295,13 +294,7 @@ export default function PullRequests() {
</Text> </Text>
</Container> </Container>
</Layout.Horizontal> </Layout.Horizontal>
<Render <Render when={row.original && row.original.labels && row.original.labels.length !== 0}>
when={
(isLabelEnabled || standalone) &&
row.original &&
row.original.labels &&
row.original.labels.length !== 0
}>
{row.original?.labels?.map((label, index) => ( {row.original?.labels?.map((label, index) => (
<Label <Label
key={index} key={index}
@ -441,8 +434,7 @@ export default function PullRequests() {
</Text> </Text>
</Render> </Render>
{(isLabelEnabled || standalone) && {labelFilter &&
labelFilter &&
labelFilter?.length !== 0 && labelFilter?.length !== 0 &&
labelFilter?.map((label, index) => ( labelFilter?.map((label, index) => (
<Label <Label

View File

@ -28,7 +28,6 @@ import {
} from '@harnessio/uicore' } from '@harnessio/uicore'
import { Color, FontVariation } from '@harnessio/design-system' import { Color, FontVariation } from '@harnessio/design-system'
import { sortBy } from 'lodash-es' import { sortBy } from 'lodash-es'
import { Render } from 'react-jsx-match'
import { getConfig, getUsingFetch } from 'services/config' import { getConfig, getUsingFetch } from 'services/config'
import { useStrings } from 'framework/strings' import { useStrings } from 'framework/strings'
import { CodeIcon, GitInfoProps, makeDiffRefs, PullRequestFilterOption } from 'utils/GitUtils' import { CodeIcon, GitInfoProps, makeDiffRefs, PullRequestFilterOption } from 'utils/GitUtils'
@ -76,7 +75,6 @@ export function PullRequestsContentHeader({
const [loadingAuthors, setLoadingAuthors] = useState<boolean>(false) const [loadingAuthors, setLoadingAuthors] = useState<boolean>(false)
const space = useGetSpaceParam() const space = useGetSpaceParam()
const { hooks, currentUser, standalone, routingId, routes } = useAppContext() const { hooks, currentUser, standalone, routingId, routes } = useAppContext()
const { CODE_PULLREQ_LABELS: isLabelEnabled } = hooks?.useFeatureFlags()
const permPushResult = hooks?.usePermissionTranslate?.( const permPushResult = hooks?.usePermissionTranslate?.(
{ {
resource: { resource: {
@ -194,16 +192,16 @@ export function PullRequestsContentHeader({
}} }}
/> />
<FlexExpander /> <FlexExpander />
<Render when={isLabelEnabled || standalone}>
<LabelFilter <LabelFilter
labelFilterOption={labelFilterOption} labelFilterOption={labelFilterOption}
setLabelFilterOption={setLabelFilterOption} setLabelFilterOption={setLabelFilterOption}
onPullRequestLabelFilterChanged={onPullRequestLabelFilterChanged} onPullRequestLabelFilterChanged={onPullRequestLabelFilterChanged}
bearerToken={bearerToken} bearerToken={bearerToken}
repoMetadata={repoMetadata} repoMetadata={repoMetadata}
spaceRef={space} spaceRef={space}
/> />
</Render>
<DropDown <DropDown
value={authorFilterOption} value={authorFilterOption}
items={() => getAuthorsPromise()} items={() => getAuthorsPromise()}

View File

@ -40,8 +40,7 @@ export default function RepositorySettings() {
const { repoMetadata, error, loading, refetch, settingSection, gitRef, resourcePath } = useGetRepositoryMetadata() const { repoMetadata, error, loading, refetch, settingSection, gitRef, resourcePath } = useGetRepositoryMetadata()
const space = useGetSpaceParam() const space = useGetSpaceParam()
const history = useHistory() const history = useHistory()
const { routes, hooks, standalone } = useAppContext() const { routes } = useAppContext()
const { CODE_PULLREQ_LABELS: isLabelEnabled } = hooks?.useFeatureFlags()
const [activeTab, setActiveTab] = React.useState<string>(settingSection || SettingsTab.general) const [activeTab, setActiveTab] = React.useState<string>(settingSection || SettingsTab.general)
const { getString } = useStrings() const { getString } = useStrings()
const { isRepositoryEmpty } = useGetResourceContent({ const { isRepositoryEmpty } = useGetResourceContent({
@ -66,22 +65,18 @@ export default function RepositorySettings() {
</Container> </Container>
) )
}, },
...(isLabelEnabled || standalone {
? [ id: SettingsTab.labels,
{ title: getString('labels.labels'),
id: SettingsTab.labels, panel: (
title: getString('labels.labels'), <LabelsListing
panel: ( activeTab={activeTab}
<LabelsListing repoMetadata={repoMetadata}
activeTab={activeTab} currentPageScope={LabelsPageScope.REPOSITORY}
repoMetadata={repoMetadata} space={space}
currentPageScope={LabelsPageScope.REPOSITORY} />
space={space} )
/> },
)
}
]
: []),
{ {
id: SettingsTab.branchProtection, id: SettingsTab.branchProtection,
title: getString('branchProtection.title'), title: getString('branchProtection.title'),