Skip to content

Commit

Permalink
Merge pull request #1234 from kubeshop/mm/bugfix/defaultsourceeditor
Browse files Browse the repository at this point in the history
fix: fallback to source editor if no form available
  • Loading branch information
mortada-codes authored Jan 31, 2022
2 parents c1d7ed5 + 1ce5ae3 commit 067b3b7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/components/organisms/ActionsPane/ActionsPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,14 @@ const ActionsPane = (props: {contentHeight: string}) => {
}, [selectedResourceId, resourceMap]);

useEffect(() => {
if (
(activeTabKey === 'metadataForm' || activeTabKey === 'form') &&
(!selectedResourceId || !(isKustomization || (resourceKindHandler && resourceKindHandler.formEditorOptions)))
) {
if (activeTabKey === 'form' && !isKustomization && !resourceKindHandler?.formEditorOptions?.editorSchema) {
setActiveTabKey('source');
}
}, [selectedResourceId, selectedResource, activeTabKey, resourceKindHandler]);

if (activeTabKey === 'metadataForm' && (!resourceKindHandler || isKustomization)) {
setActiveTabKey('source');
}
}, [selectedResource, activeTabKey, resourceKindHandler, isKustomization]);

const isSelectedResourceUnsaved = useCallback(() => {
if (!selectedResource) {
Expand Down Expand Up @@ -474,7 +475,7 @@ const ActionsPane = (props: {contentHeight: string}) => {
) : null}
</TabPane>
)}
{selectedResource && resourceKindHandler && !isKustomizationResource(selectedResource) && (
{selectedResource && resourceKindHandler && !isKustomization && (
<TabPane
key="metadataForm"
style={{height: editorTabPaneHeight}}
Expand Down

0 comments on commit 067b3b7

Please sign in to comment.