-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support multiple extensions per resource group/kind (#9834)
* feat: support multiple extensions per resource group/kind Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com> * apply reviewers suggestions Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com> * apply reviewer notes: stream extension files one by one Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com> * wrap errors Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com> * skip symlinks Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
- Loading branch information
Showing
6 changed files
with
169 additions
and
59 deletions.
There are no files selected for viewing
This file contains 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,59 @@ | ||
# 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 ). | ||
|
||
``` | ||
/tmp/extensions | ||
├── example1 | ||
│ └── extension-1.js | ||
└── example2 | ||
└── 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: | ||
|
||
```js | ||
externals: { | ||
react: 'React' | ||
} | ||
``` | ||
|
||
## 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: | ||
|
||
```typescript | ||
registerResourceExtension(component: ExtensionComponent, group: string, kind: string, tabTitle: string) | ||
``` | ||
|
||
|
||
|
||
* `component: ExtensionComponent` is a React component that receives the following properties: | ||
|
||
* resource: State - the kubernetes resource object; | ||
* tree: ApplicationTree - includes list of all resources that comprise the application; | ||
|
||
See properties interfaces in [models.ts](https://github.com/argoproj/argo-cd/blob/master/ui/src/app/shared/models.ts) | ||
|
||
* `group: string` - the glob expression that matches the group of the resource; | ||
* `kind: string` - the glob expression that matches the kind of the resource; | ||
* `tabTitle: string` - the extension tab title. | ||
|
||
Below is an example of a resource tab extension: | ||
|
||
```javascript | ||
((window) => { | ||
const component = () => { | ||
return React.createElement( 'div', {}, 'Hello World' ); | ||
}; | ||
window.extensionsAPI.registerResourceExtension(component, '*', '*', 'Nice extension'); | ||
})(window) | ||
``` | ||
|
This file contains 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 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 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 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 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