Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/connect-react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<!-- markdownlint-disable MD024 -->
# Changelog

# [1.0.0-preview.30] - 2025-02-19

- SelectApp and SelectComponent Improvements

# [1.0.0-preview.29] - 2025-02-10

- Fix enableDebugging state update bug
Expand Down
5 changes: 3 additions & 2 deletions packages/connect-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/connect-react",
"version": "1.0.0-preview.29",
"version": "1.0.0-preview.30",
"description": "Pipedream Connect library for React",
"files": [
"dist"
Expand All @@ -18,7 +18,8 @@
},
"scripts": {
"build": "vite build",
"prepare": "pnpm run build"
"prepare": "pnpm run build",
"watch": "NODE_ENV=development vite build --watch --mode development"
},
"publishConfig": {
"access": "public"
Expand Down
23 changes: 20 additions & 3 deletions packages/connect-react/src/components/SelectApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
} = useApps({
q,
});
const { Option } = components;
const { Option, SingleValue } = components;

Check failure on line 28 in packages/connect-react/src/components/SelectApp.tsx

View workflow job for this annotation

GitHub Actions / Lint Code Base

Expected a line break after this opening brace

Check failure on line 28 in packages/connect-react/src/components/SelectApp.tsx

View workflow job for this annotation

GitHub Actions / Lint Code Base

Expected a line break before this closing brace
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Fix formatting according to linting rules.

The component destructuring needs formatting adjustments.

Apply this diff to fix the formatting:

-  const { Option, SingleValue } = components;
+  const {
+    Option,
+    SingleValue,
+  } = components;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { Option, SingleValue } = components;
const {
Option,
SingleValue,
} = components;
🧰 Tools
🪛 GitHub Check: Lint Code Base

[failure] 28-28:
Expected a line break after this opening brace


[failure] 28-28:
Expected a line break before this closing brace

🪛 GitHub Actions: Pull Request Checks

[error] 28-28: Expected a line break after this opening brace (object-curly-newline).

