Skip to content

Move getFloorplanLabel to fiori generator shared - #4927

Open
kjose90 wants to merge 5 commits into
mainfrom
fix/move-read-me-util-ftn
Open

Move getFloorplanLabel to fiori generator shared #4927
kjose90 wants to merge 5 commits into
mainfrom
fix/move-read-me-util-ftn

Conversation

@kjose90

@kjose90 kjose90 commented Jul 7, 2026

Copy link
Copy Markdown
Member
  • Moved getFloorplanLabel from fiori-app-sub-generator/src/utils/common.ts to @sap-ux/fiori-generator-shared/src/app-gen-info.ts as a shared utility
  • Added floorplans.label translations and odataVersionFormatter interpolation to fiori-generator-shared i18n
  • Removed duplicate floorplans.label translation block from fiori-app-sub-generator
  • Updated repo-app-import-sub-generator to import getFloorplanLabel from shared instead of fiori-app-sub-generator, removing the dependency entirely as flagged in PR comment

@changeset-bot

changeset-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1d4b8f9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 34 packages
Name Type
@sap-ux/fiori-app-sub-generator Minor
@sap-ux/fiori-generator-shared Minor
@sap-ux/repo-app-import-sub-generator Patch
@sap-ux/abap-deploy-config-inquirer Patch
@sap-ux/abap-deploy-config-sub-generator Patch
@sap-ux/adp-flp-config-sub-generator Patch
@sap-ux/cap-config-writer Patch
@sap-ux/cf-deploy-config-sub-generator Patch
@sap-ux/deploy-config-generator-shared Patch
@sap-ux/deploy-config-sub-generator Patch
@sap-ux/fiori-elements-writer Patch
@sap-ux/fiori-freestyle-writer Patch
@sap-ux/flp-config-inquirer Patch
@sap-ux/flp-config-sub-generator Patch
@sap-ux/generator-adp Patch
@sap-ux/generator-odata-downloader Patch
@sap-ux/inquirer-common Patch
@sap-ux/odata-service-inquirer Patch
@sap-ux/ui-service-sub-generator Patch
@sap-ux/ui5-library-reference-sub-generator Patch
@sap-ux/ui5-library-sub-generator Patch
@sap-ux/ui5-test-writer Patch
@sap-ux/create Patch
@sap-ux/ui-service-inquirer Patch
@sap-ux/ui5-application-inquirer Patch
@sap-ux/generator-simple-fe Patch
@sap-ux/adp-tooling Patch
@sap-ux/cf-deploy-config-inquirer Patch
@sap-ux/deploy-tooling Patch
@sap-ux/ui5-library-inquirer Patch
@sap-ux/ui5-library-reference-inquirer Patch
@sap-ux/backend-proxy-middleware-cf Patch
@sap-ux/preview-middleware Patch
@sap-ux-private/preview-middleware-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@hyperspace-pr-bot

Copy link
Copy Markdown
Contributor

Summary

The following content is AI-generated and provides a summary of the pull request:


Description

Moves the getFloorplanLabel utility function from @sap-ux/fiori-app-sub-generator into @sap-ux/fiori-generator-shared to eliminate duplication and reduce unnecessary cross-package dependencies.

Key changes:

  • Added getFloorplanLabel to packages/fiori-generator-shared/src/app-gen-info.ts and exported it via index.ts
  • Migrated floorplans.label translation keys and odataVersionFormatter interpolation config from fiori-app-sub-generator i18n to fiori-generator-shared i18n (also adds listdetail entry)
  • Removed getFloorplanLabel and the duplicate floorplans.label translation block from fiori-app-sub-generator
  • Updated repo-app-import-sub-generator to import getFloorplanLabel directly from @sap-ux/fiori-generator-shared, removing its dependency on @sap-ux/fiori-app-sub-generator entirely (including package.json, tsconfig.json, and pnpm-lock.yaml)
  • Updated fiori-app-sub-generator to import getFloorplanLabel from @sap-ux/fiori-generator-shared
  • Added unit tests for getFloorplanLabel in fiori-generator-shared

Type of change

  • Bug (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds a new feature)
  • Breaking change (Bug or New feature that would cause existing functionality/consumers to not work as expected)
  • Non-Breaking chores (Changes to tools, libraries, build process, documentation, etc)
  • None of the above (Reviewers might ask for more clarification)

How have you tested?

  • Existing unit tests updated to import getFloorplanLabel from @sap-ux/fiori-generator-shared
  • New unit tests added in fiori-generator-shared covering label output with/without OData version and fallback for unknown template types

