diff --git a/docs/metadata.md b/docs/metadata.md index 4516390e3..227a3549d 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. | diff --git a/splunk_add_on_ucc_framework/commands/build.py b/splunk_add_on_ucc_framework/commands/build.py index d1c2ccadc..c1873b32b 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("isVisible", 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("isVisible", 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 d5b48b4f8..c28719383 100644 --- a/splunk_add_on_ucc_framework/schema/schema.json +++ b/splunk_add_on_ucc_framework/schema/schema.json @@ -1971,6 +1971,11 @@ "dark" ] } + }, + "isVisible": { + "type": "boolean", + "default": true, + "description": "Ability to configure app.conf->ui.is_visible from globalConfig file." } }, "required": [ 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 f2f30b427..0336f633a 100644 --- a/tests/testdata/test_addons/package_global_config_everything/globalConfig.json +++ b/tests/testdata/test_addons/package_global_config_everything/globalConfig.json @@ -1629,6 +1629,7 @@ "supportedThemes": [ "light", "dark" - ] + ], + "isVisible": true } } 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..cc89988ff 100644 --- a/tests/unit/generators/conf_files/test_create_app_conf.py +++ b/tests/unit/generators/conf_files/test_create_app_conf.py @@ -40,6 +40,11 @@ def has_ui(): return True +@fixture +def has_ui_no_globalConfig(): + return False + + @fixture def app_manifest(): mock_manifest = MagicMock() @@ -60,7 +65,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 +76,16 @@ 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 +95,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..cb59c91d8 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;