Skip to content

Commit

Permalink
Merge pull request #38107 from appsmithorg/fix/client-build-prod
Browse files Browse the repository at this point in the history
## Description

Updating the logic for datasource selector to fox the client build
failure on prod

Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

/ok-to-test tags="@tag.Datasource"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!IMPORTANT]
> 🟣 🟣 🟣 Your tests are running.
> Tests running at:
<https://github.com/appsmithorg/appsmith/actions/runs/12277105493>
> Commit: 507ed6f
> Workflow: `PR Automation test suite`
> Tags: `@tag.Datasource`
> Spec: ``
> <hr>Wed, 11 Dec 2024 13:13:25 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
	- Enhanced `Datasource` component to support plugin data.
- `DatasourceInfo`, `DatasourceTables`, and `DatasourceSelector`
components now accept a `plugin` prop, improving their functionality and
flexibility.

- **Bug Fixes**
- No functional changes, but improved handling of plugin data
integration.

- **Documentation**
	- Updated component interfaces to reflect new `plugin` prop.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
mohanarpit authored Dec 11, 2024
2 parents 0a046ed + 507ed6f commit 996a30b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { BOTTOMBAR_HEIGHT } from "./constants";
import { useEditorType } from "ee/hooks";
import { useParentEntityInfo } from "ee/hooks/datasourceEditorHooks";
import DatasourceInfo from "./DatasourceInfo";
import { getPlugin } from "ee/selectors/entitiesSelector";

interface Props {
datasourceId: string;
Expand All @@ -45,6 +46,8 @@ const Datasource = (props: Props) => {
getPluginIdFromDatasourceId(state, props.datasourceId),
);

const plugin = useSelector((state) => getPlugin(state, pluginId || ""));

const editorType = useEditorType(location.pathname);
const { parentEntityId } = useParentEntityInfo(editorType);

Expand Down Expand Up @@ -143,6 +146,7 @@ const Datasource = (props: Props) => {
<DatasourceInfo
datasourceId={props.datasourceId}
datasourceName={props.datasourceName}
plugin={plugin}
showEditButton={!isLoading}
/>
<StatusDisplay
Expand Down Expand Up @@ -170,6 +174,7 @@ const Datasource = (props: Props) => {
datasourceId={props.datasourceId}
datasourceName={props.datasourceName}
datasourceStructure={datasourceStructure}
plugin={plugin}
selectedTable={selectedTable}
setSelectedTable={setSelectedTable}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

const DatasourceInfo = ({
datasourceId,
datasourceName,
plugin,
showEditButton,
}: Props) => {
const editorType = useEditorType(location.pathname);
Expand Down Expand Up @@ -50,6 +53,7 @@ const DatasourceInfo = ({
<DatasourceSelector
datasourceId={datasourceId}
datasourceName={datasourceName}
plugin={plugin}
/>
{showEditButton && (
<Tooltip content={createMessage(EDIT_DS_CONFIG)} placement="top">
Expand Down
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 {
Expand All @@ -16,16 +15,17 @@ const API_FORM_COMPONENTS = [
export interface DatasourceProps {
datasourceId: string;
datasourceName: string;
plugin?: Plugin;
}

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;
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import { refreshDatasourceStructure } from "actions/datasourceActions";
import { useDispatch } from "react-redux";
import { SchemaTableContainer } from "./styles";
import DatasourceInfo from "./DatasourceInfo";
import type { Plugin } from "api/PluginApi";

interface Props {
datasourceId: string;
datasourceName: string;
currentActionId: string;
datasourceStructure: DatasourceStructure;
plugin?: Plugin;
setSelectedTable: (table: string) => void;
selectedTable: string | undefined;
}
Expand All @@ -24,6 +26,7 @@ const DatasourceTables = ({
datasourceId,
datasourceName,
datasourceStructure,
plugin,
selectedTable,
setSelectedTable,
}: Props) => {
Expand Down Expand Up @@ -56,6 +59,7 @@ const DatasourceTables = ({
<DatasourceInfo
datasourceId={datasourceId}
datasourceName={datasourceName}
plugin={plugin}
showEditButton
/>
<Button
Expand Down

0 comments on commit 996a30b

Please sign in to comment.