-
Notifications
You must be signed in to change notification settings - Fork 4.5k
chore: Cherry picking fix for client build failure #38109
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,16 +10,19 @@ import { getQueryParams } from "utils/URLUtils"; | |
| import history from "utils/history"; | ||
| import { useEditorType } from "ee/hooks"; | ||
| import { useParentEntityInfo } from "ee/hooks/datasourceEditorHooks"; | ||
| import type { Plugin } from "api/PluginApi"; | ||
|
|
||
| interface Props { | ||
| datasourceId: string; | ||
| datasourceName: string; | ||
| showEditButton: boolean; | ||
| plugin?: Plugin; | ||
|
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. 🛠️ Refactor suggestion Maintain prop optionality consistency with child component If DatasourceSelector requires plugin prop, DatasourceInfo should also make it required to maintain contract consistency. - plugin?: Plugin;
+ plugin: Plugin;Also applies to: 56-56 |
||
| } | ||
|
|
||
| const DatasourceInfo = ({ | ||
| datasourceId, | ||
| datasourceName, | ||
| plugin, | ||
| showEditButton, | ||
| }: Props) => { | ||
| const editorType = useEditorType(location.pathname); | ||
|
|
@@ -50,6 +53,7 @@ const DatasourceInfo = ({ | |
| <DatasourceSelector | ||
| datasourceId={datasourceId} | ||
| datasourceName={datasourceName} | ||
| plugin={plugin} | ||
| /> | ||
| {showEditButton && ( | ||
| <Tooltip content={createMessage(EDIT_DS_CONFIG)} placement="top"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,5 @@ | ||||||
| import React from "react"; | ||||||
| import { UIComponentTypes } from "api/PluginApi"; | ||||||
| import { usePluginActionContext } from "PluginActionEditor/PluginActionContext"; | ||||||
| import { UIComponentTypes, type Plugin } from "api/PluginApi"; | ||||||
| import ApiDatasourceSelector from "./ApiDatasourceSelector"; | ||||||
| import QueryDatasourceSelector from "./QueryDatasourceSelector"; | ||||||
| import { | ||||||
|
|
@@ -16,16 +15,17 @@ const API_FORM_COMPONENTS = [ | |||||
| export interface DatasourceProps { | ||||||
| datasourceId: string; | ||||||
| datasourceName: string; | ||||||
| plugin?: Plugin; | ||||||
|
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. 🛠️ Refactor suggestion Consider making plugin prop required instead of optional The component's rendering logic depends on the plugin prop, but the interface marks it as optional. This could lead to unexpected null renders. - plugin?: Plugin;
+ plugin: Plugin;📝 Committable suggestion
Suggested change
|
||||||
| } | ||||||
|
|
||||||
| const DatasourceSelector = (props: DatasourceProps) => { | ||||||
| const { plugin } = usePluginActionContext(); | ||||||
|
|
||||||
| return API_FORM_COMPONENTS.includes(plugin.uiComponent) ? ( | ||||||
| <ApiDatasourceSelector {...props} formName={API_EDITOR_FORM_NAME} /> | ||||||
| ) : ( | ||||||
| <QueryDatasourceSelector {...props} formName={QUERY_EDITOR_FORM_NAME} /> | ||||||
| ); | ||||||
| return props.plugin ? ( | ||||||
| API_FORM_COMPONENTS.includes(props.plugin.uiComponent) ? ( | ||||||
| <ApiDatasourceSelector {...props} formName={API_EDITOR_FORM_NAME} /> | ||||||
| ) : ( | ||||||
| <QueryDatasourceSelector {...props} formName={QUERY_EDITOR_FORM_NAME} /> | ||||||
| ) | ||||||
| ) : null; | ||||||
| }; | ||||||
|
|
||||||
| export default DatasourceSelector; | ||||||
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.
Improve plugin selector error handling
The empty string fallback for pluginId could fetch an invalid plugin. Consider adding error handling and loading states.
📝 Committable suggestion