feat: Add Argo CD Application detail view, Sync/Refresh via Kubernetes API#876
feat: Add Argo CD Application detail view, Sync/Refresh via Kubernetes API#876Joshna907 wants to merge 7 commits into
Conversation
6bb77be to
5d7ef86
Compare
There was a problem hiding this comment.
Pull request overview
This PR enhances the argocd Headlamp plugin by adding an Application detail page and list row actions (Sync/Refresh) implemented via Kubernetes API patches, plus improving navigation and branding with the official Argo CD sidebar icon.
Changes:
- Added an Application detail view route/page and wired
detailsRouteso name links navigate correctly. - Added Sync/Refresh row actions that patch the Application CR via the Kubernetes API (no Argo CD REST/session auth).
- Registered the Argo CD icon for offline rendering and bumped the plugin version.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| argocd/src/resources/application.ts | Adds detailsRoute to match the registered detail route. |
| argocd/src/index.tsx | Registers offline icon, list + detail routes, and updates sidebar icon. |
| argocd/src/index.test.tsx | Updates mocks and assertions for new route + icon registration. |
| argocd/src/components/applications/List.tsx | Adds Sync/Refresh actions and toast notifications for mutations. |
| argocd/src/components/applications/Detail.tsx | New Application detail view using DetailsGrid and status badges. |
| argocd/src/api/argoClient.ts | New Kubernetes API merge-patch helpers for sync/refresh. |
| argocd/package.json | Version bump to 0.1.1. |
| argocd/package-lock.json | Updates lock metadata to match the package name/version. |
Files not reviewed (1)
- argocd/package-lock.json: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Review FeedbackThank you for this. I have some questions and suggestions that would help strengthen this further. Questions & Clarifications1. Error Handling & RBAC
2. Test CoverageCould you clarify:
3. DocumentationConsider updating:
4. Edge Cases
5. Semantic VersioningThe bump 6. UX - Loading StatesDo the Sync/Refresh buttons show loading indicators during API calls? This would prevent accidental double-clicks and improve user feedback. 💡Code SuggestionsLoading State Management (List.tsx)Consider adding explicit loading state to prevent double-clicks: const [isSyncing, setIsSyncing] = useState<string | null>(null); // Track by app name/namespace
const handleSync = async (app: Application) => {
const appKey = `${app.metadata.namespace}/${app.metadata.name}`;
if (isSyncing === appKey) return; // Prevent double-click
setIsSyncing(appKey);
try {
await syncApplication(app);
enqueueSnackbar(`Sync initiated for ${app.metadata.name}`, { variant: 'success' });
} catch (error) {
enqueueSnackbar(`Sync failed: ${error.message}`, { variant: 'error' });
} finally {
setIsSyncing(null);
}
};RBAC Error Handling (argoClient.ts)Enhance error messages for permission issues: try {
await apiClient.patch(/* ... */);
} catch (error) {
if (error.statusCode === 403) {
throw new Error(
`Insufficient permissions to sync Application. ` +
`Required: applications.argoproj.io [update, patch] in namespace ${namespace}`
);
}
throw error;
}✅ Recommended Before Merge
|
|
ptal @illume @Tatsinnit now |
|
I think we should take a look at the commit messages , not including fixes for previous commits in the same PR. The last couple of commits fall within that. Instead they should be added to the previous commit. This is so that when people review commit by commit they can understand it better. Otherwise they might be like "oh I spot a bug here, and here are some paragraphs explaining it"... then several commits later... "oh, they fixed it." |
Add detail page using Headlamp's DetailsGrid to render standard metadata plus Argo CD-specific fields (project, source, sync and health status). Status columns are rendered as color-coded badges using StatusLabel. Extract shared status-mapping functions (getHealthStatus, getSyncStatus) into statusHelpers.ts so both the list and detail views use the same logic. Signed-off-by: Joshna907 <joshnawaikar@gmail.com>
Add static detailsRoute getter so name links in the list view navigate to the detail page instead of falling back to Home. Signed-off-by: Joshna907 <joshnawaikar@gmail.com>
2f68943 to
d90a84b
Compare
d90a84b to
5f0f63b
Compare
ashu8912
left a comment
There was a problem hiding this comment.
Added a few nits and comments
503776a to
c1a8e7c
Compare
Add merge-patch functions for sync (.operation field) and refresh (argocd.argoproj.io/refresh annotation). Includes RBAC-aware error handling that surfaces a user-friendly message on 403 Forbidden. Signed-off-by: Joshna907 <joshnawaikar@gmail.com>
Register the detail route, add the official Argo CD octopus logo as an offline Iconify icon via addIcon() (CSP-safe, no external fetch), and change sidebar icon from generic mdi:application-cog to branded simple-icons:argo. Signed-off-by: Joshna907 <joshnawaikar@gmail.com>
Add Sync and Refresh as row actions using Headlamp's ActionButton and actions prop. Both call Kubernetes API merge-patch functions from argoClient.ts with loading state to prevent double-clicks and snackbar notifications showing error details on failure. Bump version to 0.2.0 for new features (semver). Signed-off-by: Joshna907 <joshnawaikar@gmail.com>
Add unit tests for syncApplication and refreshApplication verifying URL, method, headers, and patch body. Include error scenario tests for 403 RBAC forbidden and network error passthrough. Update existing index.test.tsx mocks for the detail view route. Signed-off-by: Joshna907 <joshnawaikar@gmail.com>
Document the detail view, Sync/Refresh actions, K8s API rationale, and required RBAC permissions (ClusterRole manifest). Signed-off-by: Joshna907 <joshnawaikar@gmail.com>
4249805 to
c1a8e7c
Compare
Summary
This PR adds a detail page, Sync and Refresh actions, the official Argo CD sidebar icon, and proper route navigation. All mutations use the Kubernetes API directly — no Argo CD REST API or session tokens needed.
Why Kubernetes API instead of the Argo CD REST API?
Headlamp plugins route all API calls through the Kubernetes apiserver service proxy. This means the Argo CD REST API is unreachable from a plugin:
Authorization: Bearerheader is consumed by the apiserver for its own auth and never forwarded to argocd-server.Cookieheader is a forbidden header — the browser strips it before the request leaves.document.cookiedisabled, so cookies can't be set programmatically either.All three auth channels fail, so the Argo CD session token can never reach argocd-server. Instead, this plugin drives Argo CD the Kubernetes-native way:
.operationfield viaapplication/merge-patch+json. The Argo CD application-controller watches this field and runs the sync, exactly as the Argo CD CLI does.argocd.argoproj.io/refreshannotation. The controller reconciles the app against its Git source when it sees this annotation.No Argo CD API authentication is needed — the user's existing cluster RBAC governs access. This is the same approach used by the Flux plugin (annotation patches) and Microsoft's vscode-aks-tools (kubectl-based, never REST API).
Changes
Added
src/components/applications/Detail.tsx— Application detail view using Headlamp'sDetailsGrid. Displays project, source repo, target revision, path, destination, sync status, and health status as color-coded badges. Includes Kubernetes events viawithEvents.Changed
src/resources/application.ts— Addedstatic get detailsRoute()so name links in the list view navigate to the detail page instead of falling back to Home.src/index.tsx— Registered the detail route, added the official Argo CD octopus logo as an offline Iconify icon viaaddIcon()(CSP-safe, no external fetch), changed sidebar icon from genericmdi:application-cogto brandedsimple-icons:argo.src/components/applications/List.tsx— Added Sync and Refresh as row actions using Headlamp'sActionButtonandactionsprop. Both call Kubernetes API merge-patch functions fromargoClient.tsand show toast notifications via notistack on success/failure.package.json— Bumped version to0.1.1.Screenshots
Steps to Test