Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved the extendability of the SchemaView and DataGridView. #7876

Merged
merged 28 commits into from
Sep 9, 2024

Conversation

asheshv
Copy link
Contributor

@asheshv asheshv commented Aug 29, 2024

Restructured the SchemaView & DataGridView modules for ease of maintenance and applied the single responsibility principle (wherever is applicable).

SchemaView

  • Split the code based on the functionality, and responsibility.
  • Introduced a new View 'InlineView' instead of using the 'nextInline' configuration of the fields to have a better, and manageable code.
  • Using the separate class 'SchemaState' for managing the data and states of the SchemaView (separated from the 'useSchemaState' custom hook).
  • Introduced three new custom hooks 'useFieldValue', 'useFieldOptions', 'useFieldError' for the individual control to use for each Schema Field.
  • Don't pass value as the parameter props, and let the 'useFieldValue' and other custom hooks to decide, wheather to rerender the control itself or the whole dialog/view. (single responsibilty principle)
  • Introduced a new data store with subscription facility.
  • Moving the field metadata (option) evaluation to separate place for better management, and each option can be defined for a particular kind of field (for example - colleciton, row, cell, general, etc).
  • Allow to provide custom control for all kind of Schema field.

DataGridView

  • Same as SchemaView, split the DataGridView call in smaller and manageable chunks. (For example - grid, row, mappedCell, etc).
  • Use context based approach for providing the row and table data instead of passing them as parameter to each and every component separately.
  • Have a facility to extend this feature separately in future. (for example - selecatable cell, column grouping, etc.)
  • Separated the features like deletable, editable, reorder, expandable etc. cells using the above feature support.
  • Added ability to provide the CustomHeader, and CustomRow through the Schema field, which will extend the ability to customisation better.
  • Removed the 'DataGridViewWithHeaderForm' as it has been achieved through providing 'CustomHeader', and also introduced 'DataGridFormHeader' (a custom header) to achieve the same feature as 'DataGridViewWithHeaderForm'.

Also - Modified the test-cases to use separate 'Schema' objects during testing the rendering of create, edit, and properties views as BaseUISchema instance share the same SchemaState object.

Restructured these modules for ease of mainteance and apply the single
responsibilty principle (wherever is applicable).

* SchemaView

 - Split the code based on the functionality, and responsibility.
 - Introduced a new View 'InlineView' instead of using the
   'nextInline' configuration of the fields to have a better, and
   manageable view.
 - Using the separate class 'SchemaState' for managing the data and
   states of the SchemaView (separated from the 'useSchemaState'
   custom hook).
 - Introduced three new custom hooks 'useFieldValue',
   'useFieldOptions', 'useFieldError' for the individual control to
   use for each Schema Field.
 - Don't pass value as the parameter props, and let the
   'useFieldValue' and other custom hooks to decide, wheather to
   rerender the control itself or the whole dialog/view. (single
   responsibilty principle)
 - Introduced a new data store with subscription facility.
 - Moving the field metadata (option) evaluation to separate place
   for better management, and each option can be defined for a
   particular kind of field (for example - colleciton, row, cell,
   general, etc).
 - Allow to provide custom control for all kind of Schema field.

* DataGridView

 - Same as SchemaView, split the DataGridView call in smaller and
   manageable chunks. (For example - grid, row, mappedCell, etc).
 - Use context based approach for providing the row and table data
   instead of passing them as parameter to each and every component
   separately.
 - Have a facility to extend this feature separately in future.
   (for example - selecatable cell, column grouping, etc.)
 - Separated the features like deletable, editable, reorder,
   expandable etc. cells using the above feature support.
 - Added ability to provide the CustomHeader, and CustomRow through the
   Schema field, which will extend the ability to customisation better.
 - Removed the 'DataGridViewWithHeaderForm' as it has been achieved
   through providing 'CustomHeader', and also introduced
   'DataGridFormHeader' (a custom header) to achieve the same feature
   as 'DataGridViewWithHeaderForm'.

