-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an option to open source FE writer generate
to enable writing annotations.
#2849
base: main
Are you sure you want to change the base?
Conversation
…into moveCapUpdates
… into updateCapService
🦋 Changeset detectedLatest commit: c3e53c6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good. couple of small suggestions
function canGenerateAnnotationsForTemplate(version: OdataVersion, type: TemplateType): boolean { | ||
const isODataV4 = version === OdataVersion.v4; | ||
const supportedTemplates: TemplateType[] = [TemplateType.ListReportObjectPage, TemplateType.Worklist]; | ||
return (isODataV4 && supportedTemplates.includes(type)) || type === TemplateType.FormEntryObjectPage; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't FormEntryObjectPage also only v4?
https://sapui5.hana.ondemand.com/sdk/#/topic/533f7e7f59854cb08ce8074814ae83c5.html
const { settings } = feApp.template; | ||
const { capService } = feApp.service; | ||
const { name: packageName } = feApp.package ?? {}; | ||
let serviceName = 'mainService'; | ||
let projectPath = basePath; | ||
// add line items is false for FormEntryObjectPage type project | ||
const addLineItems = | ||
feApp.template.type === TemplateType.ListReportObjectPage || feApp.template.type === TemplateType.Worklist; | ||
const entitySetName = (settings as T & { entityConfig?: EntityConfig })?.entityConfig?.mainEntityName ?? ''; | ||
|
||
if (capService) { | ||
serviceName = capService.serviceName; | ||
projectPath = capService.projectPath; | ||
} | ||
|
||
const options: GenerateAnnotationsOptions = { | ||
entitySetName, | ||
annotationFilePath: getAnnotationFilePath(packageName, capService), | ||
addFacets: true, | ||
addLineItems, | ||
addValueHelps: !!capService | ||
}; | ||
const serviceParameters: AnnotationServiceParameters = { | ||
serviceName, | ||
appName: packageName, | ||
project: projectPath | ||
}; | ||
|
||
await generateAnnotations(fs, serviceParameters, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we move this into a separate function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes are clean and covered by tests.
Thanks for the updates.
Changeset ✅
@@ -0,0 +1,102 @@ | |||
import { sep } from 'path'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if the data
folder is the correct place as this is for static settings but I guess it's ok for now, not sure what data
means actually in this context :)
* @param {boolean} [addAnnotations] - An optional flag indicating whether annotations should be enabled. | ||
* @returns {boolean} - Returns `true` if annotations can be generated, otherwise `false`. | ||
*/ | ||
export function canGenerateAnnotationsForTemplate( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to use the template settings for this information, as thats its purpose, to have all template related information in one place.
e.g.
export const TemplateTypeAttributes: TemplateAttributes = {
[TemplateType.Worklist]: {
supportedODataVersions: [OdataVersion.v2, OdataVersion.v4],
minimumUi5Version: {
[OdataVersion.v2]: minSupportedUI5Version,
[OdataVersion.v4]: '1.99.0'
},
annotationGenerationSupport: {
[OdataVersion.v4]: true
},
Then you dont need this function: https://github.com/SAP/open-ux-tools/pull/2849/files#diff-ac5073f87858b510da65484577f6afc172f304cfec03c196415cb096ce0ebf14R45
or this def:
https://github.com/SAP/open-ux-tools/pull/2849/files#diff-ac5073f87858b510da65484577f6afc172f304cfec03c196415cb096ce0ebf14R16
@@ -223,6 +236,33 @@ async function generate<T extends {}>(basePath: string, data: FioriElementsApp<T | |||
await applyCAPUpdates(fs, feApp.service.capService, settings); | |||
} | |||
|
|||
// Handle annotation writing | |||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this whole block to the writeAnnotions
file :
if (feApp.appOptions.addAnnotations) {
writeAnnotations(...)
}
The index file is getting too busy and the function is too long now! Would be nicer to hide all annotation writing code to that file now?
@@ -2,6 +2,9 @@ | |||
"info": { | |||
"mockOnlyWarning": "This application was generated with a local metadata file and does not reference a live server. Please add the required server configuration or start this application with mock data using the target: npm run start-mock" | |||
}, | |||
"warn": { | |||
"invalidTypeForAnnotationGeneration": "Invalid template type '{{ templateType }}' for annotation generation. Supported types are: {{ supportedTypes }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add additional information...
"The provided option addAnnotations
is not supported for the specified template and odata version. Generation will continue but additional annotations will not added."
Quality Gate passedIssues Measures |
#2773
addAnnotations
toFioriElementsApp
interface.addAnnotations
is enabled and template type is LROP/ Worklist and service is OData version 4 or if template type is FEOP.