Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[FEAT]: #1488 Add JS Query in the Query Library#1648

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
FalkWolsky merged 2 commits intolowcoder-org:devfromiamfaran:feature/1488-JSQuery
May 22, 2025
Merged
Show file tree
Hide file tree
Changes fromall 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
13 changes: 13 additions & 0 deletionsclient/packages/lowcoder/src/components/ResCreatePanel.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,6 +25,7 @@ import { getUser } from "../redux/selectors/usersSelectors";
import DataSourceIcon from "./DataSourceIcon";
import { genRandomKey } from "comps/utils/idGenerator";
import { isPublicApplication } from "@lowcoder-ee/redux/selectors/applicationSelector";
import { JS_CODE_ID } from "constants/datasourceConstants";

const Wrapper = styled.div<{ $placement: PageType }>`
width: 100%;
Expand DownExpand Up@@ -145,6 +146,7 @@ const ResButton = (props: {
type: BottomResTypeEnum.Query,
extra: {
compType: "js",
dataSourceId: JS_CODE_ID,
},
},
libraryQuery: {
Expand DownExpand Up@@ -320,6 +322,17 @@ export function ResCreatePanel(props: ResCreateModalProps) {
</div>
</>
)}

{placement === "queryLibrary" && (
<>
<div className="section-title">{trans("code")}</div>
<div className="section">
<DataSourceListWrapper $placement={placement}>
<ResButton size={buttonSize} identifier={"js"} onSelect={onSelect} />
</DataSourceListWrapper>
</div>
</>
)}

<div className="section-title">{trans("query.datasource")}</div>
<div className="section">
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,7 @@ import { isCompWithPropertyView } from "comps/utils/propertyUtils";
import {
QUICK_GRAPHQL_ID,
QUICK_REST_API_ID,
JS_CODE_ID
} from "constants/datasourceConstants";
import { PageType } from "constants/pageConstants";
import { trans } from "i18n";
Expand DownExpand Up@@ -795,7 +796,8 @@ function useDatasourceStatus(datasourceId: string, datasourceType: ResourceType)
datasourceType === "libraryQuery" ||
datasourceType === "alasql" ||
datasourceId === QUICK_REST_API_ID ||
datasourceId === QUICK_GRAPHQL_ID
datasourceId === QUICK_GRAPHQL_ID ||
datasourceId === JS_CODE_ID
) {
return "";
}
Expand Down
32 changes: 17 additions & 15 deletionsclient/packages/lowcoder/src/comps/queries/resourceDropdown.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@ import { DatasourceType, ResourceType } from "@lowcoder-ee/constants/queryConsta
import {
QUICK_GRAPHQL_ID,
QUICK_REST_API_ID,
JS_CODE_ID
} from "constants/datasourceConstants";
import {
apiPluginsForQueryLibrary,
Expand DownExpand Up@@ -78,7 +79,7 @@ interface ResourceOptionValue {
}

const JSOptionValue: ResourceOptionValue = {
id:"",
id:JS_CODE_ID,
type: "js",
};

Expand DownExpand Up@@ -156,6 +157,7 @@ export const ResourceDropdown = (props: ResourceDropdownProps) => {
const optionValue: ResourceOptionValue = JSON.parse(value);
const datasourceId = optionValue.id;
const datasourceType = optionValue.type;

if (!datasourceType) {
messageInstance.error("datasource invalid");
return;
Expand DownExpand Up@@ -293,19 +295,20 @@ export const ResourceDropdown = (props: ResourceDropdownProps) => {
</SelectOptionContains>
</SelectOption>

{context?.placement !== "queryLibrary" && (
<>
<SelectOption
key={JSON.stringify(JSOptionValue)}
label={trans("query.executeJSCode")}
value={JSON.stringify(JSOptionValue)}
>
<SelectOptionContains>
{getBottomResIcon("js")}
<SelectOptionLabel>{trans("query.executeJSCode")} </SelectOptionLabel>
</SelectOptionContains>
</SelectOption>
{/* Always show JS option regardless of placement */}
<SelectOption
key={JSON.stringify(JSOptionValue)}
label={trans("query.executeJSCode")}
value={JSON.stringify(JSOptionValue)}
>
<SelectOptionContains>
{getBottomResIcon("js")}
<SelectOptionLabel>{trans("query.executeJSCode")} </SelectOptionLabel>
</SelectOptionContains>
</SelectOption>

{/* Only show Library Query option when not in Query Library */}
{context?.placement !== "queryLibrary" && (
<SelectOption
key={JSON.stringify(LibraryQueryOptionValue)}
label={trans("query.importFromQueryLibrary")}
Expand All@@ -316,8 +319,7 @@ export const ResourceDropdown = (props: ResourceDropdownProps) => {
<SelectOptionLabel>{trans("query.importFromQueryLibrary")} </SelectOptionLabel>
</SelectOptionContains>
</SelectOption>
</>
)}
)}
</CustomSelect>
</SelectWrapper>
);
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -43,4 +43,5 @@ export interface Datasource {

export const QUICK_REST_API_ID = "#QUICK_REST_API";
export const QUICK_GRAPHQL_ID = "#QUICK_GRAPHQL";
export const JS_CODE_ID = "#JS_CODE";
export const OLD_LOWCODER_DATASOURCE: Partial<DatasourceType>[] = [];
Loading

[8]ページ先頭

©2009-2025 Movatter.jp