const selectedValue = apps?.find((o) => o.name_slug === value?.name_slug) || null;
return (
<Select
instanceId={instanceId}
Expand All @@ -52,14 +53,30 @@
</div>
</Option>
),
SingleValue: (singleValueProps) => (
<SingleValue {...singleValueProps}>
<div style={{ display: "flex", gap: 10, alignItems: "center" }}>

Check failure on line 58 in packages/connect-react/src/components/SelectApp.tsx

View workflow job for this annotation

GitHub Actions / Lint Code Base

Expected a line break after this opening brace

Check failure on line 58 in packages/connect-react/src/components/SelectApp.tsx

View workflow job for this annotation

GitHub Actions / Lint Code Base

Object properties must go on a new line

Check failure on line 58 in packages/connect-react/src/components/SelectApp.tsx

View workflow job for this annotation

GitHub Actions / Lint Code Base

Object properties must go on a new line

Check failure on line 58 in packages/connect-react/src/components/SelectApp.tsx

View workflow job for this annotation

GitHub Actions / Lint Code Base

Expected a line break before this closing brace
<img
src={`https://pipedream.com/s.v0/${singleValueProps.data.id}/logo/48`}
style={{ height: 24, width: 24 }}

Check failure on line 61 in packages/connect-react/src/components/SelectApp.tsx

View workflow job for this annotation

GitHub Actions / Lint Code Base

Expected a line break after this opening brace

Check failure on line 61 in packages/connect-react/src/components/SelectApp.tsx

View workflow job for this annotation

GitHub Actions / Lint Code Base

Object properties must go on a new line

Check failure on line 61 in packages/connect-react/src/components/SelectApp.tsx

View workflow job for this annotation

GitHub Actions / Lint Code Base

Expected a line break before this closing brace
alt={singleValueProps.data.name}
/>
<span style={{ whiteSpace: "nowrap" }}>

Check failure on line 64 in packages/connect-react/src/components/SelectApp.tsx

View workflow job for this annotation

GitHub Actions / Lint Code Base

Expected a line break after this opening brace
{singleValueProps.data.name}
</span>
</div>
</SingleValue>
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

LGTM! Enhanced visual presentation.

The SingleValue component implementation improves the visual appearance with consistent styling.

However, the formatting needs adjustment:

Apply this diff to fix the formatting:

        SingleValue: (singleValueProps) => (
          <SingleValue {...singleValueProps}>
-            <div style={{ display: "flex", gap: 10, alignItems: "center" }}>
+            <div style={{
+              display: "flex",
+              gap: 10,
+              alignItems: "center",
+            }}>
              <img
-                src={`https://pipedream.com/s.v0/${singleValueProps.data.id}/logo/48`}
-                style={{ height: 24, width: 24 }}
+                src={`https://pipedream.com/s.v0/${singleValueProps.data.id}/logo/48`}
+                style={{
+                  height: 24,
+                  width: 24,
+                }}
                alt={singleValueProps.data.name}
              />
-              <span style={{ whiteSpace: "nowrap" }}>
+              <span style={{
+                whiteSpace: "nowrap",
+              }}>
                {singleValueProps.data.name}
              </span>
            </div>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
SingleValue: (singleValueProps) => (
<SingleValue {...singleValueProps}>
<div style={{ display: "flex", gap: 10, alignItems: "center" }}>
<img
src={`https://pipedream.com/s.v0/${singleValueProps.data.id}/logo/48`}
style={{ height: 24, width: 24 }}
alt={singleValueProps.data.name}
/>
<span style={{ whiteSpace: "nowrap" }}>
{singleValueProps.data.name}
</span>
</div>
</SingleValue>
),
SingleValue: (singleValueProps) => (
<SingleValue {...singleValueProps}>
<div style={{
display: "flex",
gap: 10,
alignItems: "center",
}}>
<img
src={`https://pipedream.com/s.v0/${singleValueProps.data.id}/logo/48`}
style={{
height: 24,
width: 24,
}}
alt={singleValueProps.data.name}
/>
<span style={{
whiteSpace: "nowrap",
}}>
{singleValueProps.data.name}
</span>
</div>
</SingleValue>
),
🧰 Tools
🪛 GitHub Check: Lint Code Base

[failure] 58-58:
Expected a line break after this opening brace


[failure] 58-58:
Object properties must go on a new line


[failure] 58-58:
Object properties must go on a new line


[failure] 58-58:
Expected a line break before this closing brace


[failure] 61-61:
Expected a line break after this opening brace


[failure] 61-61:
Object properties must go on a new line


[failure] 61-61:
Expected a line break before this closing brace


[failure] 64-64:
Expected a line break after this opening brace

IndicatorSeparator: () => null,
}}
options={apps || []}
getOptionLabel={(o) => o.name || o.name_slug} // TODO fetch initial value app so we show name
getOptionValue={(o) => o.name_slug}
value={value}
value={selectedValue}
onChange={(o) => onChange?.((o as AppResponse) || undefined)}
onInputChange={(v) => setQ(v)}
onInputChange={(v) => {
if(v) setQ(v)
}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve input change handler.

The current implementation might miss important input changes.

Apply this diff to handle empty string inputs:

-      onInputChange={(v) => {
-        if(v) setQ(v)
-      }}
+      onInputChange={(v) => setQ(v || "")}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
onInputChange={(v) => {
if(v) setQ(v)
}}
onInputChange={(v) => setQ(v || "")}

isLoading={isLoading}
/>
);
Expand Down
17 changes: 7 additions & 10 deletions packages/connect-react/src/components/SelectComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { useId } from "react";
import Select from "react-select";
import { useComponents } from "../hooks/use-components";
import {
AppResponse, V1Component,
} from "@pipedream/sdk";
import { AppResponse, V1Component } from "@pipedream/sdk";

type SelectComponentProps = {
app?: Partial<AppResponse> & { name_slug: string; };
Expand All @@ -19,23 +17,22 @@ export function SelectComponent({
onChange,
}: SelectComponentProps) {
const instanceId = useId();
const {
isLoading,
// TODO error
components,
} = useComponents({
const { isLoading, components } = useComponents({
app: app?.name_slug,
componentType,
});

const selectedValue = components?.find((c) => c.key === value?.key) || null;

return (
<Select
instanceId={instanceId}
className="react-select-container text-sm"
classNamePrefix="react-select"
options={components}
getOptionLabel={(o) => o.name || o.key} // TODO fetch default component so we show name (or just prime correctly in demo)
getOptionLabel={(o) => o.name || o.key}
getOptionValue={(o) => o.key}
value={value}
value={selectedValue}
onChange={(o) => onChange?.((o as V1Component) || undefined)}
isLoading={isLoading}
components={{
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-react/src/hooks/use-apps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export const useApps = (input?: GetAppsOpts) => {

return {
...query,
apps: query.data?.data,
apps: query.data?.data || [],
};
};
Loading