Skip to content

Commit

Permalink
feat: Added parsing and validation functionality for globalConfig.jso…
Browse files Browse the repository at this point in the history
…n file
  • Loading branch information
tbalar-splunk committed Mar 3, 2021
1 parent fdd6ba1 commit e690000
Show file tree
Hide file tree
Showing 9 changed files with 1,743 additions and 7 deletions.
4 changes: 3 additions & 1 deletion splunk_add_on_ucc_framework/ucc_ui_lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
"stylelint": "^13.0.0",
"webpack": "^4.16.2",
"webpack-cli": "^3.1.0",
"webpack-merge": "^4.1.3"
"webpack-merge": "^4.1.3",
"jsonschema": "^1.4.0",
"underscore": "^1.12.0"
},
"engines": {
"node": ">=6"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Button from '@splunk/react-ui/Button';
import { StyledContainer, StyledGreeting } from './TestComponentStyles';
import { getUnifiedConfigs } from '../util/util';

class TestComponent extends Component {
static propTypes = {
Expand All @@ -17,6 +18,10 @@ class TestComponent extends Component {
this.state = { counter: 0 };
}

componentDidMount() {
console.log("getUnifiedConfigs: ", getUnifiedConfigs());
}

render() {
const { name } = this.props;
const { counter } = this.state;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
export default {
/* validation messages, range [0, 99] */
0: 'Field {{args[0]}} is required',
1: 'Field {{args[0]}} must be a string',
2: '{{args[0]}} {{args[1]}} is already in use',
3: '"default", ".", "..", string started with "_" and string including any one of ["*", "\\", "[", "]", "(", ")", "?", ":"] are reserved value which cannot be used for field {{args[0]}}',
5: 'Field {{args[0]}} should be a positive number',
6: 'Field {{args[0]}} is required',
7: 'Field {{args[0]}} is not a valid regular expression',
8: 'Field {{args[0]}} should be within the range of [{{args[1]}} and {{args[2]}}]',
9: 'Field {{args[0]}} should be greater than or equal to {{args[1]}}',
10: 'Field {{args[0]}} should be less than or equal to {{args[1]}}',
11: '{{args[0]}} is not a function',
12: '{{args[0]}} is not a valid regular expression',
13: '{{args[0]}} is not a valid number range',
14: 'minLength cannot be greater than maxLength',
15: 'Field {{args[0]}} does not match regular expression {{args[1]}}',
16: 'Field {{args[0]}} is not a number',
17: 'Length of {{args[0]}} should be greater than or equal to {{args[1]}}',
18: 'Length of {{args[0]}} should be less than or equal to {{args[1]}}',
19: 'Field {{args[0]}} is not a valid {{args[1]}}',
20: 'configuration file should be pure JSON',
21: 'duplicate {{args[0]}} keys is not allowed',
22: 'Field {{args[0]}} must be less than 1024 characters',
23: '"name" feild must be provided for {{args[0]}} \'s entity in configuration file',

/* general messages, range [100, 499]*/
100: 'Create New Input',
// Delete dialog title
101: 'Delete Confirmation',
102: 'Are you sure you want to delete "{{args[0]}}" {{args[1]}}? Ensure that no input is configured with "{{args[0]}}" as this will stop data collection for that input.',
103: 'Are you sure you want to delete "{{args[0]}}" {{args[1]}}?',
// Error dialog title
104: 'Error Message',
// Warning dialog title
105: 'Warning',
// Input table filter label
106: 'Input Type',
// Configuration table count label
107: 'Items',
// Saving prompt message
108: 'Saving',
// Loading index error message
109: 'Failed to load index',
// Configuration file error
110: 'Internal configuration file error. Something wrong within the package or installation step. Contact your administrator for support. Detail: {{args[0]}}',
111: 'URL',
112: 'email address',
113: 'IPV4 address',
114: 'date in ISO 8601 format',
115: 'Loading',
// Page title
116: 'Inputs',
117: 'Configuration',

'__unknow__': 'An unknown error occurred'
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { SplunkThemeProvider } from '@splunk/themes';

import { defaultTheme } from '@splunk/splunk-utils/themes';

import ConfigManager from '../util/configManager';
import TestComponent from '../components/TestComponent';
import { StyledContainer, StyledGreeting } from './StartStyles';

Expand Down Expand Up @@ -38,9 +39,11 @@ if (page === 'inputs') {
layout(
<SplunkThemeProvider {...themeProviderSettings}>
<StyledContainer>
<StyledGreeting>Hello, from inside Inputs!</StyledGreeting>
<div>Your component will appear below.</div>
<TestComponent name="from inside TestComponent" />
<ConfigManager>
<StyledGreeting>Hello, from inside Inputs!</StyledGreeting>
<div>Your component will appear below.</div>
<TestComponent name="from inside TestComponent" />
</ConfigManager>
</StyledContainer>
</SplunkThemeProvider>,
{ pageTitle: 'Inputs' }
Expand All @@ -49,9 +52,11 @@ if (page === 'inputs') {
layout(
<SplunkThemeProvider {...themeProviderSettings}>
<StyledContainer>
<StyledGreeting>Hello, from inside Configuration!</StyledGreeting>
<div>Your component will appear below.</div>
<TestComponent name="from inside TestComponent" />
<ConfigManager>
<StyledGreeting>Hello, from inside Configuration!</StyledGreeting>
<div>Your component will appear below.</div>
<TestComponent name="from inside TestComponent" />
</ConfigManager>
</StyledContainer>
</SplunkThemeProvider>,
{ pageTitle: 'Configuration' }
Expand Down
Loading

0 comments on commit e690000

Please sign in to comment.