-
Notifications
You must be signed in to change notification settings - Fork 57
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 'Manage' tab to Digital Twins page preview #957
Changes from 1 commit
09ada15
cb4de3b
5e9edaa
32a9914
912a9f1
4818067
42299ae
c2773a8
42a714a
939e621
d75e747
d7ee4cc
413d396
4828566
a62b347
d957fbf
bae8bb7
fe2182f
5c12f3f
517ad1b
621775b
daebb10
78335aa
5ee7d39
c6a7644
dd7cc86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as React from 'react'; | ||
import { Dispatch, SetStateAction } from 'react'; | ||
import { Button } from '@mui/material'; | ||
|
||
interface DeleteButtonProps { | ||
setShowLog: Dispatch<React.SetStateAction<boolean>>; | ||
} | ||
|
||
const handleToggleLog = (setShowLog: Dispatch<SetStateAction<boolean>>) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The purpose of the function is unclear. The delete button is on Manage tab where there is no need for log dialogue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function has been renamed |
||
setShowLog(true); | ||
}; | ||
|
||
function DeleteButton({ setShowLog }: DeleteButtonProps) { | ||
return ( | ||
<Button | ||
variant="contained" | ||
size="small" | ||
color="primary" | ||
onClick={() => handleToggleLog(setShowLog)} | ||
> | ||
Delete | ||
</Button> | ||
); | ||
} | ||
|
||
export default DeleteButton; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import * as React from 'react'; | ||
import { Dispatch, SetStateAction } from 'react'; | ||
import { Button } from '@mui/material'; | ||
import { useSelector } from 'react-redux'; | ||
import { selectDigitalTwinByName } from '../../store/digitalTwin.slice'; | ||
import DigitalTwin from '../../util/gitlabDigitalTwin'; | ||
|
||
interface DialogButtonProps { | ||
assetName: string; | ||
setShowLog: Dispatch<React.SetStateAction<boolean>>; | ||
} | ||
|
||
export const handleToggleLog = async ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function has been renamed |
||
digitalTwin: DigitalTwin, | ||
setShowLog: Dispatch<SetStateAction<boolean>>, | ||
) => { | ||
await digitalTwin.getFullDescription(); | ||
setShowLog(true); | ||
}; | ||
|
||
function DetailsButton({ assetName, setShowLog }: DialogButtonProps) { | ||
const digitalTwin = useSelector(selectDigitalTwinByName(assetName)); | ||
return ( | ||
<Button | ||
variant="contained" | ||
size="small" | ||
color="primary" | ||
onClick={() => handleToggleLog(digitalTwin, setShowLog)} | ||
> | ||
Details | ||
</Button> | ||
); | ||
} | ||
|
||
export default DetailsButton; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as React from 'react'; | ||
import { Button } from '@mui/material'; | ||
import { Dispatch, SetStateAction } from 'react'; | ||
|
||
interface ReconfigureButtonProps { | ||
setShowReconfigure: Dispatch<SetStateAction<boolean>>; | ||
} | ||
|
||
const handleToggleReconfigure = ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Reconfigure button is never inactive. The original html page and all the related React components are active in the background. Is there a need to deactivate the Details button. Perhaps you intend to use this click action to show README in which case the code structure and names have to reflect that intention? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function has been changed into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, thanks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An updated message: "There is no README.md file for the hello-world digital twin" |
||
setShowReconfigure: Dispatch<SetStateAction<boolean>>, | ||
) => { | ||
setShowReconfigure((prev) => !prev); | ||
}; | ||
|
||
function ReconfigureButton({ setShowReconfigure }: ReconfigureButtonProps) { | ||
return ( | ||
<Button | ||
variant="contained" | ||
size="small" | ||
color="primary" | ||
onClick={() => handleToggleReconfigure(setShowReconfigure)} | ||
> | ||
Reconfigure | ||
</Button> | ||
); | ||
} | ||
|
||
export default ReconfigureButton; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import * as React from 'react'; | ||
import { useState } from 'react'; | ||
import { Box, Grid, Tabs, Tab } from '@mui/material'; | ||
// import { Resizable } from 'react-resizable'; | ||
import EditorTab from './EditorTab'; | ||
import PreviewTab from './PreviewTab'; | ||
import Sidebar from './Sidebar'; | ||
|
||
interface EditorProps { | ||
DTName: string; | ||
} | ||
|
||
function Editor({ DTName }: EditorProps) { | ||
const [activeTab, setActiveTab] = useState(0); | ||
const [fileName, setFileName] = useState(''); | ||
const [fileContent, setFileContent] = useState(''); | ||
const [fileType, setFileType] = useState(''); | ||
|
||
const handleTabChange = (event: React.SyntheticEvent, newValue: number) => { | ||
setActiveTab(newValue); | ||
}; | ||
|
||
return ( | ||
<Box sx={{ display: 'flex', height: '100%', width: '100%' }}> | ||
<Sidebar | ||
name={DTName} | ||
setFileName={setFileName} | ||
setFileContent={setFileContent} | ||
setFileType={setFileType} | ||
/> | ||
|
||
<Grid container direction="column" sx={{ flexGrow: 1, padding: 2 }}> | ||
<Tabs | ||
value={activeTab} | ||
onChange={handleTabChange} | ||
aria-label="editor preview tabs" | ||
> | ||
<Tab label="Editor" /> | ||
<Tab label="Preview" /> | ||
</Tabs> | ||
|
||
<Box | ||
sx={{ | ||
flexGrow: 1, | ||
padding: 2, | ||
border: '1px solid lightgray', | ||
marginTop: 2, | ||
}} | ||
> | ||
{activeTab === 0 && ( | ||
<EditorTab | ||
fileName={fileName} | ||
fileContent={fileContent} | ||
setFileContent={setFileContent} | ||
/> | ||
)} | ||
{activeTab === 1 && ( | ||
<PreviewTab fileContent={fileContent} fileType={fileType} /> | ||
)} | ||
</Box> | ||
</Grid> | ||
</Box> | ||
); | ||
} | ||
|
||
export default Editor; |
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.
There are also "details" and "reconfigure" buttons. Why are they treated differently from delete button?
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
onDelete
function is passed exclusively toAssetCardManage
, which includes the Delete button. This is because it is the only button that, in addition to having an API call viagitlabDigitalTwin
, must also modify the store via dispatch with thedeleteAsset
function.