mirror of
https://github.com/harness/drone.git
synced 2025-05-14 16:09:59 +08:00
Added: [code-1489] support to cancel/abort import (#1057)
This commit is contained in:
parent
8150be7a3b
commit
98fdb3da03
@ -124,6 +124,9 @@ export interface StringsMap {
|
|||||||
browseFiles: string
|
browseFiles: string
|
||||||
bySigningIn: string
|
bySigningIn: string
|
||||||
cancel: string
|
cancel: string
|
||||||
|
cancelImport: string
|
||||||
|
cancelImportConfirm: string
|
||||||
|
cancelledImport: string
|
||||||
changePassword: string
|
changePassword: string
|
||||||
changePasswordSuccesfully: string
|
changePasswordSuccesfully: string
|
||||||
changeRepoVis: string
|
changeRepoVis: string
|
||||||
@ -312,6 +315,7 @@ export interface StringsMap {
|
|||||||
'exportSpace.upgradeProgress': string
|
'exportSpace.upgradeProgress': string
|
||||||
'exportSpace.upgradeTitle': string
|
'exportSpace.upgradeTitle': string
|
||||||
failed: string
|
failed: string
|
||||||
|
failedToCancelImport: string
|
||||||
failedToCreateBranch: string
|
failedToCreateBranch: string
|
||||||
failedToCreatePipeline: string
|
failedToCreatePipeline: string
|
||||||
failedToCreateRepo: string
|
failedToCreateRepo: string
|
||||||
|
@ -11,6 +11,9 @@ existingAccount: Existing Account
|
|||||||
public: Public
|
public: Public
|
||||||
private: Private
|
private: Private
|
||||||
cancel: Cancel
|
cancel: Cancel
|
||||||
|
cancelImport: Cancel Import
|
||||||
|
cancelledImport: Cancelled Import
|
||||||
|
failedToCancelImport: failed to cancel import
|
||||||
name: Name
|
name: Name
|
||||||
value: Value
|
value: Value
|
||||||
help: help
|
help: help
|
||||||
@ -167,6 +170,7 @@ deleteBranch: Delete Branches
|
|||||||
deleteTag: Delete Tag
|
deleteTag: Delete Tag
|
||||||
deleteTagConfirm: Are you sure you want to delete tag <strong>{{name}}</strong>? You can't undo this action.
|
deleteTagConfirm: Are you sure you want to delete tag <strong>{{name}}</strong>? You can't undo this action.
|
||||||
deleteBranchConfirm: Are you sure you want to delete branch <strong>{{name}}</strong>? You can't undo this action.
|
deleteBranchConfirm: Are you sure you want to delete branch <strong>{{name}}</strong>? You can't undo this action.
|
||||||
|
cancelImportConfirm: Are you sure you want to abort import for <strong>{{name}}</strong>? You can't undo this action.
|
||||||
browse: Browse
|
browse: Browse
|
||||||
browseFiles: Browse Files
|
browseFiles: Browse Files
|
||||||
compare: Compare
|
compare: Compare
|
||||||
|
@ -22,20 +22,23 @@ import {
|
|||||||
Layout,
|
Layout,
|
||||||
PageBody,
|
PageBody,
|
||||||
PageHeader,
|
PageHeader,
|
||||||
|
Utils,
|
||||||
TableV2 as Table,
|
TableV2 as Table,
|
||||||
Text
|
Text,
|
||||||
|
useToaster
|
||||||
} from '@harnessio/uicore'
|
} from '@harnessio/uicore'
|
||||||
import { ProgressBar, Intent } from '@blueprintjs/core'
|
import { ProgressBar, Intent } from '@blueprintjs/core'
|
||||||
import { Color } from '@harnessio/design-system'
|
import { Color, FontVariation } from '@harnessio/design-system'
|
||||||
import type { CellProps, Column } from 'react-table'
|
import type { CellProps, Column } from 'react-table'
|
||||||
import Keywords from 'react-keywords'
|
import Keywords from 'react-keywords'
|
||||||
import cx from 'classnames'
|
import cx from 'classnames'
|
||||||
import { useGet } from 'restful-react'
|
import { useGet } from 'restful-react'
|
||||||
import { useHistory } from 'react-router-dom'
|
import { useHistory } from 'react-router-dom'
|
||||||
import { useStrings } from 'framework/strings'
|
import { useStrings, String } from 'framework/strings'
|
||||||
import { voidFn, formatDate, getErrorMessage, LIST_FETCHING_LIMIT, PageBrowserProps } from 'utils/Utils'
|
import { voidFn, formatDate, getErrorMessage, LIST_FETCHING_LIMIT, PageBrowserProps } from 'utils/Utils'
|
||||||
import { NewRepoModalButton } from 'components/NewRepoModalButton/NewRepoModalButton'
|
import { NewRepoModalButton } from 'components/NewRepoModalButton/NewRepoModalButton'
|
||||||
import type { TypesRepository } from 'services/code'
|
import type { TypesRepository } from 'services/code'
|
||||||
|
import { useDeleteRepository } from 'services/code'
|
||||||
import { usePageIndex } from 'hooks/usePageIndex'
|
import { usePageIndex } from 'hooks/usePageIndex'
|
||||||
import { useQueryParams } from 'hooks/useQueryParams'
|
import { useQueryParams } from 'hooks/useQueryParams'
|
||||||
import { useUpdateQueryParams } from 'hooks/useUpdateQueryParams'
|
import { useUpdateQueryParams } from 'hooks/useUpdateQueryParams'
|
||||||
@ -48,6 +51,8 @@ import { NoResultCard } from 'components/NoResultCard/NoResultCard'
|
|||||||
import { ResourceListingPagination } from 'components/ResourceListingPagination/ResourceListingPagination'
|
import { ResourceListingPagination } from 'components/ResourceListingPagination/ResourceListingPagination'
|
||||||
import { RepoPublicLabel } from 'components/RepoPublicLabel/RepoPublicLabel'
|
import { RepoPublicLabel } from 'components/RepoPublicLabel/RepoPublicLabel'
|
||||||
import KeywordSearch from 'components/CodeSearch/KeywordSearch'
|
import KeywordSearch from 'components/CodeSearch/KeywordSearch'
|
||||||
|
import { OptionsMenuButton } from 'components/OptionsMenuButton/OptionsMenuButton'
|
||||||
|
import { useConfirmAct } from 'hooks/useConfirmAction'
|
||||||
import noRepoImage from './no-repo.svg'
|
import noRepoImage from './no-repo.svg'
|
||||||
import FeatureMap from './FeatureMap/FeatureMap'
|
import FeatureMap from './FeatureMap/FeatureMap'
|
||||||
import css from './RepositoriesListing.module.scss'
|
import css from './RepositoriesListing.module.scss'
|
||||||
@ -112,7 +117,7 @@ export default function RepositoriesListing() {
|
|||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
Header: getString('repos.name'),
|
Header: getString('repos.name'),
|
||||||
width: 'calc(100% - 180px)',
|
width: 'calc(100% - 210px)',
|
||||||
|
|
||||||
Cell: ({ row }: CellProps<TypesRepoExtended>) => {
|
Cell: ({ row }: CellProps<TypesRepoExtended>) => {
|
||||||
const record = row.original
|
const record = row.original
|
||||||
@ -159,6 +164,58 @@ export default function RepositoriesListing() {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
disableSortBy: true
|
disableSortBy: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'action',
|
||||||
|
width: '30px',
|
||||||
|
Cell: ({ row }: CellProps<TypesRepoExtended>) => {
|
||||||
|
const { showSuccess, showError } = useToaster()
|
||||||
|
const { mutate: deleteRepo } = useDeleteRepository({})
|
||||||
|
const confirmCancelImport = useConfirmAct()
|
||||||
|
return (
|
||||||
|
<Container onClick={Utils.stopEvent}>
|
||||||
|
{row.original.importing && (
|
||||||
|
<OptionsMenuButton
|
||||||
|
isDark
|
||||||
|
width="100px"
|
||||||
|
items={[
|
||||||
|
{
|
||||||
|
text: getString('cancelImport'),
|
||||||
|
onClick: () =>
|
||||||
|
confirmCancelImport({
|
||||||
|
title: getString('cancelImport'),
|
||||||
|
confirmText: getString('cancelImport'),
|
||||||
|
intent: Intent.DANGER,
|
||||||
|
message: (
|
||||||
|
<Text
|
||||||
|
style={{ wordBreak: 'break-word' }}
|
||||||
|
font={{ variation: FontVariation.BODY2_SEMI, size: 'small' }}>
|
||||||
|
<String
|
||||||
|
useRichText
|
||||||
|
stringID="cancelImportConfirm"
|
||||||
|
vars={{ name: row.original?.uid }}
|
||||||
|
tagName="div"
|
||||||
|
/>
|
||||||
|
</Text>
|
||||||
|
),
|
||||||
|
action: async () => {
|
||||||
|
deleteRepo(`${row.original?.path as string}/+/`)
|
||||||
|
.then(() => {
|
||||||
|
showSuccess(getString('cancelledImport'), 2000)
|
||||||
|
refetch()
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
showError(getErrorMessage(err), 0, getString('failedToCancelImport'))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Container>
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
[nameTextWidth, getString, searchTerm]
|
[nameTextWidth, getString, searchTerm]
|
||||||
|
Loading…
Reference in New Issue
Block a user