argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
18k stars 5.48k forks source link

Provide a setting to skip the "please type resource name to confirm deletion" prompt #20858

Open W1zzardTPU opened 2 days ago

W1zzardTPU commented 2 days ago

Showing the popup that asks for the resource name before deletion just trains muscle memory to select, copy and paste and wastes a lot of time.

Give us a setting please to disable these mechanics.

Since it's likely that this won't be implemented, here's a workaround using Greasemonkey: (Make sure to update the hostname in line 3)

// ==UserScript==
// @name         Auto-fill ArgoCD Deletion Popup Input
// @match        *://argocd.yourhostname.com/*
// ==/UserScript==

(function() {
    'use strict';

    // Use a MutationObserver to monitor the document for changes
    const observer = new MutationObserver(mutations => {
        for (let mutation of mutations) {
            if (mutation.type === 'childList') {
                // Check if any added nodes match the popup class "popup-container"
                mutation.addedNodes.forEach(node => {
                    if (node.nodeType === 1 && node.classList.contains('popup-overlay')) {

                        // Find the input with class "baz" within the popup
                        const input = node.querySelector('.argo-field');
                        if (input) {
                            const label = input.nextElementSibling;
                            if (label && label.tagName.toLowerCase() === 'label') {
                                    let text = label.textContent;
                                if (text.includes('to confirm the deletion')) {
                                    const match = text.match(/'([^']+)'/);
                                    if (match) {
                                        input.value = match[1];
                                        input.dispatchEvent(new Event('input', { bubbles: true }));                                                                        
                                    }
                                }
                            }                          
                        }
                    }
                });
            }
        }
    });

    // Start observing the entire document
    observer.observe(document.body, { childList: true, subtree: true });
})();
andrii-korotkov-verkada commented 1 day ago

What do you think should be protections against unintended deletes or too dangerous deletes?

W1zzardTPU commented 1 day ago

What do you think should be protections against unintended deletes or too dangerous deletes?

That's a great question, and I get what you're asking. I would guess separation of responsibilities and proper setup of staging environments (which is outside the scope of any software).

The popup by itself definitely helps protect against misclicks (I'm not asking to remove the whole popup, just the tedious copy&paste mechanism).