Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions app/client/src/components/ads/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ export function RenderDropdownOptions(props: DropdownOptionsProps) {
setOptions(filteredOptions);
onSearch && onSearch(searchStr);
};
return (
return options.length > 0 ? (
<DropdownWrapper
className="ads-dropdown-options-wrapper"
width={props.optionWidth || "260px"}
Expand Down Expand Up @@ -452,7 +452,7 @@ export function RenderDropdownOptions(props: DropdownOptionsProps) {
})}
</DropdownOptionsWrapper>
</DropdownWrapper>
);
) : null;
}

export default function Dropdown(props: DropdownProps) {
Expand Down Expand Up @@ -489,7 +489,7 @@ export default function Dropdown(props: DropdownProps) {
[onSelect],
);

const disabled = props.disabled || isLoading || !!errorMsg;
const disabled = props.disabled || isLoading;
const downIconColor = errorMsg ? Colors.POMEGRANATE2 : Colors.DARK_GRAY;

const dropdownHeight = props.height ? props.height : "38px";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function GeneratePageSubmitBtn({
data-cy="t--generate-page-form-submit"
disabled={disabled}
isLoading={isLoading}
onClick={onSubmit}
onClick={() => !disabled && onSubmit()}
size={Size.large}
text="Generate Page"
type="button"
Expand Down Expand Up @@ -195,6 +195,10 @@ function GeneratePageForm() {
DEFAULT_DROPDOWN_OPTION,
);

const [isSelectedTableEmpty, setIsSelectedTableEmpty] = useState<boolean>(
false,
);

const selectedDatasourcePluginId: string = selectedDatasource.data?.pluginId;
const selectedDatasourcePluginPackageName: string =
generateCRUDSupportedPlugin[selectedDatasourcePluginId];
Expand Down Expand Up @@ -296,24 +300,26 @@ function GeneratePageForm() {
const { data } = TableObj;

if (Array.isArray(data.columns)) {
const newSelectedTableColumnOptions: DropdownOption[] = [];
data.columns.map((column) => {
if (
column.type &&
ALLOWED_SEARCH_DATATYPE.includes(column.type.toLowerCase())
) {
newSelectedTableColumnOptions.push({
id: column.name,
label: column.name,
value: column.name,
subText: column.type,
icon: columnIcon,
iconSize: IconSize.LARGE,
iconColor: Colors.GOLD,
});
}
});
if (newSelectedTableColumnOptions) {
if (data.columns.length === 0) setIsSelectedTableEmpty(true);
else {
if (isSelectedTableEmpty) setIsSelectedTableEmpty(false);
const newSelectedTableColumnOptions: DropdownOption[] = [];
data.columns.map((column) => {
if (
column.type &&
ALLOWED_SEARCH_DATATYPE.includes(column.type.toLowerCase())
) {
newSelectedTableColumnOptions.push({
id: column.name,
label: column.name,
value: column.name,
subText: column.type,
icon: columnIcon,
iconSize: IconSize.LARGE,
iconColor: Colors.GOLD,
});
}
});
setSelectedTableColumnOptions(newSelectedTableColumnOptions);
}
} else {
Expand All @@ -323,9 +329,11 @@ function GeneratePageForm() {
}
},
[
isSelectedTableEmpty,
selectTable,
setSelectedTableColumnOptions,
selectColumn,
setIsSelectedTableEmpty,
isGoogleSheetPlugin,
isS3Plugin,
],
Expand Down Expand Up @@ -375,7 +383,7 @@ function GeneratePageForm() {
selectedDatasource.value &&
!isFetchingDatasourceStructure
) {
// On finished fetching datasource structure
// when finished fetching datasource structure
const selectedDatasourceStructure =
datasourcesStructure[selectedDatasource.id] || {};

Expand Down Expand Up @@ -513,7 +521,6 @@ function GeneratePageForm() {
history.push(redirectURL);
};

const submitButtonDisable = !selectedTable.value;
// if the datasource has basic information to connect to db it is considered as a valid structure hence isValid true.
const isValidDatasourceConfig = selectedDatasource.data?.isValid;

Expand Down Expand Up @@ -546,6 +553,9 @@ function GeneratePageForm() {
if (fetchingDatasourceConfigError) {
tableDropdownErrorMsg = `Failed fetching datasource structure, Please check your datasource configuration`;
}
if (isSelectedTableEmpty) {
tableDropdownErrorMsg = `Couldn't find any columns, Please select table with columns.`;
}
}

const showEditDatasourceBtn =
Expand All @@ -557,11 +567,16 @@ function GeneratePageForm() {
!!selectedTable.value &&
PLUGIN_PACKAGE_NAME.S3 !== selectedDatasourcePluginPackageName;

const showSubmitButton = selectedTable.value && !showEditDatasourceBtn;
!fetchingDatasourceConfigs &&
fetchingDatasourceConfigError &&
const showSubmitButton =
selectedTable.value &&
!showEditDatasourceBtn &&
!fetchingDatasourceConfigs &&
!fetchingDatasourceConfigError &&
!!selectedDatasource.value;

const submitButtonDisable =
!selectedTable.value || !showSubmitButton || isSelectedTableEmpty;

return (
<div>
<Wrapper>
Expand Down