Skip to content

Commit

Permalink
feat: [code-1882] support to delete failed import (#2092)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkapoor10 authored and Harness committed Jun 12, 2024
1 parent 2f7e665 commit cdd7478
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 42 deletions.
4 changes: 4 additions & 0 deletions web/src/framework/strings/stringTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,9 @@ export interface StringsMap {
deleteBranchConfirm: string
deleteBranchText: string
deleteCommentConfirm: string
deleteFailedImport: string
deleteFile: string
deleteImport: string
deleteNotAllowed: string
deleteRepoText: string
deleteRepoTitle: string
Expand All @@ -345,6 +347,7 @@ export interface StringsMap {
deleteTokenMsg: string
deleteUser: string
deleted: string
deletedImport: string
deployKeys: string
descending: string
description: string
Expand Down Expand Up @@ -442,6 +445,7 @@ export interface StringsMap {
failedToCreateRepo: string
failedToCreateSpace: string
failedToDeleteBranch: string
failedToDeleteImport: string
failedToDeleteWebhook: string
failedToFetchFileContent: string
failedToImportSpace: string
Expand Down
6 changes: 5 additions & 1 deletion web/src/i18n/strings.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ public: Public
private: Private
cancel: Cancel
cancelImport: Cancel Import
deleteImport: Delete Import
cancelledImport: Cancelled Import
failedToCancelImport: failed to cancel import
deletedImport: Deleted Import
failedToCancelImport: Failed to cancel import
failedToDeleteImport: Failed to delete import
name: Name
value: Value
help: help
Expand Down Expand Up @@ -174,6 +177,7 @@ deleteTag: Delete Tag
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.
cancelImportConfirm: Are you sure you want to abort import for <strong>{{name}}</strong>? You can't undo this action.
deleteFailedImport: Are you sure you want to delete <strong>{{name}}</strong>?
browse: Browse
browseFiles: Browse Files
compare: Compare
Expand Down
120 changes: 79 additions & 41 deletions web/src/pages/RepositoriesListing/RepositoriesListing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,47 +224,85 @@ export default function RepositoriesListing() {
const confirmCancelImport = useConfirmAct()
return (
<Container onClick={Utils.stopEvent}>
{row?.original?.importProgress === ImportStatus.FAILED
? null
: 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'))
})
}
})
}
]}
/>
)}
{row?.original?.importProgress === ImportStatus.FAILED ? (
<OptionsMenuButton
isDark
width="100px"
items={[
{
text: getString('deleteImport'),
onClick: () =>
confirmCancelImport({
title: getString('deleteImport'),
confirmText: getString('delete'),
intent: Intent.DANGER,
message: (
<Text
style={{ wordBreak: 'break-word' }}
font={{ variation: FontVariation.BODY2_SEMI, size: 'small' }}>
<String
useRichText
stringID="deleteFailedImport"
vars={{ name: row.original?.uid }}
tagName="div"
/>
</Text>
),
action: async () => {
deleteRepo(`${row.original?.path as string}/+/`)
.then(() => {
showSuccess(getString('deletedImport'), 2000)
refetch()
})
.catch(err => {
showError(getErrorMessage(err), 0, getString('failedToDeleteImport'))
})
}
})
}
]}
/>
) : (
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>
)
}
Expand Down

0 comments on commit cdd7478

Please sign in to comment.