UI Extensions

Argo CD web user interface can be extended with additional UI elements. Extensions should be delivered as a javascript file in the argocd-server Pods that are placed in the /tmp/extensions directory and starts with extension prefix ( matches to ^extension(.*)\.js$ regex ).

  1. /tmp/extensions
  2. ├── example1
  3. └── extension-1.js
  4. └── example2
  5. └── extension-2.js

Extensions are loaded during initial page rendering and should register themselves using API exposed in the extensionsAPI global variable. (See corresponding extension type details for additional information).

The extension should provide a React component that is responsible for rendering the UI element. Extension should not bundle the React library. Instead extension should use the react global variable. You can leverage externals setting if you are using webpack:

  1. externals: {
  2. react: "React";
  3. }

Resource Tab Extensions

Resource Tab extensions is an extension that provides an additional tab for the resource sliding panel at the Argo CD Application details page.

The resource tab extension should be registered using the extensionsAPI.registerResourceExtension method:

  1. registerResourceExtension(component: ExtensionComponent, group: string, kind: string, tabTitle: string)
  • component: ExtensionComponent is a React component that receives the following properties:

  • application: Application - Argo CD Application resource;

  • resource: State - the Kubernetes resource object;

  • tree: ApplicationTree - includes list of all resources that comprise the application;

See properties interfaces in models.ts

  • group: string - the glob expression that matches the group of the resource; note: use globstar (**) to match all groups including empty string;
  • kind: string - the glob expression that matches the kind of the resource;
  • tabTitle: string - the extension tab title.
  • opts: Object - additional options:
  • icon: string - the class name the represents the icon from the https://fontawesome.com/ library (e.g. ‘fa-calendar-alt’);

Below is an example of a resource tab extension:

  1. ((window) => {
  2. const component = () => {
  3. return React.createElement("div", {}, "Hello World");
  4. };
  5. window.extensionsAPI.registerResourceExtension(
  6. component,
  7. "*",
  8. "*",
  9. "Nice extension"
  10. );
  11. })(window);

System Level Extensions

Argo CD allows you to add new items to the sidebar that will be displayed as a new page with a custom component when clicked. The system level extension should be registered using the extensionsAPI.registerSystemLevelExtension method:

  1. registerSystemLevelExtension(component: ExtensionComponent, title: string, options: {icon?: string})

Below is an example of a simple system level extension:

  1. ((window) => {
  2. const component = () => {
  3. return React.createElement(
  4. "div",
  5. { style: { padding: "10px" } },
  6. "Hello World"
  7. );
  8. };
  9. window.extensionsAPI.registerSystemLevelExtension(
  10. component,
  11. "Test Ext",
  12. "/hello",
  13. "fa-flask"
  14. );
  15. })(window);

Application Tab Extensions

Since the Argo CD Application is a Kubernetes resource, application tabs can be the same as any other resource tab. Make sure to use ‘argoproj.io’/‘Application’ as group/kind and an extension will be used to render the application-level tab.

Application Status Panel Extensions

The status panel is the bar at the top of the application view where the sync status is displayed. Argo CD allows you to add new items to the status panel of an application. The extension should be registered using the extensionsAPI.registerStatusPanelExtension method:

  1. registerStatusPanelExtension(component: StatusPanelExtensionComponent, title: string, id: string, flyout?: ExtensionComponent)

Below is an example of a simple extension:

  1. ((window) => {
  2. const component = () => {
  3. return React.createElement(
  4. "div",
  5. { style: { padding: "10px" } },
  6. "Hello World"
  7. );
  8. };
  9. window.extensionsAPI.registerStatusPanelExtension(
  10. component,
  11. "My Extension",
  12. "my_extension"
  13. );
  14. })(window);

Flyout widget

It is also possible to add an optional flyout widget to your extension. It can be opened by calling openFlyout() from your extension’s component. Your flyout component will then be rendered in a sliding panel, similar to the panel that opens when clicking on History and rollback.

Below is an example of an extension using the flyout widget:

  1. ((window) => {
  2. const component = (props: {
  3. openFlyout: () => any
  4. }) => {
  5. return React.createElement(
  6. "div",
  7. {
  8. style: { padding: "10px" },
  9. onClick: () => props.openFlyout()
  10. },
  11. "Hello World"
  12. );
  13. };
  14. const flyout = () => {
  15. return React.createElement(
  16. "div",
  17. { style: { padding: "10px" } },
  18. "This is a flyout"
  19. );
  20. };
  21. window.extensionsAPI.registerStatusPanelExtension(
  22. component,
  23. "My Extension",
  24. "my_extension",
  25. flyout
  26. );
  27. })(window);

Top Bar Action Menu Extensions

The top bar panel is the action menu at the top of the application view where the action buttons are displayed like Details, Sync, Refresh. Argo CD allows you to add new button to the top bar action menu of an application. When the extension button is clicked, the custom widget will be rendered in a flyout panel.

The extension should be registered using the extensionsAPI.registerTopBarActionMenuExt method:

  1. registerTopBarActionMenuExt(
  2. component: TopBarActionMenuExtComponent,
  3. title: string,
  4. id: string,
  5. flyout?: ExtensionComponent,
  6. shouldDisplay: (app?: Application) => boolean = () => true,
  7. iconClassName?: string,
  8. isMiddle = false
  9. )

The callback function shouldDisplay should return true if the extension should be displayed and false otherwise:

  1. const shouldDisplay = (app: Application) => {
  2. return application.metadata?.labels?.['application.environmentLabelKey'] === "prd";
  3. };

Below is an example of a simple extension with a flyout widget:

  1. ((window) => {
  2. const shouldDisplay = () => {
  3. return true;
  4. };
  5. const flyout = () => {
  6. return React.createElement(
  7. "div",
  8. { style: { padding: "10px" } },
  9. "This is a flyout"
  10. );
  11. };
  12. const component = () => {
  13. return React.createElement(
  14. "div",
  15. {
  16. onClick: () => flyout()
  17. },
  18. "Toolbar Extension Test"
  19. );
  20. };
  21. window.extensionsAPI.registerTopBarActionMenuExt(
  22. component,
  23. "Toolbar Extension Test",
  24. "Toolbar_Extension_Test",
  25. flyout,
  26. shouldDisplay,
  27. '',
  28. true
  29. );
  30. })(window);