Checklist:

  • The code conforms to the general development principles
  • Supplied as many details as possible on this change
  • The code is easy to read and maintainable by others
  • Corresponding changes to the documentation has been done
  • Already existing and new unit tests pass locally

  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.27.0

  • File Content Strategy: Full file content
  • Output Template: Repository PR Template
  • LLM: anthropic--claude-4.6-sonnet
  • Event Trigger: pull_request.opened
  • Correlation ID: 16940fa0-7a15-11f1-8472-ba896d393687
  • Summary Prompt: Default Prompt

@hyperspace-pr-bot hyperspace-pr-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR cleanly achieves its goal of consolidating getFloorplanLabel into @sap-ux/fiori-generator-shared and removing the circular dependency from repo-app-import-sub-generator. The refactoring is well-structured with appropriate deprecation notices, updated tests, and a valid changeset. Two issues were flagged: the interpolation.format callback in fiori-generator-shared doesn't match the i18next function signature (missing the format name guard), and the fallback behaviour for unknown templates with an OData version warrants a clarifying comment or intentional assertion.

PR Bot Information

Version: 1.27.0

  • File Content Strategy: Full file content
  • Agent Instructions:
  • LLM: anthropic--claude-4.6-sonnet
  • Event Trigger: pull_request.opened
  • Correlation ID: 16940fa0-7a15-11f1-8472-ba896d393687

Comment on lines +23 to +26
interpolation: {
format: function odataVersionFormatter(odataVersion: string) {
return odataVersion ? ` V${odataVersion}` : '';
}

@hyperspace-pr-bot hyperspace-pr-bot Bot Jul 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The interpolation.format function signature does not match the i18next API contract.

The i18next format callback receives three arguments: (value, format, lng). The current implementation names the first parameter odataVersion, which only works because the i18n keys use a named formatter ({{odataVersion, odataVersionFormatter}}). However, i18next passes the interpolated variable's value as the first argument — not the format name. The format name (odataVersionFormatter) is passed as the second argument and is being silently ignored. This means the function works by accident: it returns `V${value}` for any truthy first argument, regardless of whether the formatter was actually intended.

Additionally, the function only handles the odataVersionFormatter format, but any other interpolated value calling a named formatter will also be processed here indiscriminately. The format name should be checked to guard this:

interpolation: {
    format: function (value: string, format?: string) {
        if (format === 'odataVersionFormatter') {
            return value ? ` V${value}` : '';
        }
        return value;
    }
},
Suggested change
interpolation: {
format: function odataVersionFormatter(odataVersion: string) {
return odataVersion ? ` V${odataVersion}` : '';
}
interpolation: {
format: function (value: string, format?: string) {
if (format === 'odataVersionFormatter') {
return value ? ` V${value}` : '';
}
return value;
}
},

Double-check suggestion before committing. Edit this comment for amendments.


Thank you for submitting your feedback: ✅ Helpful comment.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


test('should return templateType as fallback for unknown template', () => {
expect(getFloorplanLabel('unknown-template')).toBe('unknown-template');
expect(getFloorplanLabel('unknown-template', '4')).toBe('unknown-template');

@hyperspace-pr-bot hyperspace-pr-bot Bot Jul 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: getFloorplanLabel('unknown-template', '4') is expected to return 'unknown-template', but the version suffix will actually be appended.

When the i18n key floorplans.label.unknown-template is missing, the defaultValue: templateType option kicks in. However, this default value string does not contain the {{odataVersion, odataVersionFormatter}} interpolation token, so the version suffix is never appended — and the test passes for the wrong reason. The real question is whether an unknown template with an OData version should return 'unknown-template V4'. If intentionally no suffix is desired for unknown templates, the current behaviour is correct but the test should document this intent explicitly. If a suffix is desired, the default value template needs to include the token. Either way, the test assertion masks a potential design gap.


Thank you for submitting your feedback: ❌ This comment is not helpful.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But since there's no defined label for an unknown template, returning unknown-template is ok? — appending
' V4' to an already-meaningless string doesn't add value.

"ovp": "Overview Page{{odataVersion, odataVersionFormatter}}",
"feop": "Form Entry Object Page{{odataVersion, odataVersionFormatter}}"
},
"description": {

@kjose90 kjose90 Jul 7, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we need to move floorplans.description to fiori generator shared as well? I couldnt find where this is used in the repo as well 🤷

lfindlaysap
lfindlaysap previously approved these changes Jul 7, 2026
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
77.8% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants