-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Digital Twin create and Library features (#1081)
- Refactors the classes interacting with gitlab so that the exploration of existing digital assets in a gitlab repository are possible - Adds library page which allows to browse existing assets in a gitlab repository and select them to create new digital twin - Adds feature to create digital twins from clean slate - Adds ability to create composite, fleet and hierarchical digital twins --------- Co-authored-by: vanessa <vanessascherma@gmail.com>
- Loading branch information
1 parent
510ebe2
commit 1b0e8d6
Showing
98 changed files
with
4,472 additions
and
1,329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import * as React from 'react'; | ||
import { Button } from '@mui/material'; | ||
import LibraryAsset from 'preview/util/libraryAsset'; | ||
import useCart from 'preview/store/CartAccess'; | ||
import { useSelector } from 'react-redux'; | ||
import { selectAssetByPathAndPrivacy } from 'preview/store/assets.slice'; | ||
|
||
interface AddToCartButtonProps { | ||
assetPath: string; | ||
assetPrivacy: boolean; | ||
} | ||
|
||
function AddToCartButton({ assetPath, assetPrivacy }: AddToCartButtonProps) { | ||
const { state: cartState, actions } = useCart(); | ||
const asset = useSelector( | ||
selectAssetByPathAndPrivacy(assetPath, assetPrivacy), | ||
) as LibraryAsset; | ||
|
||
const isInCart = cartState.assets.some( | ||
(item: LibraryAsset) => | ||
item.path === asset.path && item.isPrivate === asset.isPrivate, | ||
); | ||
|
||
const handleAddToCart = async () => { | ||
actions.add(asset); | ||
}; | ||
|
||
const handleRemoveFromCart = async () => { | ||
actions.remove(asset); | ||
}; | ||
|
||
return ( | ||
<Button | ||
variant="contained" | ||
size="small" | ||
color="primary" | ||
onClick={() => { | ||
if (isInCart) { | ||
handleRemoveFromCart(); | ||
} else { | ||
handleAddToCart(); | ||
} | ||
}} | ||
> | ||
{isInCart ? 'Remove' : 'Add'} | ||
</Button> | ||
); | ||
} | ||
|
||
export default AddToCartButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
import GitlabInstance from 'preview/util/gitlab'; | ||
|
||
export interface Asset { | ||
name: string; | ||
path: string; | ||
type: string; | ||
isPrivate: boolean; | ||
gitlabInstance?: GitlabInstance; | ||
fullDescription?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.