Skip to content

Commit

Permalink
fix: update notification
Browse files Browse the repository at this point in the history
  • Loading branch information
voicis committed Sep 20, 2024
1 parent 727db61 commit 4c770f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { type AddFragmentChangeContentType } from 'sap/ui/fl/Change';

import { setApplicationRequiresReload } from '@sap-ux-private/control-property-editor-common';

import { getResourceModel } from '../../i18n';
import { getResourceModel, getTextBundle } from '../../i18n';
import { CommunicationService } from '../../cpe/communication-service';

import ControlUtils from '../control-utils';
Expand Down Expand Up @@ -170,9 +170,11 @@ export default class AddFragment extends BaseDialog<AddFragmentModel> {
targetAggregation
};

await this.createFragmentChange(fragmentData);
const templateName = await this.createFragmentChange(fragmentData);

notifyUser(`Note: The '${fragmentName}.fragment.xml' fragment will be created once you save the change.`, 8000);
const textKey = templateName ? 'ADP_ADD_FRAGMENT_WITH_TEMPLATE_NOTIFICATION' : 'ADP_ADD_FRAGMENT_NOTIFICATION';
const bundle = await getTextBundle();
notifyUser(bundle.getText(textKey, [fragmentName]), 8000);

this.handleDialogClose();
}
Expand Down Expand Up @@ -279,7 +281,7 @@ export default class AddFragment extends BaseDialog<AddFragmentModel> {
*
* @param fragmentData Fragment Data
*/
private async createFragmentChange(fragmentData: CreateFragmentProps) {
private async createFragmentChange(fragmentData: CreateFragmentProps): Promise<string | undefined> {
const { fragmentName, index, targetAggregation } = fragmentData;

const flexSettings = this.rta.getFlexSettings();
Expand Down Expand Up @@ -310,6 +312,7 @@ export default class AddFragment extends BaseDialog<AddFragmentModel> {
CommunicationService.sendAction(setApplicationRequiresReload(true));
}
await this.commandExecutor.pushAndExecuteCommand(command);
return templateName;
}

private getFragmentTemplateName(targetAggregation: string): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ ADP_ADD_FRAGMENT_DIALOG_CONTROL_TYPE_LABEL = Control Type
ADP_ADD_FRAGMENT_DIALOG_AGGREGATION_LABEL = Target Aggregation
ADP_ADD_FRAGMENT_DIALOG_INDEX_LABEL = Index
ADP_ADD_FRAGMENT_DIALOG_FRAGMENT_NAME_LABEL = Fragment Name
ADP_ADD_FRAGMENT_NOTIFICATION = Note: The "{0}.fragment.xml" fragment will be created once you save the change.
ADP_ADD_FRAGMENT_WITH_TEMPLATE_NOTIFICATION = Note: The "{0}.fragment.xml" fragment will be created once you save the changes. After saving, reload the editor to see the change in UI.
ADP_SYNC_VIEWS_MESSAGE = Have in mind that synchronous views are detected for this application and controller extensions are not supported for such views. Controller extension functionality on these views will be disabled.
ADP_REUSE_COMPONENTS_MESSAGE = Have in mind that reuse components are detected for some views in this application and controller extensions and adding fragments are not supported for such views. Controller extension and adding fragment functionality on these views will be disabled.

Expand Down

0 comments on commit 4c770f0

Please sign in to comment.