-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task/TUI-307 -- bug fixes tapis training (#308)
* Use undefined fields when adding new app args * remove undefined fields * Job Type * Consistent headings for job steps * Validate execution options with batch type jobs * Stringify non string values in description lists, allow useDetails for systems to specify request parameters * Refactor DescriptionListValue * Remove console statement * Refactor JSONDisplay * Refactor tabs, system detail tabs with json * Handle object keys that are Javascript Sets * Added permission checking to file toolbar * fix unit test * linting
- Loading branch information
1 parent
ac65e20
commit 8060c24
Showing
28 changed files
with
375 additions
and
136 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
export { default as Sidebar } from './Sidebar'; | ||
export { default as Tabs } from './Tabs'; |
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
File renamed without changes.
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,92 @@ | ||
import { useMemo, useState, useCallback } from 'react'; | ||
import { Input, FormGroup, Label } from 'reactstrap'; | ||
import { CopyButton } from 'tapis-ui/_common'; | ||
import styles from './JSONDisplay.module.scss'; | ||
|
||
const simplifyObject = (obj: any) => { | ||
const result = JSON.parse(JSON.stringify(obj)); | ||
Object.entries(result).forEach(([key, value]) => { | ||
if (Array.isArray(value)) { | ||
if ((value as Array<any>).length === 0) { | ||
delete result[key]; | ||
} | ||
return; | ||
} | ||
if (typeof value === 'object') { | ||
const simplifiedValue = simplifyObject(value); | ||
if (Object.entries(simplifiedValue).length === 0) { | ||
delete result[key]; | ||
} else { | ||
result[key] = simplifiedValue; | ||
} | ||
return; | ||
} | ||
if (value === undefined) { | ||
delete result[key]; | ||
} | ||
}); | ||
return result; | ||
}; | ||
|
||
const convertSets = (obj: any): any => { | ||
if (obj === undefined) { | ||
return undefined; | ||
} | ||
if (Array.isArray(obj)) { | ||
return (obj as Array<any>).map((value) => convertSets(value)); | ||
} | ||
if (obj instanceof Set) { | ||
return Array.from(obj).map((value) => convertSets(value)); | ||
} | ||
if (typeof obj === 'object') { | ||
const result: any = {}; | ||
Object.entries(obj).forEach(([key, value]) => { | ||
result[key] = convertSets(value); | ||
}); | ||
return result; | ||
} | ||
return JSON.parse(JSON.stringify(obj)); | ||
}; | ||
|
||
type JSONDisplayProps = { | ||
json: any; | ||
className?: string; | ||
}; | ||
|
||
const JSONDisplay: React.FC<JSONDisplayProps> = ({ json, className }) => { | ||
const [simplified, setSimplified] = useState(false); | ||
const onChange = useCallback(() => { | ||
setSimplified(!simplified); | ||
}, [setSimplified, simplified]); | ||
const jsonString = useMemo( | ||
() => | ||
JSON.stringify( | ||
simplified ? simplifyObject(convertSets(json)) : convertSets(json), | ||
null, | ||
2 | ||
), | ||
[json, simplified] | ||
); | ||
return ( | ||
<div className={className}> | ||
<div className={styles.controls}> | ||
<FormGroup check> | ||
<Label check size="sm" className={`form-field__label`}> | ||
<Input type="checkbox" onChange={onChange} /> | ||
Simplified | ||
</Label> | ||
</FormGroup> | ||
<CopyButton value={jsonString} /> | ||
</div> | ||
<Input | ||
type="textarea" | ||
value={jsonString} | ||
className={styles.json} | ||
rows="20" | ||
disabled={true} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default JSONDisplay; |
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,3 @@ | ||
import JSONDisplay from './JSONDisplay'; | ||
|
||
export default JSONDisplay; |
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,25 @@ | ||
.tab { | ||
border-top-left-radius: 3px; | ||
border-top-right-radius: 3px; | ||
border-top: 1px dotted var(--global-color-primary--dark); | ||
border-left: 1px dotted var(--global-color-primary--dark); | ||
border-bottom: 1px dotted var(--global-color-primary-dark); | ||
background-color: var(--global-color-primary--normal); | ||
a { | ||
color: var(--global-color-primary--xx-dark); | ||
height: 2.5em; | ||
font-size: 0.8em; | ||
} | ||
:hover { | ||
cursor: pointer; | ||
} | ||
margin-right: 2px; | ||
} | ||
|
||
.active { | ||
background-color: var(--global-color-primary--xx-light); | ||
} | ||
|
||
.pane { | ||
padding: 0.5em 0.5em 0.5em 0.5em; | ||
} |
Oops, something went wrong.