-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added custom cell feature in the table and fixed sorting issue
- Loading branch information
1 parent
05f29f7
commit 3711846
Showing
7 changed files
with
157 additions
and
46 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
74 changes: 74 additions & 0 deletions
74
splunk_add_on_ucc_framework/ucc_ui_lib/src/main/webapp/components/CustomCell.jsx
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,74 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { getUnifiedConfigs } from '../util/util'; | ||
|
||
class CustomCell extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
loading: true, | ||
}; | ||
this.shouldRender = true; | ||
} | ||
|
||
componentDidMount() { | ||
const globalConfig = getUnifiedConfigs(); | ||
this.setState({ loading: true }); | ||
this.loadCustomControl().then((Control) => { | ||
const customControl = new Control( | ||
this.el, | ||
this.props.field, | ||
this.props.row, | ||
this.props.serviceName, | ||
globalConfig | ||
); | ||
customControl.render(); | ||
this.setState({ loading: false }); | ||
}); | ||
} | ||
|
||
shouldComponentUpdate(nextProps, nextState) { | ||
if (!nextState.loading && this.shouldRender) { | ||
this.shouldRender = false; | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
loadCustomControl = () => { | ||
const globalConfig = getUnifiedConfigs(); | ||
const appName = globalConfig.meta.name; | ||
return new Promise((resolve) => { | ||
__non_webpack_require__( | ||
[`app/${appName}/js/build/custom/${this.props.fileName}`], | ||
(Control) => resolve(Control) | ||
); | ||
}); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<> | ||
{this.state.loading && 'Loading...'} | ||
{ | ||
<span | ||
ref={(el) => { | ||
this.el = el; | ||
}} | ||
style={{ visibility: this.state.loading ? 'hidden' : 'visible' }} | ||
/> | ||
} | ||
</> | ||
); | ||
} | ||
} | ||
|
||
CustomCell.propTypes = { | ||
serviceName: PropTypes.string.isRequired, | ||
row: PropTypes.object.isRequired, | ||
field: PropTypes.string.isRequired, | ||
fileName: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default CustomCell; |
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