fix: [code-241]: fix filtering and rbac on pr page

This commit is contained in:
calvin 2023-04-19 17:33:45 -06:00
parent 961cf14fd2
commit 7134529e12
6 changed files with 29 additions and 11 deletions

View File

@ -150,7 +150,7 @@ export const Changes: React.FC<ChangesProps> = ({
return ( return (
<Container className={cx(css.container, className)} {...(!!loading || !!error ? { flex: true } : {})}> <Container className={cx(css.container, className)} {...(!!loading || !!error ? { flex: true } : {})}>
<LoadingSpinner visible={loading || loadingActivities} /> <LoadingSpinner visible={loading || loadingActivities} withBorder={true} />
<Render when={error}> <Render when={error}>
<PageError message={getErrorMessage(error || errorActivities)} onClick={voidFn(refetch)} /> <PageError message={getErrorMessage(error || errorActivities)} onClick={voidFn(refetch)} />
</Render> </Render>

View File

@ -9,7 +9,7 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
z-index: 3; z-index: 4;
&.withBorder { &.withBorder {
background: var(--white) !important; background: var(--white) !important;

View File

@ -251,6 +251,7 @@ export const Conversation: React.FC<ConversationProps> = ({
className={css.selectButton} className={css.selectButton}
onChange={newState => { onChange={newState => {
setPrShowState(newState) setPrShowState(newState)
refetchActivities()
}} }}
/> />
</Container> </Container>

View File

@ -86,7 +86,7 @@
--background-color-active: var(--grey-100) !important; --background-color-active: var(--grey-100) !important;
} }
button { a, button {
--background-color: var(--green-800) !important; --background-color: var(--green-800) !important;
--background-color-hover: var(--green-900) !important; --background-color-hover: var(--green-900) !important;
--background-color-active: var(--green-900) !important; --background-color-active: var(--green-900) !important;

View File

@ -26,7 +26,9 @@ import type {
} from 'services/code' } from 'services/code'
import { useStrings } from 'framework/strings' import { useStrings } from 'framework/strings'
import { CodeIcon, GitInfoProps, PullRequestFilterOption, PullRequestState } from 'utils/GitUtils' import { CodeIcon, GitInfoProps, PullRequestFilterOption, PullRequestState } from 'utils/GitUtils'
import { getErrorMessage } from 'utils/Utils' import { useGetSpaceParam } from 'hooks/useGetSpaceParam'
import { useAppContext } from 'AppContext'
import { getErrorMessage, permissionProps } from 'utils/Utils'
import ReviewSplitButton from 'components/Changes/ReviewSplitButton/ReviewSplitButton' import ReviewSplitButton from 'components/Changes/ReviewSplitButton/ReviewSplitButton'
import css from './PullRequestActionsBox.module.scss' import css from './PullRequestActionsBox.module.scss'
@ -86,6 +88,18 @@ export const PullRequestActionsBox: React.FC<PullRequestActionsBoxProps> = ({
if (pullRequestMetadata.state === PullRequestFilterOption.MERGED) { if (pullRequestMetadata.state === PullRequestFilterOption.MERGED) {
return <MergeInfo pullRequestMetadata={pullRequestMetadata} /> return <MergeInfo pullRequestMetadata={pullRequestMetadata} />
} }
const { hooks, standalone } = useAppContext()
const space = useGetSpaceParam()
const permPushResult = hooks?.usePermissionTranslate?.(
{
resource: {
resourceType: 'CODE_REPO'
},
permissions: ['code_repo_push']
},
[space]
)
return ( return (
<Container <Container
@ -174,6 +188,7 @@ export const PullRequestActionsBox: React.FC<PullRequestActionsBoxProps> = ({
position: PopoverPosition.BOTTOM_RIGHT, position: PopoverPosition.BOTTOM_RIGHT,
transitionDuration: 1000 transitionDuration: 1000
}} }}
{...permissionProps(permPushResult, standalone)}
onClick={() => { onClick={() => {
if (mergeOption.method !== 'close') { if (mergeOption.method !== 'close') {
const payload: OpenapiMergePullReq = { method: mergeOption.method } const payload: OpenapiMergePullReq = { method: mergeOption.method }

View File

@ -16,10 +16,12 @@ export const PullRequestTabContentWrapper: React.FC<PullRequestTabContentWrapper
error, error,
onRetry, onRetry,
children children
}) => ( }) => {
<Container className={className} padding="xlarge" {...(!!loading || !!error ? { flex: true } : {})}> return (
<LoadingSpinner visible={loading} /> <Container className={className} padding="xlarge">
{error && <PageError message={getErrorMessage(error)} onClick={onRetry} />} <LoadingSpinner visible={loading} withBorder={true} />
{!loading && !error && children} {error && <PageError message={getErrorMessage(error)} onClick={onRetry} />}
</Container> {!error && children}
) </Container>
)
}