Skip to content
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

feat(custom_row): pass default row value to custom row component #1218

Merged
merged 13 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 20 additions & 34 deletions docs/custom_ui_extensions/custom_row.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@ When a row is expanded on the Inputs table, Custom Row is utilized to incorporat

### Properties

| Property | Description |
| ----------------- | ----------- |
| globalConfig | is a hierarchical object that contains the globalConfig file's properties and values. |
| el | is used to render a customized element on the Inputs table when a row is expanded. |
| serviceName | is the name of the service/tab specified in the globalConfig file. |
| row | it the object of the record for which the CustomRowInput constructor is called. |
| Property | Description |
| ------------ | ------------------------------------------------------------------------------------- |
| globalConfig | is a hierarchical object that contains the globalConfig file's properties and values. |
| el | is used to render a customized element on the Inputs table when a row is expanded. |
| serviceName | is the name of the service/tab specified in the globalConfig file. |
| row | is the object of the record for which the CustomRowInput constructor is called. |

### Methods

| Property | Description |
| ----------------- | ----------- |
| render | is a method which should have logic for the custom row component, and it will be executed automatically when the create, edit, or clone actions are performed. |
| Property | Description |
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| render | is a method which contains the logic to display the custom row component. This method is automatically executed when the row is expanded |
| getDLRows | is a method which contains the logic to update the custom row values, return a key-value pair. |

> Note

> - Atleast one method should be present
> - If both method is present then the getDLRows method have the high priority.

### Usage

Expand All @@ -35,34 +41,14 @@ When a row is expanded on the Inputs table, Custom Row is utilized to incorporat

### Example

```js
--8<-- "tests/testdata/test_addons/package_global_config_everything/package/appserver/static/js/build/custom/custom_input_row.js"
```
class CustomInputRow {
/**
* Custom Row Cell
* @constructor
* @param {Object} globalConfig - Global configuration.
* @param {string} serviceName - Input service name.
* @param {element} el - The element of the custom cell.
* @param {Object} row - custom row object.
*/
constructor(globalConfig, serviceName, el, row) {
this.globalConfig = globalConfig;
this.serviceName = serviceName;
this.el = el;
this.row = row;
}

render() {
const content_html_template = 'Custom Input Row';
this.el.innerHTML = content_html_template;
return this;
}
}

