Skip to content

Commit

Permalink
Pass the reset key to 'FormView' from SchemaDialogView, and set the
Browse files Browse the repository at this point in the history
reset the tab only, when reset key is changed.
  • Loading branch information
asheshv committed Aug 30, 2024
1 parent 044931d commit ab2e467
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 21 deletions.
9 changes: 5 additions & 4 deletions web/pgadmin/static/js/SchemaView/FormView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const ErrorMessageBox = () => {
export default function FormView({
accessPath, schema=null, isNested=false, dataDispatch, className,
hasSQLTab, getSQLValue, isTabView=true, viewHelperProps, field,
showError=false
showError=false, resetKey
}) {
const [key, setKey] = useState(0);
const schemaState = useContext(SchemaStateContext);
Expand Down Expand Up @@ -104,10 +104,11 @@ export default function FormView({

// Upon reset, set the tab to first.
useEffect(() => {
if (!visible) return;
if (schemaState?.isReady)
if (!visible || !resetKey) return;
if (resetKey) {
setTabValue(0);
}, [schemaState?.isReady]);
}
}, [resetKey]);

const finalGroups = useMemo(
() => createFieldControls({
Expand Down
2 changes: 1 addition & 1 deletion web/pgadmin/static/js/SchemaView/SchemaDialogView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export default function SchemaDialogView({
hasSQLTab={props.hasSQL} getSQLValue={getSQLValue}
firstEleRef={firstEleRef} isTabView={isTabView}
className={props.formClassName}
showError={true}
showError={true} resetKey={props.resetKey}
/>
</Box>
{showFooter &&
Expand Down
2 changes: 1 addition & 1 deletion web/regression/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Python Tests:
'pgadmin4/web/pgadmin/utils/test.py' file.

- To run Feature Tests in parallel using selenoid(grid + docker), selenoid
need to be installed nad should be run only with SERVER_MODE=True.
need to be installed and should be run only with SERVER_MODE=True.
Steps to install selenoid -

- Install & Start docker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,11 @@ def _check_role_membership_control(self):
edit_object = self.wait.until(EC.visibility_of_element_located(
(By.CSS_SELECTOR, NavMenuLocators.edit_obj_css)))
edit_object.click()
membership_tab = WebDriverWait(self.page.driver, 4).until(
membership_tab = WebDriverWait(self.page.driver, 2).until(
EC.presence_of_element_located((
By.XPATH, "//button[normalize-space(text())='Membership']")))
membership_tab.click()

WebDriverWait(self.page.driver, 2).until(
EC.presence_of_element_located((
By.XPATH, "//div[contains(@class, 'pgrd-row-cell')]"))
)

# Fetch the source code for our custom control
source_code = self.page.find_by_xpath(
"//div[contains(@class, 'pgrd-row-cell')]"
Expand Down
26 changes: 17 additions & 9 deletions web/regression/feature_utils/pgadmin_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -1147,29 +1147,37 @@ def check_if_element_exists_with_scroll(self, xpath):
bottom_ele = self.driver.find_element(
By.XPATH,
"//div[@id='id-object-explorer']"
"/div/div/div/div/div[last()]")
bottom_ele_location = int(
bottom_ele.value_of_css_property('top').split("px")[0])
"/div/div/div/div/div/div[last()]")
bottom_ele_top = bottom_ele.value_of_css_property('top')
bottom_ele_location = 1

if (bottom_ele_top != 'auto'):
bottom_ele_location = int(
bottom_ele_top.split("px")[0]
)

if tree_height - bottom_ele_location < 25:
f_scroll = 0
f_scroll = bottom_ele_location - 25
else:
self.driver.execute_script(
self.js_executor_scrollintoview_arg, bottom_ele)
self.js_executor_scrollintoview_arg, bottom_ele
)
f_scroll -= 1
elif r_scroll > 0:
top_el = self.driver.find_element(
By.XPATH,
"//div[@id='id-object-explorer']"
"/div/div/div/div/div[1]")
top_el_location = int(
top_el.value_of_css_property('top').split("px")[0])
top_el_top = top_el.value_of_css_property('top')
top_el_location = 0

if (top_el_top != 'auto'):
top_el_location = int(top_el_top.split("px")[0])

if (tree_height - top_el_location) == tree_height:
r_scroll = 0
else:
webdriver.ActionChains(self.driver).move_to_element(
top_el).perform()
self.js_executor_scrollintoview_arg, top_el)
r_scroll -= 1
else:
break
Expand Down

0 comments on commit ab2e467

Please sign in to comment.