Also - Modified the testcases to use separate 'Schema' objects for
testing the rendering of create, edit, and properties mode as
BaseUISchema instance share the same SchemaState object.
@asheshv asheshv requested review from adityatoshniwal and removed request for adityatoshniwal August 29, 2024 18:41
the data.

I never realised that - we were using 'origData' for schema
validation to get the initial data, and replaced it with 'sessData'
variable by mistake. Changing it back to use 'origData' based on the
feedback from Aditya.
Copy link
Contributor

@adityatoshniwal adityatoshniwal left a comment

Choose a reason for hiding this comment

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

  1. Open an existing table and change column to PK. It crashes.
  2. Partitioned table properties tab is crashing, even on v8.11.
  3. Auto focus first input is not working.
  4. Go to security tab and add a row. Then select a grantee and click on privileges. Notice - it requires 2 clicks to open
image

@asheshv
Copy link
Contributor Author

asheshv commented Sep 3, 2024

  1. Open an existing table and change column to PK. It crashes.

We don't allow to change the PK for a column. Can you please share exact steps?

  1. Partitioned table properties tab is crashing, even on v8.11.

Fixed.

  1. Auto focus first input is not working.

Yet to work on it.

  1. Go to security tab and add a row. Then select a grantee and click on privileges. Notice - it requires 2 clicks to open

Not reproducible.

image

Yet to work on it.

@adityatoshniwal
Copy link
Contributor

Hi @asheshv,
Attaching screen recordings:

Trying to add column in existing table/or switch a column to PK where there is no PK.
https://github.com/user-attachments/assets/2efcd99f-be1a-43a5-9b2c-ff957afaac0d

In this, when grantee is changed, the 2 clicks are required to open privileges.
https://github.com/user-attachments/assets/fdcfee63-dfed-4979-b644-dc00150b08ab

@asheshv
Copy link
Contributor Author

asheshv commented Sep 3, 2024

Hi @asheshv, Attaching screen recordings:

Trying to add column in existing table/or switch a column to PK where there is no PK. https://github.com/user-attachments/assets/2efcd99f-be1a-43a5-9b2c-ff957afaac0d

So - it was failing while creating a table, and not existing table. :)
Fixed.

In this, when grantee is changed, the 2 clicks are required to open privileges. https://github.com/user-attachments/assets/fdcfee63-dfed-4979-b644-dc00150b08ab

Looking into it.

@adityatoshniwal
Copy link
Contributor

adityatoshniwal commented Sep 3, 2024

So - it was failing while creating a table, and not existing table. :) Fixed.

No, I'm adding column to existing table.

It was failing on new table as well.

@asheshv
Copy link
Contributor Author

asheshv commented Sep 3, 2024

In this, when grantee is changed, the 2 clicks are required to open privileges. https://github.com/user-attachments/assets/fdcfee63-dfed-4979-b644-dc00150b08ab

Looking into it.

Done!

@asheshv
Copy link
Contributor Author

asheshv commented Sep 3, 2024

@adityatoshniwal All issues are done. Please check now.

EDIT: There is one issue remaining - first element selection is not covered.

@adityatoshniwal
Copy link
Contributor

@adityatoshniwal All issues are done. Please check now.

EDIT: There is one issue remaining - first element selection is not covered.

I missed in the review last time - SchemaStateContext, SCHEMA_STATE_ACTIONS variables are duplicated in 2 files. Please remove that as well.

@asheshv
Copy link
Contributor Author

asheshv commented Sep 4, 2024

@adityatoshniwal All issues are done. Please check now.
EDIT: There is one issue remaining - first element selection is not covered.

I missed in the review last time - SchemaStateContext, SCHEMA_STATE_ACTIONS variables are duplicated in 2 files. Please remove that as well.

As discussed, this has already been taken care in this PR.

@asheshv
Copy link
Contributor Author

asheshv commented Sep 9, 2024

There is one issue remaining - first element selection is not covered.

Done.

@akshay-joshi akshay-joshi merged commit e9af0c3 into pgadmin-org:master Sep 9, 2024
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants