Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Improve the UI/UX for GitHub integrations #3907

Merged
merged 22 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
bb14eba
fix: Improve the UI/UX for GitHub integrations
novakzaballa May 8, 2024
bfca370
Move GithubReposTable and deleteGithubRepos components to MyGitHubRep…
novakzaballa May 8, 2024
e6fb3d0
Add logic in MyGithubRepositoriesComponent, solve link PR issue
novakzaballa May 8, 2024
24bd50d
Update UI in the feature external resources components
novakzaballa May 8, 2024
fa38d29
Move components to ExternalResourcesTable
novakzaballa May 9, 2024
1b17e10
Solve issues in the GitHubSetupPage
novakzaballa May 9, 2024
4d97821
Rename PermanentRow to AddExternalResourceRow, Add constants
novakzaballa May 9, 2024
7c6be5e
Solve closeModal logic
novakzaballa May 9, 2024
859afbe
Solve Row render issue, Solve GithubSetupPage select project issue
novakzaballa May 10, 2024
d8de450
Solve Row render issue
novakzaballa May 10, 2024
b34ac52
Change confirm with a modal
novakzaballa May 10, 2024
079ec0e
Delete comment
novakzaballa May 10, 2024
d314723
Merge branch 'main' into fix/improve-the-ui-ux-for-github-integrations
novakzaballa May 10, 2024
08e1a35
Fix margin styles, Increase the emergent window size, solve select ov…
novakzaballa May 10, 2024
5da708f
fetch Github integration onFocus
novakzaballa May 10, 2024
8bbe4ab
Improve Issue/PR selects
novakzaballa May 10, 2024
2ee6f73
Solve select issue
novakzaballa May 14, 2024
4cbace3
fix: SelectRepositories return the incorrect values when has more tha…
novakzaballa May 15, 2024
2d71d67
Merge branch 'main' into fix/improve-the-ui-ux-for-github-integrations
novakzaballa May 16, 2024
3085c69
fix: Change the theme for the plus button
novakzaballa May 17, 2024
23d0c54
Create a new tab for the external resources in the createFlag modal
novakzaballa May 17, 2024
3969932
Move add External resources on the top to tab
novakzaballa May 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions frontend/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,10 @@ export default {
'TRAITS_ID': 150,
},
},
githubType: {
githubIssue: 'GitHub Issue',
githubPR: 'Github PR',
},
modals: {
'PAYMENT': 'Payment Modal',
},
Expand Down Expand Up @@ -472,6 +476,10 @@ export default {
],
projectPermissions: (perm: string) =>
`To use this feature you need the <i>${perm}</i> permission for this project.<br/>Please contact a member of this project who has administrator privileges.`,
resourceTypes: {
GITHUB_ISSUE: { id: 1, label: 'GitHub Issue', type: 'GITHUB' },
GITHUB_PR: { id: 2, label: 'GitHub PR', type: 'GITHUB' },
},
roles: {
'ADMIN': 'Organisation Administrator',
'USER': 'User',
Expand Down
6 changes: 3 additions & 3 deletions frontend/common/types/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ export type ExternalResource = {
id?: number
url: string
type: string
project: number
status: null | string
project?: number
metadata: null | { status: string }
feature: number
}

Expand Down Expand Up @@ -769,7 +769,7 @@ export type Res = {
supportedContentType: ContentType[]
externalResource: PagedResponse<ExternalResource>
githubIntegrations: PagedResponse<githubIntegration>
githubRepository: PagedResponse<GithubRepository> | { data: { id: string } }
githubRepository: PagedResponse<GithubRepository>
githubIssues: Issue[]
githubPulls: PullRequest[]
githubRepos: GithubPaginatedRepos<Repository>
Expand Down
54 changes: 0 additions & 54 deletions frontend/web/components/DeleteGithubIntegracion.tsx

This file was deleted.

64 changes: 64 additions & 0 deletions frontend/web/components/DeleteGithubIntegration.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import React, { FC } from 'react'
import Button from './base/forms/Button'
import { useDeleteGithubIntegrationMutation } from 'common/services/useGithubIntegration'

type DeleteGithubIntegrationType = {
organisationId: string
githubId: string
}

const DeleteGithubIntegration: FC<DeleteGithubIntegrationType> = ({
githubId,
organisationId,
}) => {
const [deleteGithubIntegration] = useDeleteGithubIntegrationMutation()

return (
<Button
id='delete-integration'
theme='danger'
data-test='delete-integration'
onClick={() =>
openModal2(
'Delete Github Integration',
<div>
<div>Are you sure you want to remove your GitHub integration?</div>
<div>
If you proceed, you will need to uninstall the application from
your GitHub organization in order to integrate it again.
</div>
<div className='text-right'>
<Button
className='mr-2'
onClick={() => {
closeModal2()
}}
>
Cancel
</Button>
<Button
theme='danger'
onClick={() => {
deleteGithubIntegration({
github_integration_id: githubId,
organisation_id: organisationId,
}).then(() => {
closeModal2()
closeModal()
})
}}
>
Delete
</Button>
</div>
</div>,
)
}
size='small'
>
Delete Integration
</Button>
)
}

export default DeleteGithubIntegration
162 changes: 162 additions & 0 deletions frontend/web/components/ExternalResourcesLinkTab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import React, { FC, useState } from 'react'
import MyRepositoriesSelect from './MyRepositoriesSelect'
import ExternalResourcesTable, {
ExternalResourcesTableType,
} from './ExternalResourcesTable'
import { ExternalResource } from 'common/types/responses'
import MyIssuesSelect from './MyIssuesSelect'
import MyPullRequestsSelect from './MyPullRequestsSelect'
import { useCreateExternalResourceMutation } from 'common/services/useExternalResource'
import Constants from 'common/constants'
import Button from './base/forms/Button'

type ExternalResourcesLinkTabType = {
githubId: string
organisationId: string
featureId: string
projectId: string
}

type AddExternalResourceRowType = ExternalResourcesTableType & {
linkedExternalResources?: ExternalResource[]
}

type GitHubStatusType = {
value: number
label: string
}

const AddExternalResourceRow: FC<AddExternalResourceRowType> = ({
featureId,
linkedExternalResources,
organisationId,
projectId,
repoName,
repoOwner,
}) => {
const [externalResourceType, setExternalResourceType] = useState<string>('')
const [featureExternalResource, setFeatureExternalResource] =
useState<string>('')

const [createExternalResource] = useCreateExternalResourceMutation()
const githubTypes = Object.values(Constants.resourceTypes).filter(
(v) => v.type === 'GITHUB',
)
return (
<Row>
<Flex style={{ maxWidth: '170px' }}>
<Select
size='select-md'
placeholder={'Select Type'}
onChange={(v: GitHubStatusType) => setExternalResourceType(v.label)}
options={githubTypes.map((e) => {
return { label: e.label, value: e.id }
})}
/>
</Flex>
<Flex className='table-column px-3'>
<Flex className='ml-4'>
{externalResourceType ==
Constants.resourceTypes.GITHUB_ISSUE.label ? (
<MyIssuesSelect
orgId={organisationId}
onChange={(v) => setFeatureExternalResource(v)}
repoOwner={repoOwner}
repoName={repoName}
linkedExternalResources={linkedExternalResources!}
/>
) : externalResourceType ==
Constants.resourceTypes.GITHUB_PR.label ? (
<MyPullRequestsSelect
orgId={organisationId}
onChange={(v) => setFeatureExternalResource(v)}
repoOwner={repoOwner}
repoName={repoName}
linkedExternalResources={linkedExternalResources!}
/>
) : (
<></>
)}
</Flex>
</Flex>
<div className='table-column text-center' style={{ width: '80px' }}>
<Button
className='text-right'
theme='primary'
disabled={!externalResourceType || !featureExternalResource}
onClick={() => {
createExternalResource({
body: {
feature: parseInt(featureId),
metadata: { status: 'open' },
type: externalResourceType.toUpperCase().replace(/\s+/g, '_'),
url: featureExternalResource,
},
feature_id: featureId,
project_id: projectId,
}).then(() => {
toast('External Resource Added')
})
}}
>
Save
</Button>
</div>
</Row>
)
}

const ExternalResourcesLinkTab: FC<ExternalResourcesLinkTabType> = ({
featureId,
githubId,
organisationId,
projectId,
}) => {
const [repoName, setRepoName] = useState<string>('')
const [repoOwner, setRepoOwner] = useState<string>('')
const [selectedResources, setSelectedResources] =
useState<ExternalResource[]>()

return (
<>
<h5>GitHub Issues and Pull Requests linked</h5>
<label className='cols-sm-2 control-label'>
{' '}
Link new Issue / Pull Request{' '}
</label>
<FormGroup>
<MyRepositoriesSelect
githubId={githubId}
orgId={organisationId}
onChange={(v) => {
const repoData = v.split('/')
setRepoName(repoData[0])
setRepoOwner(repoData[1])
}}
/>
{repoName && repoOwner && (
<AddExternalResourceRow
featureId={featureId}
projectId={projectId}
organisationId={organisationId}
repoName={repoName}
repoOwner={repoOwner}
linkedExternalResources={selectedResources}
/>
)}
</FormGroup>
<ExternalResourcesTable
featureId={featureId}
projectId={projectId}
organisationId={organisationId}
repoOwner={repoOwner}
repoName={repoName}
setSelectedResources={(r: ExternalResource[]) =>
setSelectedResources(r)
}
/>
</>
)
}

export default ExternalResourcesLinkTab
Loading