export default CustomInputRow;
```
> Note:

> Note: The Javascript file for the custom control should be saved in the custom folder at `appserver/static/js/build/custom/`.
> - The content should be included in the JavaScript file named by customRow.src property in globalConfig (see usage for details).
> - The Javascript file for the custom control should be saved in the custom folder at `appserver/static/js/build/custom/`.

### Output

Expand Down
Binary file modified docs/images/custom_ui_extensions/Custom_Row_Output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 31 additions & 30 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ markdown_extensions:
- sane_lists
- codehilite
- pymdownx.superfences
- pymdownx.snippets

theme:
name: "material"
Expand All @@ -26,58 +27,58 @@ theme:
- navigation.indexes

extra_css:
- css/extra.css
- css/extra.css

nav:
- Home: "index.md"
- Quickstart: "quickstart.md"
- ".conf files": "dot_conf_files.md"
- Inputs:
- "inputs/index.md"
- Introduction: "inputs/index.md"
- Tabs: "inputs/tabs.md"
- Multi-level Menu: "inputs/multilevel_menu.md"
- Helper Module: "inputs/helper.md"
- "inputs/index.md"
- Introduction: "inputs/index.md"
- Tabs: "inputs/tabs.md"
- Multi-level Menu: "inputs/multilevel_menu.md"
- Helper Module: "inputs/helper.md"
- Configuration:
- "configurations/index.md"
- Introduction: "configurations/index.md"
- Logging: "configurations/logging.md"
- Proxy: "configurations/proxy.md"
- Dashboard: "dashboard.md"
- Alert Actions:
- "alert_actions/index.md"
- Alert Action Scripts: "alert_actions/alert_scripts.md"
- Adaptive Response: "alert_actions/adaptive_response.md"
- "alert_actions/index.md"
- Alert Action Scripts: "alert_actions/alert_scripts.md"
- Adaptive Response: "alert_actions/adaptive_response.md"
- Entity:
- "entity/index.md"
- Introduction: "entity/index.md"
- Components: "entity/components.md"
- Validators: "entity/validators.md"
- Modify Fields On Change: "entity/modifyFieldsOnValue.md"
- "entity/index.md"
- Introduction: "entity/index.md"
- Components: "entity/components.md"
- Validators: "entity/validators.md"
- Modify Fields On Change: "entity/modifyFieldsOnValue.md"

- Table: "table.md"
- Additional packaging: "additional_packaging.md"
- UCC Ignore: "uccignore.md"
- OpenAPI: "openapi.md"
- UCC-related libraries: "ucc_related_libraries.md"
- Custom UI Extensions:
- Overview: "custom_ui_extensions/overview.md"
- Custom Hook: "custom_ui_extensions/custom_hook.md"
- Custom Control: "custom_ui_extensions/custom_control.md"
- Custom Row: "custom_ui_extensions/custom_row.md"
- Custom Cell: "custom_ui_extensions/custom_cell.md"
- Custom Menu: "custom_ui_extensions/custom_menu.md"
- Custom Tab: "custom_ui_extensions/custom_tab.md"
- Overview: "custom_ui_extensions/overview.md"
- Custom Hook: "custom_ui_extensions/custom_hook.md"
- Custom Control: "custom_ui_extensions/custom_control.md"
- Custom Row: "custom_ui_extensions/custom_row.md"
- Custom Cell: "custom_ui_extensions/custom_cell.md"
- Custom Menu: "custom_ui_extensions/custom_menu.md"
- Custom Tab: "custom_ui_extensions/custom_tab.md"
- Advanced:
- Custom Mapping: "advanced/custom_mapping.md"
- Dependent Dropdown: "advanced/dependent_dropdown.md"
- OAuth Support: "advanced/oauth_support.md"
- Custom REST Handler: "advanced/custom_rest_handler.md"
- Groups Feature: "advanced/groups_feature.md"
- Save Validator: "advanced/save_validator.md"
- OS-dependent libraries: "advanced/os-dependent_libraries.md"
- Sub Description: "advanced/sub_description.md"
- Custom Warning: "advanced/custom_warning.md"
- Custom Mapping: "advanced/custom_mapping.md"
- Dependent Dropdown: "advanced/dependent_dropdown.md"
- OAuth Support: "advanced/oauth_support.md"
- Custom REST Handler: "advanced/custom_rest_handler.md"
- Groups Feature: "advanced/groups_feature.md"
- Save Validator: "advanced/save_validator.md"
- OS-dependent libraries: "advanced/os-dependent_libraries.md"
- Sub Description: "advanced/sub_description.md"
- Custom Warning: "advanced/custom_warning.md"
- Troubleshooting: "troubleshooting.md"
- Contributing: "contributing.md"
- Changelog: "CHANGELOG.md"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,10 @@
"field": "disabled"
}
],
"customRow": {
"src": "custom_input_row",
"type": "external"
},
"moreInfo": [
{
"label": "Name",
Expand Down Expand Up @@ -1550,9 +1554,9 @@
"meta": {
"name": "Splunk_TA_UCCExample",
"restRoot": "splunk_ta_uccexample",
"version": "5.44.0R7f88cfdd",
"version": "5.45.0R08c37572",
"displayName": "Splunk UCC test Add-on",
"schemaVersion": "0.0.7",
"_uccVersion": "5.44.0"
"_uccVersion": "5.45.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class CustomInputRow {
/**
* Custom Row Cell
* @constructor
* @param {Object} globalConfig - Global configuration.
* @param {string} serviceName - Input service name.
* @param {element} el - The element of the custom cell.
* @param {Object} row - custom row object,
* use this.row.<field_name>, where <field_name> is a field name
*/
constructor(globalConfig, serviceName, el, row) {
this.globalConfig = globalConfig;
this.serviceName = serviceName;
this.el = el;
this.row = row;
}

getDLRows() {
return Object.fromEntries(
Object.entries(this.row).map(([key, value]) => [
key,
key === "interval" ? `${value} sec` : value,
])
);
}

render() {
rohanm-crest marked this conversation as resolved.
Show resolved Hide resolved
const content_html_template = "Custom Input Row";
this.el.innerHTML = content_html_template;
return this;
}
}

export default CustomInputRow;
8 changes: 7 additions & 1 deletion tests/ui/test_input_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,12 @@ def test_inputs_more_info(
):
"""Verifies the expand functionality of the inputs table"""
input_page = InputPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
interval = "90"
self.assert_util(
input_page.table.get_more_info,
{
"Name": "dummy_input_one",
"Interval": "90",
"Interval": f"{interval} sec",
"Index": "default",
"Status": "Enabled",
"Example Account": "test_input",
Expand All @@ -309,6 +310,11 @@ def test_inputs_more_info(
},
left_args={"name": "dummy_input_one"},
)
backend_stanza = input_page.backend_conf.get_stanza(
"example_input_one://dummy_input_one"
)
# we verify that the conf value is `interval` and only the UI has changed
assert backend_stanza.get("interval") == interval

@pytest.mark.execute_enterprise_cloud_true
@pytest.mark.forwarder
Expand Down
Loading
Loading