-
Notifications
You must be signed in to change notification settings - Fork 56
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
Add Create tab into Digital Twins page preview #1005
base: feature/distributed-demo
Are you sure you want to change the base?
Add Create tab into Digital Twins page preview #1005
Conversation
@VanessaScherma Thanks for the PR. A very top-level review. What works:
What does not work:
What are the suggested improvements:
|
Strange. I've created two new DTs, namely "new-dt" and "new-digital-twin". But they don't show up in Manage and Execute tabs.
Ok thanks
It is alright for now. Please focus on completing the PR. |
client/src/preview/route/digitaltwins/create/CreateDTDialog.tsx
Outdated
Show resolved
Hide resolved
client/src/preview/route/digitaltwins/create/CreateDTDialog.tsx
Outdated
Show resolved
Hide resolved
client/src/preview/route/digitaltwins/editor/sidebarFunctions.ts
Outdated
Show resolved
Hide resolved
client/src/preview/route/digitaltwins/editor/sidebarFunctions.ts
Outdated
Show resolved
Hide resolved
Code Climate has analyzed commit 28c38a7 and detected 3 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
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.
@VanessaScherma Thanks for the updates. Broader suggestions are:
- The Execute and Manage pages refer to default branch while the create page refers to the main branch. Please make the create page refer to the default branch as well.
- When the tab is changed, the execution status of the DTs is lost. If it is easily doable, please retain the execution status including the waiting loop icon. Otherwise, skip it for now.
- The execution fails for a newly created DT
- Suggested text for different tabs in
DigitalTwinTabDataPreview.ts
is:
Create: Create and save new digital twins. The new digital twins are saved in the linked gitlab repository. Remember to add valid `.gitlab-ci.yml` configuration as it is used for execution of digital twin.
Manage: Explore, edit and delete existing digital twins. The changes get saved in the linked gitlab repository.
Execute: Execute existing digital twins using CI/CD pipelines of the linked gitlab repository. Availability of gitlab runners is required for execution of digital twins.
In addition, please see the comments.
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.
This file requires significant reorganization. Perhaps it is better to split it into two independent files/modules.
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 file was split in this way:
Sidebar.tsx
: contains the Sidebar layout and the logic to manage the rendering of filesSidebarDialog.tsx
: contains the dialog for adding a new file
dispatch(setDigitalTwin({ assetName: asset.name, digitalTwin })); | ||
}); | ||
}; | ||
|
||
export const DTContent = () => { |
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.
This is only creating new DT. Can this intent be made more clear with a restructuring of code?
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 purpose of this file has remained unchanged, I have only added the necessary logic for the Create page (the useState newDigitalTwinName
) while I have moved the pre-existing logic in the function fetchAssetsAndCreateTwins
to the AssetBoard, as it no longer has to be called up only when the main component (DigitalTwinsPreview) is opened, but each time an AssetBoard is rendered, i.e. when switching to the Manage or Execute tabs. This is necessary in order to allow the new DT to be displayed immediately after creation by switching to one of the aforementioned tabs.
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 AssetBoard
is a react component. It is better to move the actual logic out of it.
const dispatch = useDispatch(); | ||
|
||
const gitlabInstance = new GitlabInstance( |
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.
This code has been moved from DigitalTwinsPreview.tsx
to here. The non-react part of code belongs to some file in preview/util
module.
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.
It has been moved to init.ts
in preview/util.
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.
File handling relates to operations on gitlab repo from frontend. Perhaps separating all the file handling operations into one module, say util/File.ts
helps with modularity of the code?
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.
Functions with file-related operations have been moved to file.ts
in preview/util
.
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 broader problem I see is this.
We need the user to forget the existence of gitlab but understand DT abstraction. In addition, user knows (rightly) that a DT consists of multiple files including configuration file(s). Thus we need to have a dedicated code for modifying files which can be accessed by DT class and if needed gitlab class. The code dependency graph I see is:
DigitalTwin (create, reconfigure, execute) ---> GitlabInstance (files, commits, jobs etc)
| |
|----> Files (create, update, delete) <-------------------|
The Files code can be in preview/utils/
@@ -12,28 +14,132 @@ const filesSlice = createSlice({ | |||
name: 'files', | |||
initialState, | |||
reducers: { | |||
addOrUpdateFile: (state, action: PayloadAction<FileState>) => { | |||
addNewFile: ( |
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.
Please remove duplication and restructure these three reducers.
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.
Done. Now there is only the addOrUpdateFile
reducer, capable to handle these three cases.
The correct dependency graph is: DigitalTwin (create, reconfigure, execute) ---> GitlabInstance (files, commits, jobs etc)
| ^
| |
|----> Files (create, update, delete) -------------------| You can create an interface IFiles and then have both GitlabInstance and Files implement this interface. |
The current code structure requires addition of child pipeline in parent pipeline. Thus each new DT created must have an entry in top-level .gitlab-ci.yml. Otherwise, the execution of new DTs fails. The solution is to have the create step has update the |
Title
Add Create tab into Digital Twins page preview
Type of Change
Description
PR with the aim of solving issue #1002.
When opening, the Create page shows the Editor and three files already placed in the sidebar:
description.md
README.md
.gitlab-ci.yml
The user can:
.gitlab-ci.yml
as it is necessary for the execution of the DT)By clicking on the ‘Create’ button, the user can enter the name of the DT, which will correspond to the name of the sub-folder within his GitLab digitaltwins folder, and confirm the operation.
At the end of the operation, the Snackbar informs of success or failure.
By switching to one of the other tabs, the DT is already visible.
Testing
Unit and integration tests are currently in progress.
Impact
These changes add a new functionality, allowing the user to insert new digital twins.
Additional Information
None.
Checklist
existing code.