Skip to content

Commit bfa8890

Browse files
Merge branch 'release' of github.com:appsmithorg/appsmith into fix/edit-button-copy-text
2 parents 2ccd395 + bda1aa4 commit bfa8890

File tree

9 files changed

+475
-31
lines changed

9 files changed

+475
-31
lines changed

app/client/src/WidgetQueryGenerators/Snowflake/index.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { DatasourceConnectionMode } from "entities/Datasource";
22
import Snowflake from ".";
3+
import { SSLType } from "entities/Datasource/RestAPIForm";
34

45
describe("Snowflake WidgetQueryGenerator", () => {
56
const initialValues = {
@@ -367,4 +368,36 @@ OFFSET
367368
},
368369
]);
369370
});
371+
372+
test("should return provided connection mode when available", () => {
373+
const datasourceConfiguration = {
374+
connection: {
375+
mode: DatasourceConnectionMode.READ_ONLY,
376+
ssl: {
377+
authType: SSLType.DEFAULT,
378+
authTypeControl: false,
379+
certificateFile: {
380+
name: "",
381+
base64Content: "",
382+
},
383+
},
384+
},
385+
url: "https://example.com",
386+
};
387+
388+
const connectionMode = Snowflake.getConnectionMode(datasourceConfiguration);
389+
390+
expect(connectionMode).toEqual(DatasourceConnectionMode.READ_ONLY);
391+
});
392+
393+
test("should return READ_WRITE as default when no connection mode is provided", () => {
394+
const datasourceConfiguration = {
395+
// No connection mode specified
396+
url: "https://example.com",
397+
};
398+
399+
const connectionMode = Snowflake.getConnectionMode(datasourceConfiguration);
400+
401+
expect(connectionMode).toEqual(DatasourceConnectionMode.READ_WRITE);
402+
});
370403
});

app/client/src/WidgetQueryGenerators/Snowflake/index.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
import { BaseQueryGenerator } from "../BaseQueryGenerator";
1+
import {
2+
DatasourceConnectionMode,
3+
type DatasourceStorage,
4+
} from "entities/Datasource";
5+
import { without } from "lodash";
26
import { formatDialect, snowflake } from "sql-formatter";
3-
import { QUERY_TYPE } from "../types";
7+
import { removeSpecialChars } from "utils/helpers";
8+
import { BaseQueryGenerator } from "../BaseQueryGenerator";
49
import type {
10+
ActionConfigurationSQL,
511
WidgetQueryGenerationConfig,
612
WidgetQueryGenerationFormConfig,
7-
ActionConfigurationSQL,
813
} from "../types";
9-
import { removeSpecialChars } from "utils/helpers";
10-
import { without } from "lodash";
11-
import { DatasourceConnectionMode } from "entities/Datasource";
14+
import { QUERY_TYPE } from "../types";
1215

1316
export default abstract class Snowflake extends BaseQueryGenerator {
1417
private static buildSelect(
@@ -249,4 +252,13 @@ export default abstract class Snowflake extends BaseQueryGenerator {
249252
static getTotalRecordExpression(binding: string) {
250253
return `${binding}[0].count`;
251254
}
255+
256+
static getConnectionMode(
257+
datasourceConfiguration: DatasourceStorage["datasourceConfiguration"],
258+
) {
259+
return (
260+
datasourceConfiguration?.connection?.mode ||
261+
DatasourceConnectionMode.READ_WRITE
262+
);
263+
}
252264
}

app/client/src/components/editorComponents/WidgetQueryGeneratorForm/CommonControls/DatasourceDropdown/DropdownOption.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,42 @@ const IconContainer = styled.div`
2222
align-items: center;
2323
`;
2424

25-
const Label = styled.div`
25+
const LabelContainer = styled.div`
2626
width: calc(100% - 40px);
27+
display: flex;
28+
flex-direction: column;
29+
justify-content: center;
30+
`;
31+
32+
const Label = styled.div`
2733
overflow: hidden;
2834
text-overflow: ellipsis;
2935
`;
3036

37+
const SubText = styled.span`
38+
font-size: 12px;
39+
color: var(--ads-v2-color-fg-muted);
40+
`;
41+
3142
interface Props {
43+
className?: string;
3244
label?: JSX.Element | string;
3345
leftIcon?: JSX.Element;
3446
rightIcon?: JSX.Element;
35-
className?: string;
47+
subText?: string;
3648
}
3749

3850
export function DropdownOption(props: Props) {
39-
const { className, label, leftIcon, rightIcon } = props;
51+
const { className, label, leftIcon, rightIcon, subText } = props;
4052

4153
return (
4254
<Container className={className}>
4355
<LeftSection>
4456
{leftIcon && <IconContainer>{leftIcon}</IconContainer>}
45-
<Label>{label}</Label>
57+
<LabelContainer>
58+
<Label>{label}</Label>
59+
{subText && <SubText>{subText}</SubText>}
60+
</LabelContainer>
4661
</LeftSection>
4762
{rightIcon && <IconContainer>{rightIcon}</IconContainer>}
4863
</Container>

app/client/src/components/editorComponents/WidgetQueryGeneratorForm/CommonControls/TableOrSpreadsheetDropdown/index.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
import React, { memo, useContext } from "react";
2-
import { ErrorMessage, Label, LabelWrapper, SelectWrapper } from "../../styles";
2+
import {
3+
ErrorMessage,
4+
Label,
5+
LabelWrapper,
6+
PrimaryKeysMessage,
7+
SelectWrapper,
8+
} from "../../styles";
39
import { useTableOrSpreadsheet } from "./useTableOrSpreadsheet";
410
import { Select, Option, Tooltip } from "@appsmith/ads";
511
import { DropdownOption } from "../DatasourceDropdown/DropdownOption";
612
import type { DefaultOptionType } from "rc-select/lib/Select";
713
import { ColumnSelectorModal } from "../ColumnSelectorModal";
814
import { WidgetQueryGeneratorFormContext } from "components/editorComponents/WidgetQueryGeneratorForm/index";
15+
import { createMessage } from "ee/constants/messages";
16+
import { NO_PRIMARY_KEYS_MESSAGE, PRIMARY_KEYS_MESSAGE } from "../../constants";
917

1018
function TableOrSpreadsheetDropdown() {
1119
const {
@@ -55,17 +63,29 @@ function TableOrSpreadsheetDropdown() {
5563
return (
5664
<Option
5765
data-testid="t--one-click-binding-table-selector--table"
66+
disabled={option.disabled}
5867
key={option.id}
5968
value={option.value}
6069
>
61-
<DropdownOption label={option.label} />
70+
<DropdownOption
71+
label={option.label}
72+
subText={
73+
option.disabled
74+
? createMessage(NO_PRIMARY_KEYS_MESSAGE)
75+
: undefined
76+
}
77+
/>
6278
</Option>
6379
);
6480
})}
6581
</Select>
6682
<ErrorMessage data-testid="t--one-click-binding-table-selector--error">
6783
{error}
6884
</ErrorMessage>
85+
86+
<PrimaryKeysMessage>
87+
{createMessage(PRIMARY_KEYS_MESSAGE)}
88+
</PrimaryKeysMessage>
6989
</SelectWrapper>
7090
);
7191
} else {

0 commit comments

Comments
 (0)