diff --git a/packages/adp-flp-config-sub-generator/src/app/index.ts b/packages/adp-flp-config-sub-generator/src/app/index.ts index c39c03dd6e5..230f28fcaf7 100644 --- a/packages/adp-flp-config-sub-generator/src/app/index.ts +++ b/packages/adp-flp-config-sub-generator/src/app/index.ts @@ -1,7 +1,7 @@ import type { FlpConfigOptions } from './types'; import type { Question } from 'inquirer'; import Generator from 'yeoman-generator'; -import path, { join } from 'node:path'; +import { join, basename } from 'node:path'; import { type AxiosError, type AbapServiceProvider, isAxiosError } from '@sap-ux/axios-extension'; import { getVariant, @@ -23,9 +23,11 @@ import { getAdpFlpInboundsWriterConfig, getTileSettingsQuestions, type FLPConfigAnswers, - type TileSettingsAnswers + type TileSettingsAnswers, + tileActions, + tilePromptNames } from '@sap-ux/flp-config-inquirer'; -import { AppWizard, Prompts, MessageType } from '@sap-devx/yeoman-ui-types'; +import { AppWizard, Prompts, MessageType, type IPrompt } from '@sap-devx/yeoman-ui-types'; import { DefaultLogger, TelemetryHelper, @@ -106,8 +108,6 @@ export default class AdpFlpConfigGenerator extends Generator { (this.env as unknown as YeomanEnvironment).conflicter.force = this.options.force ?? true; } - this._setupFLPConfigPage(); - if (!this.launchAsSubGen) { await this._initializeStandAloneGenerator(); if (this.abort || this.authenticationRequired) { @@ -143,6 +143,10 @@ export default class AdpFlpConfigGenerator extends Generator { } this.tileSettingsAnswers = await this._promptTileActions(); + if (this.tileSettingsAnswers?.[tilePromptNames.tileHandlingAction] === tileActions.REPLACE) { + return; + } + const prompts: Question[] = await getPrompts( this.inbounds, getAdpFlpConfigPromptOptions(this.tileSettingsAnswers as TileSettingsAnswers, this.inbounds, this.variant) @@ -158,9 +162,10 @@ export default class AdpFlpConfigGenerator extends Generator { const config = getAdpFlpInboundsWriterConfig( this.answers, this.layer, - this.tileSettingsAnswers as TileSettingsAnswers + this.tileSettingsAnswers as TileSettingsAnswers, + this.inbounds ); - await generateInboundConfig(this.projectRootPath, config as InternalInboundNavigation, this.fs); + await generateInboundConfig(this.projectRootPath, config as InternalInboundNavigation[], this.fs); } catch (error) { this.logger.error(`Writing phase failed: ${error}`); throw new Error(t('error.updatingApp')); @@ -258,11 +263,14 @@ export default class AdpFlpConfigGenerator extends Generator { * Adds navigations steps and callback function for the generator prompts. */ private _setupFLPConfigPage(): void { + const pages: IPrompt[] = this.prompts['items']; + const tileSettingsPageIndex = pages.findIndex((p) => p.name === t('yuiNavSteps.tileSettingsName')); + // if launched as a sub-generator, the navigation steps will be set by the parent generator if (!this.launchAsSubGen) { - this.prompts.splice(0, 0, [ + this.prompts.splice(tileSettingsPageIndex + 1, 0, [ { - name: t('yuiNavSteps.flpConfigName', { projectName: path.basename(this.projectRootPath) }), + name: t('yuiNavSteps.flpConfigName'), description: '' } ]); @@ -275,7 +283,14 @@ export default class AdpFlpConfigGenerator extends Generator { private _setupFLPConfigPrompts(): void { // If launched as a sub-generator, the prompts will be set by the parent generator if (!this.launchAsSubGen) { - this.prompts = new Prompts([]); + this.prompts = new Prompts([ + { + name: t('yuiNavSteps.tileSettingsName'), + description: t('yuiNavSteps.tileSettingsDescr', { + projectName: basename(this.projectRootPath) + }) + } + ]); this.setPromptsCallback = (fn): void => { if (this.prompts) { this.prompts.setCallback(fn); @@ -367,33 +382,34 @@ export default class AdpFlpConfigGenerator extends Generator { if (!this.inbounds) { return undefined; } - this._setTileSettingsPrompts(); const existingFlpConfig = !this.launchAsSubGen && flpConfigurationExists(this.variant); const promptOptions = { existingFlpConfigInfo: { hide: !existingFlpConfig } }; - const tileSettingsPrompts = getTileSettingsQuestions(promptOptions); - return this.prompt(tileSettingsPrompts); - } + const tileSettingsPrompts = getTileSettingsQuestions(this.inbounds, promptOptions, async (answer) => { + if (!answer) { + return true; + } - /** - * Sets the tile settings prompts based on the current state of the generator. - */ - private _setTileSettingsPrompts(): void { - if (this.launchAsSubGen) { - return; - } - const promptsIndex = this.prompts.size() === 1 ? 0 : 1; - this.prompts.splice(promptsIndex, 0, [ - { - name: t('yuiNavSteps.tileSettingsName'), - description: t('yuiNavSteps.tileSettingsDescr', { - projectName: path.basename(this.projectRootPath) - }) + const pages: IPrompt[] = this.prompts['items']; + const hasExistingFlpConfigPage = pages.some((p) => p.name === t('yuiNavSteps.flpConfigName')); + + if (answer === tileActions.ADD && !hasExistingFlpConfigPage) { + this._setupFLPConfigPage(); + return true; } - ]); + + if (!hasExistingFlpConfigPage) { + return true; + } + + this.prompts.splice(this.prompts.size() - 1, 1, []); + return true; + }); + + return this.prompt(tileSettingsPrompts); } /** diff --git a/packages/adp-tooling/src/writer/inbound-navigation.ts b/packages/adp-tooling/src/writer/inbound-navigation.ts index c1acb12e90e..bb3b0e47f3a 100644 --- a/packages/adp-tooling/src/writer/inbound-navigation.ts +++ b/packages/adp-tooling/src/writer/inbound-navigation.ts @@ -12,13 +12,13 @@ import { enhanceManifestChangeContentWithFlpConfig as enhanceInboundConfig } fro * Generates and writes the inbound configuration to the manifest.appdescr_variant file. * * @param basePath - The base path of the project. - * @param config - The inbound configuration properties. + * @param configs - The inbound configuration properties. * @param fs - Optional mem-fs editor instance. * @returns The mem-fs editor instance. */ export async function generateInboundConfig( basePath: string, - config: InternalInboundNavigation, + configs: InternalInboundNavigation[], fs?: Editor ): Promise { if (!fs) { @@ -29,14 +29,17 @@ export async function generateInboundConfig( variant.content = removeInboundChangeTypes(variant.content); - if (!config?.inboundId) { - config.inboundId = `${variant.id}.InboundID`; - } + // Set default inbound IDs if missing + configs.forEach((config) => { + if (!config?.inboundId) { + config.inboundId = `${variant.id}.InboundID`; + } + }); - enhanceInboundConfig(config, variant.id, variant.content as Content[]); + enhanceInboundConfig(configs, variant.id, variant.content as Content[]); await updateVariant(basePath, variant, fs); - await updateI18n(basePath, variant.id, config, fs); + await updateI18n(basePath, variant.id, configs, fs); return fs; } @@ -73,17 +76,20 @@ export function getFlpI18nKeys(config: InternalInboundNavigation, appId: string) * * @param {string} basePath - The base path of the project. * @param {string} appId - The application ID used to generate i18n keys. - * @param {InternalInboundNavigation} config - The inbound configuration properties. + * @param {InternalInboundNavigation[]} configs - The inbound configuration properties. * @param {Editor} fs - The mem-fs editor instance for file operations. * @returns {Promise} A promise that resolves when the i18n file is updated. */ export async function updateI18n( basePath: string, appId: string, - config: InternalInboundNavigation, + configs: InternalInboundNavigation[], fs: Editor ): Promise { - const newEntries = getFlpI18nKeys(config, appId); + let newEntries: NewI18nEntry[] = []; + configs.forEach((config) => { + newEntries = newEntries.concat(getFlpI18nKeys(config, appId)); + }); const i18nPath = path.join(basePath, 'webapp', 'i18n', 'i18n.properties'); const keysToRemove = [`${appId}_sap.app.crossNavigation.inbounds`]; await removeAndCreateI18nEntries(i18nPath, newEntries, keysToRemove, basePath, fs); diff --git a/packages/adp-tooling/src/writer/index.ts b/packages/adp-tooling/src/writer/index.ts index 4e44205761e..5300a4d6629 100644 --- a/packages/adp-tooling/src/writer/index.ts +++ b/packages/adp-tooling/src/writer/index.ts @@ -51,11 +51,8 @@ function setDefaults(config: AdpWriterConfig): AdpWriterConfig { } if (configWithDefaults.customConfig?.adp.environment === 'C' && configWithDefaults.flp) { - enhanceManifestChangeContentWithFlpConfig( - configWithDefaults.flp as InternalInboundNavigation, - configWithDefaults.app.id, - configWithDefaults.app.content - ); + const configs = [configWithDefaults.flp]; + enhanceManifestChangeContentWithFlpConfig(configs, configWithDefaults.app.id, configWithDefaults.app.content); } return configWithDefaults; diff --git a/packages/adp-tooling/src/writer/options.ts b/packages/adp-tooling/src/writer/options.ts index 561af2f5447..37f4df4b2cf 100644 --- a/packages/adp-tooling/src/writer/options.ts +++ b/packages/adp-tooling/src/writer/options.ts @@ -305,17 +305,20 @@ function getInboundChangeContentWithNewInboundID( /** * Generate Inbound change content required for manifest.appdescriptor. * - * @param flpConfiguration FLP cloud project configuration + * @param flpConfigurations FLP cloud project configuration * @param appId Application variant id * @param manifestChangeContent Application variant change content */ export function enhanceManifestChangeContentWithFlpConfig( - flpConfiguration: InternalInboundNavigation, + flpConfigurations: InternalInboundNavigation[], appId: string, manifestChangeContent: Content[] = [] ): void { - const inboundChangeContent = getInboundChangeContentWithNewInboundID(flpConfiguration, appId); - if (inboundChangeContent) { + flpConfigurations.forEach((flpConfig, index) => { + const inboundChangeContent = getInboundChangeContentWithNewInboundID(flpConfig, appId); + if (!inboundChangeContent) { + return; + } const addInboundChange = { changeType: 'appdescr_app_addNewInbound', content: inboundChangeContent, @@ -323,15 +326,20 @@ export function enhanceManifestChangeContentWithFlpConfig( 'i18n': 'i18n/i18n.properties' } }; - const removeOtherInboundsChange = { - changeType: 'appdescr_app_removeAllInboundsExceptOne', - content: { - 'inboundId': flpConfiguration.inboundId - }, - texts: {} - }; - manifestChangeContent.push(addInboundChange); - manifestChangeContent.push(removeOtherInboundsChange); - } + + // Remove all inbounds except one should be only after the first inbound is added + // This is implemented this way to avoid issues with the merged on ABAP side + if (index === 0) { + const removeOtherInboundsChange = { + changeType: 'appdescr_app_removeAllInboundsExceptOne', + content: { + 'inboundId': flpConfig.inboundId + }, + texts: {} + }; + + manifestChangeContent.push(removeOtherInboundsChange); + } + }); } diff --git a/packages/create/src/cli/add/navigation-config.ts b/packages/create/src/cli/add/navigation-config.ts index ec2a81df842..add847bdfa2 100644 --- a/packages/create/src/cli/add/navigation-config.ts +++ b/packages/create/src/cli/add/navigation-config.ts @@ -12,7 +12,7 @@ import { type DescriptorVariant } from '@sap-ux/adp-tooling'; import type { ToolsLogger } from '@sap-ux/logger'; -import { getPrompts } from '@sap-ux/flp-config-inquirer'; +import { getPrompts, tileActions } from '@sap-ux/flp-config-inquirer'; import { FileName, getAppType } from '@sap-ux/project-access'; import { createAbapServiceProvider } from '@sap-ux/system-access'; import type { Manifest, ManifestNamespace } from '@sap-ux/project-access'; @@ -82,22 +82,17 @@ async function addInboundNavigationConfig(basePath: string, simulate: boolean, y const inbounds = await getInbounds(basePath, yamlPath, fs, logger, variant); let tileSettingsAnswers: TileSettingsAnswers | undefined; if (inbounds && isAdp) { - tileSettingsAnswers = await promptYUIQuestions(getTileSettingsQuestions(), false); + tileSettingsAnswers = await promptYUIQuestions(getTileSettingsQuestions(inbounds), false); } const answers = await getUserAnswers(inbounds, isAdp, tileSettingsAnswers); - if (!answers) { + if (!answers && tileSettingsAnswers?.tileHandlingAction !== tileActions.REPLACE) { logger.info('User chose not to overwrite existing inbound navigation configuration.'); return; } - if (variant.isAdp) { - const config = getAdpFlpInboundsWriterConfig(answers, variant.content.layer, tileSettingsAnswers); - await generateInboundConfig(basePath, config as InternalInboundNavigation, fs); - } else { - await generateInboundNavigationConfig(basePath, answers, true, fs); - } + await generateConfig(basePath, answers as FLPConfigAnswers, variant, fs, tileSettingsAnswers); if (!simulate) { fs.commit(() => logger.info(`Inbound navigation configuration complete.`)); @@ -174,6 +169,10 @@ async function getUserAnswers( promptOptions = getAdpFlpConfigPromptOptions(tileSettingsAnswers as TileSettingsAnswers, inbounds); } + if (isAdp && tileSettingsAnswers?.tileHandlingAction === tileActions.REPLACE) { + return undefined; + } + const prompts = await filterLabelTypeQuestions(await getPrompts(inbounds, promptOptions)); const config = await promptYUIQuestions(prompts, false); @@ -183,3 +182,28 @@ async function getUserAnswers( return config?.overwrite === false ? undefined : config; } + +/** + * Generates the inbound navigation configuration for the given project. + * + * @param {string} basePath - The path to the application root. + * @param {FLPConfigAnswers} answers - The user-provided configuration answers. + * @param {Variant} variant - The descriptor variant information. + * @param {Editor} fs - The mem-fs editor instance. + * @param {TileSettingsAnswers} [tileSettingsAnswers] - The answers for tile settings. + * @returns {Promise} A promise that resolves when the configuration is generated. + */ +async function generateConfig( + basePath: string, + answers: FLPConfigAnswers, + variant: Variant, + fs: Editor, + tileSettingsAnswers?: TileSettingsAnswers +): Promise { + if (variant.isAdp) { + const config = getAdpFlpInboundsWriterConfig(answers, variant.content.layer, tileSettingsAnswers); + await generateInboundConfig(basePath, config as InternalInboundNavigation[], fs); + } else { + await generateInboundNavigationConfig(basePath, answers as FLPConfigAnswers, true, fs); + } +} diff --git a/packages/flp-config-inquirer/src/index.ts b/packages/flp-config-inquirer/src/index.ts index 3cf06d6671d..5006c4a79ce 100644 --- a/packages/flp-config-inquirer/src/index.ts +++ b/packages/flp-config-inquirer/src/index.ts @@ -4,7 +4,7 @@ import type { ManifestNamespace } from '@sap-ux/project-access'; import type { InquirerAdapter, PromptDefaultValue } from '@sap-ux/inquirer-common'; import { initI18n, addi18nResourceBundle } from './i18n'; -import { promptNames } from './types'; +import { promptNames, tileActions, tilePromptNames } from './types'; import { getExistingFlpConfigInfoPrompt } from './prompts/questions'; import { getQuestions, getTileSettingsQuestions } from './prompts'; import type { FLPConfigAnswers, FLPConfigQuestion, FLPConfigPromptOptions, TileSettingsAnswers } from './types'; @@ -109,6 +109,8 @@ export { type FLPConfigPromptOptions, type FLPConfigQuestion, type TileSettingsAnswers, + tileActions, + tilePromptNames, getAdpFlpConfigPromptOptions, getAdpFlpInboundsWriterConfig, getTileSettingsQuestions diff --git a/packages/flp-config-inquirer/src/prompts/prompts.ts b/packages/flp-config-inquirer/src/prompts/prompts.ts index 8f6603a5bcf..0d1bce5eaf1 100644 --- a/packages/flp-config-inquirer/src/prompts/prompts.ts +++ b/packages/flp-config-inquirer/src/prompts/prompts.ts @@ -14,7 +14,13 @@ import { getTileSettingsPrompts } from './questions'; import { promptNames } from '../types'; -import type { ExistingInboundRef, FLPConfigPromptOptions, FLPConfigQuestion, TileSettingsAnswers } from '../types'; +import type { + ExistingInboundRef, + FLPConfigPromptOptions, + FLPConfigQuestion, + TileSettingsAnswers, + OnActionSelect +} from '../types'; import type { YUIQuestion } from '@sap-ux/inquirer-common'; /** @@ -71,12 +77,18 @@ export function getQuestions( /** * Generates a list of prompts for configuring tile settings in the FLP configuration. * + * @param {ManifestNamespace.Inbound} inbounds - Existing inbounds for the application. * @param {FLPConfigPromptOptions} [promptOptions] - Optional configuration to control prompt behavior and defaults. + * @param {OnActionSelect} onActionSelect - Callback function to handle changes in tile settings. * @returns {YUIQuestion[] | FLPConfigQuestion[]} An array of questions for tile settings. */ -export function getTileSettingsQuestions(promptOptions?: FLPConfigPromptOptions): YUIQuestion[] { +export function getTileSettingsQuestions( + inbounds: ManifestNamespace.Inbound, + promptOptions?: FLPConfigPromptOptions, + onActionSelect?: OnActionSelect +): YUIQuestion[] { const isCLI = getHostEnvironment() === hostEnvironment.cli; - const questions = getTileSettingsPrompts(); + const questions = getTileSettingsPrompts(inbounds, onActionSelect); if (!promptOptions?.existingFlpConfigInfo?.hide) { questions.unshift(getExistingFlpConfigInfoPrompt(isCLI) as YUIQuestion); } diff --git a/packages/flp-config-inquirer/src/prompts/questions/tile-settings.ts b/packages/flp-config-inquirer/src/prompts/questions/tile-settings.ts index 84664cb22ff..bc94bf5e6ad 100644 --- a/packages/flp-config-inquirer/src/prompts/questions/tile-settings.ts +++ b/packages/flp-config-inquirer/src/prompts/questions/tile-settings.ts @@ -1,13 +1,20 @@ import type { ListQuestion, ConfirmQuestion, YUIQuestion } from '@sap-ux/inquirer-common'; -import { type TileSettingsAnswers, tileActions, tilePromptNames } from '../../types'; +import { Severity, type IMessageSeverity } from '@sap-devx/yeoman-ui-types'; +import type { ManifestNamespace } from '@sap-ux/project-access'; +import { type TileSettingsAnswers, tileActions, tilePromptNames, type OnActionSelect } from '../../types'; import { t } from '../../i18n'; /** * Returns the list of questions for tile handling actions. * + * @param inbounds - list of tile inbounds of the application. + * @param onActionSelect - callback function to handle changes in tile settings. * @returns {YUIQuestion[]} Array of tile action questions. */ -export function getTileSettingsPrompts(): YUIQuestion[] { +export function getTileSettingsPrompts( + inbounds: ManifestNamespace.Inbound, + onActionSelect?: OnActionSelect +): YUIQuestion[] { return [ { type: 'list', @@ -21,6 +28,25 @@ export function getTileSettingsPrompts(): YUIQuestion[] { guiOptions: { mandatory: true, breadcrumb: true + }, + additionalMessages: async ( + answer: TileSettingsAnswers['tileHandlingAction'] + ): Promise => { + let additionalMessage: IMessageSeverity | undefined; + if (answer === tileActions.REPLACE) { + additionalMessage = { + severity: Severity.information, + message: t('additionalMessages.replaceScenarioInfo') + }; + } + return additionalMessage; + }, + validate: async (answer: TileSettingsAnswers['tileHandlingAction']): Promise => { + let handlerResult: boolean | string | undefined = true; + if (typeof onActionSelect === 'function') { + handlerResult = await onActionSelect(answer); + } + return handlerResult ?? true; } } as ListQuestion, { diff --git a/packages/flp-config-inquirer/src/translations/flp-config-inquirer.i18n.json b/packages/flp-config-inquirer/src/translations/flp-config-inquirer.i18n.json index 0fcb100ae2b..005fe79ffe7 100644 --- a/packages/flp-config-inquirer/src/translations/flp-config-inquirer.i18n.json +++ b/packages/flp-config-inquirer/src/translations/flp-config-inquirer.i18n.json @@ -27,5 +27,8 @@ "choices": { "replaceOriginalTile": "Replace Base Application's Existing Tiles", "addNewTile": "Add a New Tile" + }, + "additionalMessages": { + "replaceScenarioInfo": "Selecting this option will replace existing tiles from the base application. Please make sure that you create a new IAM app of type 'UI Adaptation' and add it to a custom business catalog. In the business role, add your custom business catalog and deactivate the original IAM app." } } diff --git a/packages/flp-config-inquirer/src/types.ts b/packages/flp-config-inquirer/src/types.ts index bc0730b74fc..08186597484 100644 --- a/packages/flp-config-inquirer/src/types.ts +++ b/packages/flp-config-inquirer/src/types.ts @@ -175,3 +175,7 @@ export interface TileSettingsAnswers { [tilePromptNames.tileHandlingAction]: string; [tilePromptNames.copyFromExisting]: boolean; } + +export type OnActionSelect = ( + answer: TileSettingsAnswers['tileHandlingAction'] +) => Promise | boolean | string | undefined; diff --git a/packages/flp-config-inquirer/src/utils.ts b/packages/flp-config-inquirer/src/utils.ts index 41e4f12e558..f7728f22fc9 100644 --- a/packages/flp-config-inquirer/src/utils.ts +++ b/packages/flp-config-inquirer/src/utils.ts @@ -6,7 +6,6 @@ import { flpConfigurationExists, NamespacePrefix } from '@sap-ux/adp-tooling'; -import type { InboundContent } from '@sap-ux/axios-extension'; import type { ManifestNamespace, UI5FlexLayer } from '@sap-ux/project-access'; import { type FLPConfigPromptOptions, type FLPConfigAnswers, type TileSettingsAnswers, tileActions } from './types'; /** @@ -57,29 +56,35 @@ export function getAdpFlpConfigPromptOptions( /** * Builds the configuration for replacing an existing FLP inbound based on the provided answers and layer. * - * @param {FLPConfigAnswers} flpConfigAnswers - The answers for FLP configuration. * @param {UI5FlexLayer} layer - The layer of the project. - * @returns {InternalInboundNavigation} The configuration for the replaced FLP inbound. + * @param {ManifestNamespace.Inbound} inbounds - The inbound configuration. + * @returns {InternalInboundNavigation[]} The configuration for the replaced FLP inbound. */ -function buildReplaceInboundConfig(flpConfigAnswers: FLPConfigAnswers, layer: UI5FlexLayer): InternalInboundNavigation { - const { - semanticObject, - action, - signature: { parameters } = {} - } = flpConfigAnswers.inboundId ?? ({} as InboundContent); - let inboundId = !semanticObject || !action ? '' : `${semanticObject}-${action}`; - if (inboundId) { - inboundId = layer === FlexLayer.CUSTOMER_BASE ? `${NamespacePrefix.CUSTOMER}${inboundId}` : inboundId; +function buildReplaceInboundConfig( + layer: UI5FlexLayer, + inbounds?: ManifestNamespace.Inbound +): InternalInboundNavigation[] { + if (!inbounds) { + return []; } - return { - inboundId, - semanticObject: semanticObject ?? '', - action: action ?? '', - title: flpConfigAnswers.title ?? '', - subTitle: flpConfigAnswers.subTitle ?? '', - icon: flpConfigAnswers.icon ?? '', - additionalParameters: parameters ? JSON.stringify(parameters) : '' - }; + + return Object.entries(inbounds).map(([inboundKey, inboundData]) => { + const { semanticObject, action, signature: { parameters } = {} } = inboundData; + let inboundId = inboundKey; + if (inboundId && layer === FlexLayer.CUSTOMER_BASE) { + inboundId = `${NamespacePrefix.CUSTOMER}${inboundId}`; + } + + return { + inboundId, + semanticObject: semanticObject ?? '', + action: action ?? '', + title: inboundData.title ?? '', + subTitle: inboundData.subTitle ?? '', + icon: inboundData.icon ?? '', + additionalParameters: parameters ? JSON.stringify(parameters) : '' + }; + }); } /** @@ -87,9 +92,9 @@ function buildReplaceInboundConfig(flpConfigAnswers: FLPConfigAnswers, layer: UI * * @param {FLPConfigAnswers} flpConfigAnswers - The answers for FLP configuration. * @param {FlexLayer} layer - The layer of the project. - * @returns {InternalInboundNavigation} The configuration for the new FLP inbound. + * @returns {InternalInboundNavigation[]} The configuration for the new FLP inbound. */ -function buildAddInboundConfig(flpConfigAnswers: FLPConfigAnswers, layer: UI5FlexLayer): InternalInboundNavigation { +function buildAddInboundConfig(flpConfigAnswers: FLPConfigAnswers, layer: UI5FlexLayer): InternalInboundNavigation[] { let inboundId = !flpConfigAnswers.semanticObject || !flpConfigAnswers.action ? '' @@ -98,15 +103,17 @@ function buildAddInboundConfig(flpConfigAnswers: FLPConfigAnswers, layer: UI5Fle inboundId = layer === FlexLayer.CUSTOMER_BASE ? `${NamespacePrefix.CUSTOMER}${inboundId}` : inboundId; } - return { - inboundId, - semanticObject: flpConfigAnswers.semanticObject ?? '', - action: flpConfigAnswers.action ?? '', - title: flpConfigAnswers.title ?? '', - subTitle: flpConfigAnswers.subTitle ?? '', - icon: flpConfigAnswers.icon ?? '', - additionalParameters: flpConfigAnswers.additionalParameters ?? '' - }; + return [ + { + inboundId, + semanticObject: flpConfigAnswers.semanticObject ?? '', + action: flpConfigAnswers.action ?? '', + title: flpConfigAnswers.title ?? '', + subTitle: flpConfigAnswers.subTitle ?? '', + icon: flpConfigAnswers.icon ?? '', + additionalParameters: flpConfigAnswers.additionalParameters ?? '' + } + ]; } /** @@ -115,16 +122,18 @@ function buildAddInboundConfig(flpConfigAnswers: FLPConfigAnswers, layer: UI5Fle * @param {FLPConfigAnswers} flpConfigAnswers - The answers for FLP configuration. * @param {FlexLayer} layer - The layer of the project. * @param {TileSettingsAnswers} [tileSettingsAnswers] - The answers for tile settings. + * @param {ManifestNamespace.Inbound} inbounds - The inbound configuration. * @returns {InternalInboundNavigation | NewInboundNavigation} The configuration for FLP inbounds writer. */ export function getAdpFlpInboundsWriterConfig( - flpConfigAnswers: FLPConfigAnswers, + flpConfigAnswers: FLPConfigAnswers | undefined, layer: UI5FlexLayer, - tileSettingsAnswers?: TileSettingsAnswers -): InternalInboundNavigation | NewInboundNavigation { + tileSettingsAnswers?: TileSettingsAnswers, + inbounds?: ManifestNamespace.Inbound +): InternalInboundNavigation[] | NewInboundNavigation[] { const { tileHandlingAction } = tileSettingsAnswers ?? {}; if (tileHandlingAction === tileActions.REPLACE) { - return buildReplaceInboundConfig(flpConfigAnswers, layer); + return buildReplaceInboundConfig(layer, inbounds); } - return buildAddInboundConfig(flpConfigAnswers, layer); + return buildAddInboundConfig(flpConfigAnswers as FLPConfigAnswers, layer); }