From 9eb59e0f435cd8141ffac3c575a3af07dba36edf Mon Sep 17 00:00:00 2001 From: hetangmodi-crest Date: Wed, 18 Sep 2024 18:10:49 +0530 Subject: [PATCH 1/5] fix: add isVisible attribute for add-ons --- docs/metadata.md | 1 + splunk_add_on_ucc_framework/commands/build.py | 7 ++++--- splunk_add_on_ucc_framework/schema/schema.json | 5 +++++ .../globalConfig.json | 3 ++- .../generators/conf_files/test_create_app_conf.py | 12 ++++++++---- ui/src/types/globalConfig/meta.ts | 2 ++ 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/docs/metadata.md b/docs/metadata.md index 57b51d947..93fa99725 100644 --- a/docs/metadata.md +++ b/docs/metadata.md @@ -20,3 +20,4 @@ Metadata contains general information about add-on build. | defaultView | string | Define which view should be loaded on TA load. One of `"inputs"`, `"configuration"`, `"dashboard"` or `"search"`. Default `configuration`. | | [os-dependentLibraries](./advanced/os-dependent_libraries.md) | array | This feature allows you to download and unpack libraries with appropriate binaries for the indicated operating system during the build process. | | supported_themes | array | This feature is allows you provide the themes supported by your add-on. Supported values: `light`, `dark`. No default. | +| isVisible | boolean | This option allows you to create apps which are not visible by default by setting isVisible=false. Default: true if globalConfig file exists in the repository, else false. | \ No newline at end of file diff --git a/splunk_add_on_ucc_framework/commands/build.py b/splunk_add_on_ucc_framework/commands/build.py index d1c2ccadc..a4b03112b 100644 --- a/splunk_add_on_ucc_framework/commands/build.py +++ b/splunk_add_on_ucc_framework/commands/build.py @@ -435,11 +435,9 @@ def generate( app_manifest = _get_app_manifest(source) ta_name = app_manifest.get_addon_name() generated_files = [] - ui_available = False gc_path = _get_and_check_global_config_path(source, config_path) if gc_path: - ui_available = True logger.info(f"Using globalConfig file located @ {gc_path}") global_config = global_config_lib.GlobalConfig(gc_path) # handle the update of globalConfig before validating @@ -506,7 +504,7 @@ def generate( addon_name=ta_name, app_manifest=app_manifest, addon_version=addon_version, - has_ui=ui_available, + has_ui=global_config.meta.get("is_visible", True), ) ) # TODO: all FILES GENERATED object: generated_files, use it for comparison @@ -600,6 +598,9 @@ def generate( f"Updated {app_manifest_lib.APP_MANIFEST_FILE_NAME} file in the output folder" ) + ui_available = False + if global_config: + ui_available = global_config.meta.get("is_visible", True) # NOTE: merging source and generated 'app.conf' as per previous design AppConf( global_config=global_config, diff --git a/splunk_add_on_ucc_framework/schema/schema.json b/splunk_add_on_ucc_framework/schema/schema.json index f59162c7c..cedd2e896 100644 --- a/splunk_add_on_ucc_framework/schema/schema.json +++ b/splunk_add_on_ucc_framework/schema/schema.json @@ -1827,6 +1827,11 @@ "type": "string", "enum": ["light", "dark"] } + }, + "isVisible": { + "type": "boolean", + "default": true, + "description": "Ability to configure app.conf->ui.is_visible from globalConfig file." } }, "required": ["displayName", "name", "restRoot", "version"], diff --git a/tests/testdata/test_addons/package_global_config_everything/globalConfig.json b/tests/testdata/test_addons/package_global_config_everything/globalConfig.json index 1bd01ef1e..c5fda0f7e 100644 --- a/tests/testdata/test_addons/package_global_config_everything/globalConfig.json +++ b/tests/testdata/test_addons/package_global_config_everything/globalConfig.json @@ -1558,6 +1558,7 @@ "supportedThemes": [ "light", "dark" - ] + ], + "isVisible": false } } diff --git a/tests/unit/generators/conf_files/test_create_app_conf.py b/tests/unit/generators/conf_files/test_create_app_conf.py index 50edcc25a..6e2f0d8ad 100644 --- a/tests/unit/generators/conf_files/test_create_app_conf.py +++ b/tests/unit/generators/conf_files/test_create_app_conf.py @@ -39,6 +39,10 @@ def addon_version(): def has_ui(): return True +@fixture +def has_ui_no_globalConfig(): + return False + @fixture def app_manifest(): @@ -60,7 +64,7 @@ def test_set_attributes_no_global_config_or_schema( ucc_dir, ta_name, addon_version, - has_ui, + has_ui_no_globalConfig, app_manifest, ): """Test _set_attributes when both _global_config and _gc_schema are None.""" @@ -71,14 +75,14 @@ def test_set_attributes_no_global_config_or_schema( ucc_dir=ucc_dir, addon_name=ta_name, addon_version=addon_version, - has_ui=has_ui, + has_ui=has_ui_no_globalConfig, app_manifest=app_manifest, ) app_conf._global_config = None app_conf._gc_schema = None app_conf._set_attributes( - addon_version=addon_version, has_ui=has_ui, app_manifest=app_manifest + addon_version=addon_version, has_ui=has_ui_no_globalConfig, app_manifest=app_manifest ) assert app_conf.conf_file == "app.conf" @@ -88,7 +92,7 @@ def test_set_attributes_no_global_config_or_schema( assert app_conf.id == app_conf._addon_name assert app_conf.supported_themes == "" assert app_conf.addon_version == addon_version - assert app_conf.is_visible == "true" + assert app_conf.is_visible == "false" assert app_conf.description == "Test Description" assert app_conf.author == "Test Author" assert app_conf.build == "1234" diff --git a/ui/src/types/globalConfig/meta.ts b/ui/src/types/globalConfig/meta.ts index d42acea0e..7fb429f6f 100644 --- a/ui/src/types/globalConfig/meta.ts +++ b/ui/src/types/globalConfig/meta.ts @@ -11,6 +11,8 @@ export const meta = z.object({ hideUCCVersion: z.boolean().optional(), checkForUpdates: z.boolean().default(true).optional(), searchViewDefault: z.boolean().default(false).optional(), + isVisible: z.boolean().default(true).optional(), + supportedThemes:z.array(z.string()).optional() }); export type meta = z.infer; From 64801e9768f2ca59e49158aea26f86d9d6c4de25 Mon Sep 17 00:00:00 2001 From: hetangmodi-crest Date: Wed, 18 Sep 2024 18:11:12 +0530 Subject: [PATCH 2/5] chore: fix lint failures --- docs/metadata.md | 2 +- tests/unit/generators/conf_files/test_create_app_conf.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/metadata.md b/docs/metadata.md index 93fa99725..7a93bcf83 100644 --- a/docs/metadata.md +++ b/docs/metadata.md @@ -20,4 +20,4 @@ Metadata contains general information about add-on build. | defaultView | string | Define which view should be loaded on TA load. One of `"inputs"`, `"configuration"`, `"dashboard"` or `"search"`. Default `configuration`. | | [os-dependentLibraries](./advanced/os-dependent_libraries.md) | array | This feature allows you to download and unpack libraries with appropriate binaries for the indicated operating system during the build process. | | supported_themes | array | This feature is allows you provide the themes supported by your add-on. Supported values: `light`, `dark`. No default. | -| isVisible | boolean | This option allows you to create apps which are not visible by default by setting isVisible=false. Default: true if globalConfig file exists in the repository, else false. | \ No newline at end of file +| isVisible | boolean | This option allows you to create apps which are not visible by default by setting isVisible=false. Default: true if globalConfig file exists in the repository, else false. | diff --git a/tests/unit/generators/conf_files/test_create_app_conf.py b/tests/unit/generators/conf_files/test_create_app_conf.py index 6e2f0d8ad..cc89988ff 100644 --- a/tests/unit/generators/conf_files/test_create_app_conf.py +++ b/tests/unit/generators/conf_files/test_create_app_conf.py @@ -39,7 +39,8 @@ def addon_version(): def has_ui(): return True -@fixture + +@fixture def has_ui_no_globalConfig(): return False @@ -82,7 +83,9 @@ def test_set_attributes_no_global_config_or_schema( app_conf._gc_schema = None app_conf._set_attributes( - addon_version=addon_version, has_ui=has_ui_no_globalConfig, app_manifest=app_manifest + addon_version=addon_version, + has_ui=has_ui_no_globalConfig, + app_manifest=app_manifest, ) assert app_conf.conf_file == "app.conf" From bf59f58c072063e4940f81262084f3b641834a49 Mon Sep 17 00:00:00 2001 From: hetangmodi-crest Date: Wed, 18 Sep 2024 18:27:18 +0530 Subject: [PATCH 3/5] chore:set is_visible attribute value to true --- .../package_global_config_everything/globalConfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testdata/test_addons/package_global_config_everything/globalConfig.json b/tests/testdata/test_addons/package_global_config_everything/globalConfig.json index c5fda0f7e..e894a211f 100644 --- a/tests/testdata/test_addons/package_global_config_everything/globalConfig.json +++ b/tests/testdata/test_addons/package_global_config_everything/globalConfig.json @@ -1559,6 +1559,6 @@ "light", "dark" ], - "isVisible": false + "isVisible": true } } From 6a7f499a8ba300c62111d7762b5f47d96ebc14aa Mon Sep 17 00:00:00 2001 From: hetangmodi-crest Date: Wed, 18 Sep 2024 18:56:47 +0530 Subject: [PATCH 4/5] chore: fix lint failure --- ui/src/types/globalConfig/meta.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/types/globalConfig/meta.ts b/ui/src/types/globalConfig/meta.ts index 7fb429f6f..cb59c91d8 100644 --- a/ui/src/types/globalConfig/meta.ts +++ b/ui/src/types/globalConfig/meta.ts @@ -12,7 +12,7 @@ export const meta = z.object({ checkForUpdates: z.boolean().default(true).optional(), searchViewDefault: z.boolean().default(false).optional(), isVisible: z.boolean().default(true).optional(), - supportedThemes:z.array(z.string()).optional() + supportedThemes: z.array(z.string()).optional(), }); export type meta = z.infer; From 870cc3c319cf13bcc27372a5f64539ed5699dd76 Mon Sep 17 00:00:00 2001 From: hetangmodi-crest Date: Tue, 24 Sep 2024 16:56:52 +0530 Subject: [PATCH 5/5] fix: typo of naming convention --- splunk_add_on_ucc_framework/commands/build.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/splunk_add_on_ucc_framework/commands/build.py b/splunk_add_on_ucc_framework/commands/build.py index a4b03112b..c1873b32b 100644 --- a/splunk_add_on_ucc_framework/commands/build.py +++ b/splunk_add_on_ucc_framework/commands/build.py @@ -504,7 +504,7 @@ def generate( addon_name=ta_name, app_manifest=app_manifest, addon_version=addon_version, - has_ui=global_config.meta.get("is_visible", True), + has_ui=global_config.meta.get("isVisible", True), ) ) # TODO: all FILES GENERATED object: generated_files, use it for comparison @@ -600,7 +600,7 @@ def generate( ui_available = False if global_config: - ui_available = global_config.meta.get("is_visible", True) + ui_available = global_config.meta.get("isVisible", True) # NOTE: merging source and generated 'app.conf' as per previous design AppConf( global_config=global_config,