-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
feat(runs_list): add button delete workflow run #33138
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
Closed
zsbahtiar
wants to merge
30
commits into
go-gitea:main
from
zsbahtiar:feat/actions-delete-workflow-run
Closed
Changes from 16 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
fcd6948
feat(runs_list): add button delete workflow run
862237c
fix: lint
5358fc5
feat(action_model): add query DeleteRunByID
c8dbc29
feat(web): add path DELETE /username/reponame/actions/runs/{id}
3938aea
feat(initGlobalDeleteButton): add option http method delete when data…
6c58a02
fix: lint
8170c47
feat(DeleteRunByID): add delete action_run_job
60982c7
Merge branch 'main' into feat/actions-delete-workflow-run
zsbahtiar c4bdf78
refactor: change middleware to reqRepoActionsWriter
1e75212
feat(websrc): add repo action for handling delete
aa8a3d0
feat(action.list): add checkbox all and button delete
b6afdc6
refactor(run_list): change from button delete workflow to checkbox
8413beb
refactor(action.delete): change to support plural delete action runs
7f511d9
feat(DeleteRunByIDs): add delete action_task_step, action_task_output…
3faea22
revert
0b27261
revert
050a6b6
feat: add GetRunJobsByRunIDs
5dd6245
fix: job id
05af60b
refactor: change to GetRunsByIDsAndTriggerUserID
80377f8
rm: invalid test
1390874
feat: add GetRunTasksByJobIDs
965087e
feat: add removeActionTaskLogFilenames
71b773a
fix: lint
1a7a7e7
refactor: change to DeleteActionRunAndChild
8c742ab
test(integration): add TestRepoActionDelete
e17f73a
test(integration): add assert error equal
95924a1
fix: lint
f389529
fix: job
530360b
fix: check backend
5576b10
Merge branch 'main' into feat/actions-delete-workflow-run
silverwind File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import {queryElems, toggleElem} from '../utils/dom.ts'; | ||
import {confirmModal} from './comp/ConfirmModal.ts'; | ||
import {showErrorToast} from '../modules/toast.ts'; | ||
import {POST} from '../modules/fetch.ts'; | ||
|
||
function initRepoActionListCheckboxes() { | ||
const actionListSelectAll = document.querySelector<HTMLInputElement>('.action-checkbox-all'); | ||
if (!actionListSelectAll) return; // logged out state | ||
const issueCheckboxes = document.querySelectorAll<HTMLInputElement>('.action-checkbox:not([disabled])'); | ||
const actionDelete = document.querySelector('#action-delete'); | ||
const syncIssueSelectionState = () => { | ||
const enabledCheckboxes = Array.from(issueCheckboxes).filter((el) => !el.disabled); | ||
const checkedCheckboxes = enabledCheckboxes.filter((el) => el.checked); | ||
const anyChecked = Boolean(checkedCheckboxes.length); | ||
const allChecked = anyChecked && checkedCheckboxes.length === enabledCheckboxes.length; | ||
|
||
if (allChecked) { | ||
actionListSelectAll.checked = true; | ||
actionListSelectAll.indeterminate = false; | ||
} else if (anyChecked) { | ||
actionListSelectAll.checked = false; | ||
actionListSelectAll.indeterminate = true; | ||
} else { | ||
actionListSelectAll.checked = false; | ||
actionListSelectAll.indeterminate = false; | ||
} | ||
if (actionDelete) { | ||
toggleElem('#action-delete', anyChecked); | ||
} | ||
}; | ||
|
||
for (const el of issueCheckboxes) { | ||
el.addEventListener('change', syncIssueSelectionState); | ||
} | ||
|
||
actionListSelectAll.addEventListener('change', () => { | ||
for (const el of issueCheckboxes) { | ||
if (!el.disabled) { | ||
el.checked = actionListSelectAll.checked; | ||
} | ||
} | ||
syncIssueSelectionState(); | ||
}); | ||
|
||
queryElems(document, '.action-action', (el) => el.addEventListener('click', | ||
async (e: MouseEvent) => { | ||
e.preventDefault(); | ||
|
||
const action = el.getAttribute('data-action'); | ||
const url = el.getAttribute('data-url'); | ||
const actionIDList: number[] = []; | ||
const radix = 10; | ||
for (const el of document.querySelectorAll<HTMLInputElement>('.action-checkbox:checked:not([disabled])')) { | ||
const id = el.getAttribute('data-action-id'); | ||
if (id) { | ||
actionIDList.push(parseInt(id, radix)); | ||
} | ||
} | ||
if (actionIDList.length < 1) return; | ||
|
||
// for delete | ||
if (action === 'delete') { | ||
const confirmText = el.getAttribute('data-action-delete-confirm'); | ||
if (!await confirmModal({content: confirmText, confirmButtonColor: 'red'})) { | ||
return; | ||
} | ||
} | ||
|
||
try { | ||
await deleteActions(url, actionIDList); | ||
window.location.reload(); | ||
} catch (err) { | ||
showErrorToast(err.responseJSON?.error ?? err.message); | ||
} | ||
}, | ||
)); | ||
} | ||
|
||
async function deleteActions(url: string, actionIds: number[]) { | ||
try { | ||
const response = await POST(url, { | ||
data: { | ||
actionIds, | ||
}, | ||
}); | ||
if (!response.ok) { | ||
throw new Error('failed to delete actions'); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
export function initRepoActionList() { | ||
if (document.querySelector('.page-content.repository.actions')) { | ||
initRepoActionListCheckboxes(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.