generated from openmcp-project/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Custom Resource Definition Schema based Intellisense for YAML viewer and editor #364
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
Open
lucasgoral
wants to merge
95
commits into
main
Choose a base branch
from
intellisense-for-yaml-editor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 78 commits
Commits
Show all changes
95 commits
Select commit
Hold shift + click to select a range
99d7f78
init
lucasgoral 31416d8
Merge branch 'main' into edit-resources
lucasgoral 4c78673
fix
lucasgoral 667bb38
fixes
lucasgoral cae0b1d
fix
lucasgoral a7524f9
fixes
lucasgoral b71be75
Update ManagedResources.tsx
lucasgoral 1b65dde
refactor
lucasgoral dc27602
fix
lucasgoral 3548a2f
Update YamlSidePanel.tsx
lucasgoral 2dbea4b
Update ManagedResources.tsx
lucasgoral 39533d5
Merge branch 'main' into edit-resources
lucasgoral 23dba77
refactor
lucasgoral e5b3d3c
Update ProvidersConfig.tsx
lucasgoral 27a6e75
Update src/components/YamlEditor/YamlDiffEditor.tsx
lucasgoral 7309a85
Update src/components/YamlEditor/YamlEditor.tsx
lucasgoral 5d2af7c
refactor
lucasgoral e3d4f02
removed finalizers
lucasgoral 6082362
refactor
lucasgoral 80035ae
fix
lucasgoral f42c67c
fix
lucasgoral 918f04c
refactor
lucasgoral 54fa61f
fix
lucasgoral 2407778
Merge branch 'main' into edit-resources
lucasgoral 0d8c56b
Merge branch 'main' into edit-resources
Hubert-Szczepanski-SAP 3b59674
Update convertToResourceConfig.ts
lucasgoral f24a383
Update convertToResourceConfig.ts
lucasgoral 40440fd
Merge branch 'main' into edit-resources
lucasgoral 60629f9
fix
lucasgoral ac411c5
fix
lucasgoral 7eaa038
refactor
lucasgoral 53c0b3b
Update YamlEditor.module.css
lucasgoral 0391900
refactor
lucasgoral 841b024
Update YamlSidePanel.module.css
lucasgoral 2a8f6f8
refactor
lucasgoral e1d3874
Merge branch 'main' into edit-resources
lucasgoral ba93909
Update ActionsMenu.tsx
lucasgoral 0a94eca
fix
lucasgoral 3c33acf
Merge branch 'main' into edit-resources
lucasgoral b55f44f
Update monaco.ts
lucasgoral f2fd02f
fix
lucasgoral c54e0e5
refactor
lucasgoral 3fe0bfc
Update YamlEditor.tsx
lucasgoral bbb8b87
Merge branch 'main' into edit-resources
lucasgoral b128354
init
lucasgoral 01fc245
init
lucasgoral 8b6dace
init
lucasgoral d06c098
demo
lucasgoral 92f06d7
Update YamlEditor.tsx
lucasgoral 5af6627
fix
lucasgoral f63c900
fix
lucasgoral 9c34b6f
refactor
lucasgoral 16cfd2c
refactor
lucasgoral 0ca4902
init
lucasgoral 56bda8a
Update ProjectsList.tsx
lucasgoral 663efbb
Merge branch 'main' into intellisense-for-yaml-editor
lucasgoral 4801878
Update package-lock.json
lucasgoral 10325c8
refactor
lucasgoral 2f93439
refactor
lucasgoral 61f39f4
fix
lucasgoral 3bed46c
fix
lucasgoral 1c08250
fix
lucasgoral 5eecd45
refactor
lucasgoral 919db44
Merge branch 'main' into intellisense-for-yaml-editor
lucasgoral 6246ae4
fixes
lucasgoral 9114764
Update Graph.tsx
lucasgoral 8d5dc00
fix
lucasgoral 0ac11df
Merge branch 'main' into intellisense-for-yaml-editor
lucasgoral 215083b
Update build.yaml
lucasgoral 57ce21e
Revert "Update build.yaml"
lucasgoral 76cd190
Update package-lock.json
lucasgoral a9a6776
Update YamlEditor.tsx
lucasgoral 6e22777
Update YamlEditor.tsx
lucasgoral 0411073
Update YamlEditor.tsx
lucasgoral 4ed10b4
fix
lucasgoral 53b8958
fix
lucasgoral b11e2cd
Merge branch 'main' into intellisense-for-yaml-editor
lucasgoral 7b156ca
Update package-lock.json
lucasgoral b15f292
Update YamlSidePanelWithLoader.tsx
lucasgoral 71c8955
fix
lucasgoral 9d34630
Update YamlSidePanelWithLoader.tsx
lucasgoral 6e9cfaf
Merge branch 'main' into intellisense-for-yaml-editor
lucasgoral e08b327
fix
lucasgoral 214c240
Update YamlEditor.tsx
lucasgoral 7bf5584
Update AuthContextMcp.tsx
lucasgoral 0c738b1
fix
lucasgoral 49bc60d
fix
lucasgoral 1bdd114
Delete openapi.json
lucasgoral 599f1ff
Merge branch 'main' into intellisense-for-yaml-editor
lucasgoral 2326f1e
added fixes from old PR
lucasgoral 594f8d0
Merge branch 'main' into intellisense-for-yaml-editor
lucasgoral 9d4c362
fix
lucasgoral 3a34387
Merge branch 'main' into intellisense-for-yaml-editor
lucasgoral 7e61a55
Update package-lock.json
lucasgoral bf1374e
Update package-lock.json
lucasgoral 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import { | |
| AnalyticalTable, | ||
| AnalyticalTableColumnDefinition, | ||
| AnalyticalTableScaleWidthMode, | ||
| Button, | ||
| Panel, | ||
| Title, | ||
| Toolbar, | ||
|
|
@@ -35,6 +36,7 @@ import { YamlSidePanel } from '../Yaml/YamlSidePanel.tsx'; | |
| import { ErrorDialog, ErrorDialogHandle } from '../Shared/ErrorMessageBox.tsx'; | ||
| import { APIError } from '../../lib/api/error.ts'; | ||
| import { useHandleResourcePatch } from '../../lib/api/types/crossplane/useHandleResourcePatch.ts'; | ||
| import { useAuthMcp } from '../../spaces/mcp/auth/AuthContextMcp.tsx'; | ||
|
|
||
| interface StatusFilterColumn { | ||
| filterValue?: string; | ||
|
|
@@ -54,6 +56,19 @@ type ResourceRow = { | |
| conditionSyncedMessage: string; | ||
| }; | ||
|
|
||
| /** | ||
| * Checks if a resource is managed by Flux based on the kustomize.toolkit.fluxcd.io/name label | ||
| */ | ||
| const isResourceFluxManaged = (item: ManagedResourceItem | undefined): boolean => { | ||
| if (!item) return false; | ||
|
|
||
| const fluxLabelValue = (item?.metadata?.labels as unknown as Record<string, unknown> | undefined)?.[ | ||
| 'kustomize.toolkit.fluxcd.io/name' | ||
| ]; | ||
|
|
||
| return fluxLabelValue != null && (typeof fluxLabelValue !== 'string' || fluxLabelValue.trim() !== ''); | ||
| }; | ||
|
|
||
| export function ManagedResources() { | ||
| const { t } = useTranslation(); | ||
| const toast = useToast(); | ||
|
|
@@ -105,7 +120,7 @@ export function ManagedResources() { | |
| }, | ||
| [openInAside, handlePatch], | ||
| ); | ||
|
|
||
| const { hasMCPAdminRights } = useAuthMcp(); | ||
| const columns = useMemo<AnalyticalTableColumnDefinition[]>( | ||
| () => | ||
| [ | ||
|
|
@@ -167,8 +182,27 @@ export function ManagedResources() { | |
| disableFilters: true, | ||
| Cell: ({ row }) => { | ||
| const { original } = row; | ||
| const isFluxManaged = isResourceFluxManaged(original?.item); | ||
| return original?.item ? ( | ||
| <YamlViewButton variant="resource" resource={original.item as unknown as Resource} /> | ||
| <YamlViewButton | ||
| variant="resource" | ||
| resource={original.item as unknown as Resource} | ||
| toolbarContent={ | ||
| hasMCPAdminRights ? ( | ||
| <Button | ||
| icon={'edit'} | ||
| design={'Transparent'} | ||
| disabled={isFluxManaged} | ||
| tooltip={t('yaml.fluxManaged')} | ||
lucasgoral marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should only show this tooltip if the resource is managed by flux |
||
| onClick={() => { | ||
| openEditPanel(original?.item); | ||
| }} | ||
| > | ||
| {t('buttons.edit')} | ||
| </Button> | ||
| ) : undefined | ||
| } | ||
| /> | ||
| ) : undefined; | ||
| }, | ||
| }, | ||
|
|
@@ -182,12 +216,7 @@ export function ManagedResources() { | |
| const item = original?.item; | ||
| if (!item) return undefined; | ||
|
|
||
| // Flux-managed check for disabling Edit | ||
| const fluxLabelValue = (item?.metadata?.labels as unknown as Record<string, unknown> | undefined)?.[ | ||
| 'kustomize.toolkit.fluxcd.io/name' | ||
| ]; | ||
| const isFluxManaged = | ||
| typeof fluxLabelValue === 'string' ? fluxLabelValue.trim() !== '' : fluxLabelValue != null; | ||
| const isFluxManaged = isResourceFluxManaged(item); | ||
|
|
||
| const actions: ActionItem<ManagedResourceItem>[] = [ | ||
| { | ||
|
|
@@ -196,20 +225,23 @@ export function ManagedResources() { | |
| icon: 'edit', | ||
| disabled: isFluxManaged, | ||
| onClick: openEditPanel, | ||
| tooltip: isFluxManaged && hasMCPAdminRights ? t('yaml.fluxManaged') : undefined, | ||
| }, | ||
|
|
||
| { | ||
| key: 'delete', | ||
| text: t('ManagedResources.deleteAction'), | ||
| icon: 'delete', | ||
| onClick: openDeleteDialog, | ||
| disabled: !hasMCPAdminRights, | ||
| }, | ||
| ]; | ||
|
|
||
| return <ActionsMenu item={item} actions={actions} />; | ||
| }, | ||
| }, | ||
| ] as AnalyticalTableColumnDefinition[], | ||
| [t, openEditPanel, openDeleteDialog], | ||
| [t, openEditPanel, openDeleteDialog, hasMCPAdminRights], | ||
| ); | ||
|
|
||
| const rows: ResourceRow[] = | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity, why is this dependency needed?