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

Create insert panel for inserting instances and relations #48

Draft
wants to merge 29 commits into
base: master
Choose a base branch
from

Conversation

aematei
Copy link
Collaborator

@aematei aematei commented Mar 27, 2024

Checklist before submitting a merge request

Description of contribution

[Describe your contribution, link to any existing relevant issues]

Testing performed

  • I have added unit tests to cover additional functionality

How to Test Expected functionality changes

[Describe expected behaviour changes in steps]

  • I have added the steps needed to test these changes

Additional context

[If needed, you may add additional context]

…dense all possible buttons to keep the toolbar small.

Signed-off-by: Alex <[email protected]>
@aematei aematei marked this pull request as draft March 27, 2024 22:58

interface InsertItemProps {
label: string;
onItemClicked: () => void;
Copy link
Member

Choose a reason for hiding this comment

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

@aematei You may want to have a function called handleItemClicked. The code will be more reusable than arrow functions. This arrow function is anonymous so it may be hard to call the logic within the function in another part of the app.

Look at the official Typescript documentation and this Stack Overflow post for more details:

https://www.typescriptlang.org/docs/handbook/interfaces.html#function-types

https://stackoverflow.com/questions/45721344/arrow-function-in-typescript-interface-with-return-type-as-void

Copy link
Collaborator Author

@aematei aematei Apr 24, 2024

Choose a reason for hiding this comment

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

@pogi7 should I still include the function in the interface/type?

Copy link
Member

Choose a reason for hiding this comment

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

@aematei Yes. It would look like

interface InsertItemProps {
     label: string;
     onItemClicked: handleItemClicked
}

const handleItemClicked: void = () => {
     // you'll handle the logic of an item being clicked 
     console.log('Item Clicked');
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh got it! That makes sense, thanks.


export type InsertItem = {
label: string,
onItemClicked: () => void,
Copy link
Member

Choose a reason for hiding this comment

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

@aematei Please refer to my earlier comment regarding the arrow function
https://github.com/opencaesar/oml-vision/pull/48/files#r1574922754

@aematei aematei changed the title Create insert panel for inserting components and relationships Create insert panel for inserting instances and relations May 21, 2024
@aematei
Copy link
Collaborator Author

aematei commented May 23, 2024

Hey @pogi7, I noticed that the color of diagram nodes is specified in a model's components.json file. I want to access the value node in this file so that I can color the instances in the diagram insert panel. Do you know of a way I can access this value from Diagram.tsx? I did some digging but I'm having trouble finding it.

@pogi7
Copy link
Member

pogi7 commented May 23, 2024

Hey @pogi7, I noticed that the color of diagram nodes is specified in a model's components.json file. I want to access the value node in this file so that I can color the instances in the diagram insert panel. Do you know of a way I can access this value from Diagram.tsx? I did some digging but I'm having trouble finding it.

@aematei You may be able to access the color of the diagram nodes by accessing the background-color of the ref. You may be able to access the color of the diagram node by using React.useRef

Here's an example of using React.useRef in the code to find the font-size of the tableContainerRef ref (please refer to view/src/components/Table/Table.tsx L67 - L65):

const tableContainerRef = React.useRef<HTMLDivElement>(null);

// Set the Font Size
React.useEffect(() => {
  if (tableContainerRef.current) {
    tableContainerRef.current.style.setProperty("--font-size", `${fontSize}`);
  }
}, [fontSize]);

@aematei aematei self-assigned this Jun 28, 2024
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.

3 participants