-
Notifications
You must be signed in to change notification settings - Fork 29
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
Improve catalog properties modal tables #55
Conversation
Camel components: [1] - More information about API's are out of scope of this PR, API parameters have more methods with more properties, so the expendable rows with sub-rows needs to be implemented, at least with 3 level (apis->methods->methodParameters) ,, see AS2 or Twilio component => #60 |
694d527
to
8f788e3
Compare
72c9e9a
to
d6dc804
Compare
Can we put some blank space between the description of the component and the tabs for the properties tables? |
@lhein sure, I am currently working to add there also Enum and Autowired info |
9464b6a
to
5c3ea1c
Compare
5c3ea1c
to
5b0b23c
Compare
export const PropertiesModal: FunctionComponent<IPropertiesModalProps> = (props) => { | ||
let table: IPropertiesTable; | ||
let tabs: IPropertiesTab[] = []; | ||
switch (props.tile.type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing here is that it will make the calculations on every render. It would be more convenient to store the tabs
object using a useState
hook and then update it using a useEffect
that depends on props.tile.type
.
The idea would be more or less something like this:
const [tabs, setTabs] = useState<IPropertiesTab[]>([]);
useEffect(() => {
// switch logic goes here
// store the resulting calculation like
setTabs(CALCULATED_TABS_HERE);
}, [props.tile.type]);
Also, is worth mentioning that unless we plan to reuse the returning array, it would be more convenient (IMHO) to return an array from the function, rather than providing one from the outside.
let tabs: IPropertiesTab[] = [];
transformCamelComponentIntoTab(tabs, props.tile.rawObject as ICamelComponentDefinition);
// vs
const tabs = transformCamelComponentIntoTab(props.tile.rawObject as ICamelComponentDefinition);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tabs are in a different component, there is no re-render in the modal component However, of course, it can be some in the future so I will move it into useEffect() .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lordrip Isn't there better to use useCallback
/ useMemo
hooks in this case?
Because useEffect
is running only after the component is rendered, so, for the first time, the empty table is shown for a few milliseconds (because the table is null for the first rendering). [Also with opening a different camel component, for milliseconds, the table from the previous component is shown ]
In other words, in this case, the computation is needed before the first rendering.
e.g.
https://github.com/KaotoIO/kaoto-next/blob/0fa042ad24b9cd08126d25255e76b682ffbaf238/packages/ui/src/components/PropertiesModal/PropertiesModal.tsx#L20-L38
I have tried to re-render the modal component (via useState and button) and the switch computation is not running before the modal is open again ( with a different camel component ) so it is working correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, let's go with your approach then 💪
5b0b23c
to
0fa042a
Compare
0fa042a
to
438a4d6
Compare
getTableFromProperties
functions can be filtered byIPropertiesTableFilter = { filterKey: string; filterValue: string }
e.g. get only properties which have
kind="path"
, pass filter like this into functionprepareDataForTabs
function (lots of spaghetti code there, can be generalized or divided into small pieces)