Skip to content
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

fix: reuse component detection #3038

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

Conversation

mmilko01
Copy link
Contributor

@mmilko01 mmilko01 commented Mar 19, 2025

#3045

  • Consume isReuseComponent API from RTA to detect reuse components.
  • Disable context menu items for Add: Fragment and Extend with Controller on control level only
  • Remove reuse component pop-up when loading Adaptation Editor

Copy link

changeset-bot bot commented Mar 19, 2025

🦋 Changeset detected

Latest commit: 20076a1

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

This PR includes changesets to release 3 packages
Name Type
@sap-ux-private/preview-middleware-client Patch
@sap-ux/preview-middleware Patch
@sap-ux/create 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

@@ -19,6 +19,7 @@ import { ContextMenuService } from './context-menu-service';

export default function init(
rta: RuntimeAuthoring,
isReuseComponentChecker: IsReuseComponentApi,
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be undefined if called directly from RTA.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed after the changes proposed below, this point is taken care of.
Fixed with: a9fa288

*
* @returns boolean
*/
export function isHigherThanMinimalUi5Version(
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to "duplicate" isLowerThanMinimalUi5Version function. You can just use negation if you need higher version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed with: 848ceb5

*/
export const getExtendControllerItemText = (overlay: ElementOverlay, isReuseComponentChecker: IsReuseComponentApi, isCloud: boolean) => {
if (isCloud && isReuseComponentChecker(overlay.getElement().getId())) {
return 'Extend With Controller (Unavailable due to control being a Reuse component)';
Copy link
Contributor

Choose a reason for hiding this comment

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

Text should be maintained in messagebundle.properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in: 401d3a2

@@ -40,6 +40,7 @@ export interface QuickActionContext {
flexSettings: FlexSettings;
manifest: Manifest;
changeService: ChangeService;
isReuseComponent: (controlId: string) => boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually looking at this now, it seems that this is a bit overly complex and not needed. We could just "import" the isReuseComponent in the quick action where it is required, since it no longer has a state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in: a9fa288

reuseComponentApi = (await import('sap/ui/rta/util/isReuseComponent')).default;
}

return function isReuseComponent(controlId: string): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no need to redefine this function every time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in: a9fa288

@mmilko01 mmilko01 marked this pull request as ready for review March 25, 2025 07:18
@mmilko01 mmilko01 requested a review from a team as a code owner March 25, 2025 07:18
@mmilko01 mmilko01 requested a review from a team as a code owner March 25, 2025 07:35
Copy link
Contributor

@lfindlaysap lfindlaysap left a comment

Choose a reason for hiding this comment

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

@mmilko01, some questions and suggestions.

@@ -42,6 +42,11 @@ ADP_SYNC_VIEWS_MESSAGE = Synchronous views are detected for this application. Co
ADP_REUSE_COMPONENTS_MESSAGE_TITLE = Reuse components detected
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ADP_REUSE_COMPONENTS_MESSAGE_TITLE = Reuse components detected
ADP_REUSE_COMPONENTS_MESSAGE_TITLE = Reuse Components Detected

@@ -42,6 +42,11 @@ ADP_SYNC_VIEWS_MESSAGE = Synchronous views are detected for this application. Co
ADP_REUSE_COMPONENTS_MESSAGE_TITLE = Reuse components detected
ADP_REUSE_COMPONENTS_MESSAGE_DESCRIPTION = Reuse components are detected for some views in this application. Controller extensions, adding fragments and manifest changes are not supported for such views and will be disabled.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ADP_REUSE_COMPONENTS_MESSAGE_DESCRIPTION = Reuse components are detected for some views in this application. Controller extensions, adding fragments and manifest changes are not supported for such views and will be disabled.
ADP_REUSE_COMPONENTS_MESSAGE_DESCRIPTION = Reuse components are detected for some views in this application. Controller extensions, adding fragments, and manifest changes are not supported for such views and will be disabled.

@@ -42,6 +42,11 @@ ADP_SYNC_VIEWS_MESSAGE = Synchronous views are detected for this application. Co
ADP_REUSE_COMPONENTS_MESSAGE_TITLE = Reuse components detected
ADP_REUSE_COMPONENTS_MESSAGE_DESCRIPTION = Reuse components are detected for some views in this application. Controller extensions, adding fragments and manifest changes are not supported for such views and will be disabled.
ADP_QUICK_ACTION_DIALOG_OPEN_MESSAGE = This action is disabled because a dialog is already open
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ADP_QUICK_ACTION_DIALOG_OPEN_MESSAGE = This action is disabled because a dialog is already open
ADP_QUICK_ACTION_DIALOG_OPEN_MESSAGE = This action is disabled because a dialog is already open.

@@ -42,6 +42,11 @@ ADP_SYNC_VIEWS_MESSAGE = Synchronous views are detected for this application. Co
ADP_REUSE_COMPONENTS_MESSAGE_TITLE = Reuse components detected
ADP_REUSE_COMPONENTS_MESSAGE_DESCRIPTION = Reuse components are detected for some views in this application. Controller extensions, adding fragments and manifest changes are not supported for such views and will be disabled.
ADP_QUICK_ACTION_DIALOG_OPEN_MESSAGE = This action is disabled because a dialog is already open
ADP_ADD_FRAGMENT_MENU_ITEM = Add: Fragment
ADP_ADD_FRAGMENT_MENU_ITEM_REUSE_COMPONENT = Add: Fragment (Unavailable due to control being a Reuse component)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you show me what this looks like? Same for the other unavailable texts?

ADP_ADD_FRAGMENT_MENU_ITEM = Add: Fragment
ADP_ADD_FRAGMENT_MENU_ITEM_REUSE_COMPONENT = Add: Fragment (Unavailable due to control being a Reuse component)
ADP_ADD_FRAGMENT_MENU_ITEM_UNSTABLE_ID = Add: Fragment (Unavailable due to unstable ID of the control or its parent control)
ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM = Extend With Controller
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM = Extend With Controller
ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM = Extend with Controller

ADP_ADD_FRAGMENT_MENU_ITEM_REUSE_COMPONENT = Add: Fragment (Unavailable due to control being a Reuse component)
ADP_ADD_FRAGMENT_MENU_ITEM_UNSTABLE_ID = Add: Fragment (Unavailable due to unstable ID of the control or its parent control)
ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM = Extend With Controller
ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM_REUSE_COMPONENT = Extend With Controller (Unavailable due to control being a Reuse component)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM_REUSE_COMPONENT = Extend With Controller (Unavailable due to control being a Reuse component)
ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM_REUSE_COMPONENT = Extend with Controller (Unavailable due to control being a Reuse component)

ADP_ADD_FRAGMENT_MENU_ITEM_REUSE_COMPONENT = Add: Fragment (Unavailable due to control being a Reuse component)
ADP_ADD_FRAGMENT_MENU_ITEM_UNSTABLE_ID = Add: Fragment (Unavailable due to unstable ID of the control or its parent control)
ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM = Extend With Controller
ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM_REUSE_COMPONENT = Extend With Controller (Unavailable due to control being a Reuse component)
CPE_CHANGES_VISIBLE_AFTER_SAVE_AND_RELOAD_MESSAGE = Note: The change will be visible after save and reload.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a button called save and reload?

ADP_ADD_FRAGMENT_MENU_ITEM_REUSE_COMPONENT = Add: Fragment (Unavailable due to control being a Reuse component)
ADP_ADD_FRAGMENT_MENU_ITEM_UNSTABLE_ID = Add: Fragment (Unavailable due to unstable ID of the control or its parent control)
ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM = Extend With Controller
ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM_REUSE_COMPONENT = Extend With Controller (Unavailable due to control being a Reuse component)
CPE_CHANGES_VISIBLE_AFTER_SAVE_AND_RELOAD_MESSAGE = Note: The change will be visible after save and reload.

TABLE_ROWS_NEEDED_TO_CREATE_CUSTOM_COLUMN=At least one table row is required to create new custom column. Make sure the table data is loaded and try again.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
TABLE_ROWS_NEEDED_TO_CREATE_CUSTOM_COLUMN=At least one table row is required to create new custom column. Make sure the table data is loaded and try again.
TABLE_ROWS_NEEDED_TO_CREATE_CUSTOM_COLUMN=At least one table row is required to create a new custom column. Make sure the table data is loaded and try again.

Copy link
Contributor

@GDamyanov GDamyanov left a comment

Choose a reason for hiding this comment

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

Code looks good.
Excellent test coverage.
Did not tested manually.

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.

None yet

4 participants