Skip to content

Commit ded968e

Browse files
committed
refactor: remove add_message and change texts
1 parent b9697ac commit ded968e

File tree

5 files changed

+9
-162
lines changed

5 files changed

+9
-162
lines changed

packages/generator-adp/src/app/questions/helper/additional-messages.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Severity } from '@sap-devx/yeoman-ui-types';
22
import type { IMessageSeverity } from '@sap-devx/yeoman-ui-types';
33

44
import { AdaptationProjectType } from '@sap-ux/axios-extension';
5-
import type { AdaptationDescriptor } from '@sap-ux/axios-extension';
65
import type { FlexUISupportedSystem, SourceApplication } from '@sap-ux/adp-tooling';
76

87
import { t } from '../../../utils/i18n';
@@ -155,37 +154,3 @@ export const getTargetEnvAdditionalMessages = (
155154

156155
return undefined;
157156
};
158-
159-
/**
160-
* Provides additional messages for key-user prompts (system or password).
161-
*
162-
* @param {object} options - The options for the key-user additional messages.
163-
* @param {AdaptationDescriptor[]} options.adaptations - The list of adaptations available.
164-
* @param {boolean} options.isAuthRequired - Whether authentication is required.
165-
* @param {boolean} options.isSystemPrompt - Whether this is for the system prompt (true) or password prompt (false).
166-
* @returns {IMessageSeverity | undefined} Message object or undefined if no message is applicable.
167-
*/
168-
export const getKeyUserSystemAdditionalMessages = ({
169-
adaptations,
170-
isAuthRequired,
171-
isSystemPrompt
172-
}: {
173-
adaptations: AdaptationDescriptor[];
174-
isAuthRequired: boolean;
175-
isSystemPrompt: boolean;
176-
}): IMessageSeverity | undefined => {
177-
const authMatches = isSystemPrompt ? !isAuthRequired : isAuthRequired;
178-
179-
if (!authMatches) {
180-
return undefined;
181-
}
182-
183-
if (adaptations.length > 1) {
184-
return {
185-
message: t('prompts.keyUserAdaptationLabelMulti'),
186-
severity: Severity.information
187-
};
188-
}
189-
190-
return undefined;
191-
};

packages/generator-adp/src/app/questions/key-user.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import type {
2222
import { t } from '../../utils/i18n';
2323
import { keyUserPromptNames } from '../types';
2424
import { getAdaptationChoices, getKeyUserSystemChoices } from './helper/choices';
25-
import { getKeyUserSystemAdditionalMessages } from './helper/additional-messages';
2625

2726
export const DEFAULT_ADAPTATION_ID = 'DEFAULT';
2827

@@ -145,13 +144,7 @@ export class KeyUserImportPrompter {
145144
breadcrumb: true
146145
},
147146
default: options?.default ?? '',
148-
validate: async (value: string, answers: KeyUserImportAnswers) => await this.validateSystem(value, answers),
149-
additionalMessages: () =>
150-
getKeyUserSystemAdditionalMessages({
151-
adaptations: this.adaptations,
152-
isAuthRequired: this.isAuthRequired,
153-
isSystemPrompt: true
154-
})
147+
validate: async (value: string, answers: KeyUserImportAnswers) => await this.validateSystem(value, answers)
155148
} as ListQuestion<KeyUserImportAnswers>;
156149
}
157150

@@ -195,13 +188,7 @@ export class KeyUserImportPrompter {
195188
},
196189
when: (answers: KeyUserImportAnswers) => !!answers.keyUserSystem && this.isAuthRequired,
197190
validate: async (value: string, answers: KeyUserImportAnswers) =>
198-
await this.validatePassword(value, answers),
199-
additionalMessages: () =>
200-
getKeyUserSystemAdditionalMessages({
201-
adaptations: this.adaptations,
202-
isAuthRequired: this.isAuthRequired,
203-
isSystemPrompt: false
204-
})
191+
await this.validatePassword(value, answers)
205192
} as PasswordQuestion<KeyUserImportAnswers>;
206193
}
207194

packages/generator-adp/src/translations/generator-adp.i18n.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"importKeyUserChangesLabel": "Import Key User Changes",
5454
"keyUserAdaptationLabel": "Context-Based Adaptation",
5555
"keyUserAdaptationBreadcrumb": "Adaptation",
56-
"keyUserAdaptationLabelMulti": "There are multiple context-based adaptations. Select an adaptation to take over as an app variant.",
5756
"targetEnvLabel": "Environment",
5857
"targetEnvTooltip": "Select the target environment for your Adaptation Project.",
5958
"targetEnvBreadcrumb": "Target Environment",
@@ -111,10 +110,10 @@
111110
"projectDoesNotExistMta": "Provide the path to the MTA project where you want to have your Adaptation Project created.",
112111
"noAdaptableBusinessServiceFoundInMta": "No adaptable business service found in the MTA.",
113112
"fetchBaseInboundsFailed": "Fetching base application inbounds failed: {{error}}.",
114-
"keyUserNoChangesDefault": "Only a single adaptation ('DEFAULT') was found and no key-user changes were found for it. Please select a different system to continue, or click 'Back' and choose not to import key-user changes.",
115-
"keyUserNoChangesAdaptation": "No key-user changes have been found for the '{{adaptationId}}' adaptation.",
116-
"keyUserNoAdaptations": "No context-based adaptations have been found for the selected application.",
117-
"keyUserNotSupported": "The system does not allow or support the import of key-user changes."
113+
"keyUserNoChangesDefault": "Only a single adaptation ('DEFAULT') was found and no key-user changes were found for it. Please select a different system to continue, or navigate to the 'Project Attributes' page and click 'Back' and choose not to import key-user changes.",
114+
"keyUserNoChangesAdaptation": "No key-user changes have been found for the '{{adaptationId}}' adaptation. Please select a different adaptation.",
115+
"keyUserNoAdaptations": "No context-based adaptations have been found for the selected application. Please refer to the documentation.",
116+
"keyUserNotSupported": "The selected system does not allow or support the import of key-user changes. Please refer to the documentation."
118117
},
119118
"validators": {
120119
"ui5VersionNotDetectedError": "The SAPUI5 version of the selected system cannot be determined. You are able to create and edit adaptation projects that use the latest SAPUI5 version, but they are not usable on this system until the system's SAPUI5 version is upgraded to version 1.71 or higher."

packages/generator-adp/test/unit/questions/helper/additional-messages.test.ts

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@ import { Severity } from '@sap-devx/yeoman-ui-types';
22

33
import type { SourceApplication } from '@sap-ux/adp-tooling';
44
import { AdaptationProjectType } from '@sap-ux/axios-extension';
5-
import type { AdaptationDescriptor } from '@sap-ux/axios-extension';
65

76
import {
87
getAppAdditionalMessages,
98
getSystemAdditionalMessages,
109
getVersionAdditionalMessages,
11-
getTargetEnvAdditionalMessages,
12-
getKeyUserSystemAdditionalMessages
10+
getTargetEnvAdditionalMessages
1311
} from '../../../../src/app/questions/helper/additional-messages';
1412
import { initI18n, t } from '../../../../src/utils/i18n';
15-
import { DEFAULT_ADAPTATION_ID } from '../../../../src/app/questions/key-user';
1613

1714
describe('additional-messages', () => {
1815
beforeAll(async () => {
@@ -173,70 +170,4 @@ describe('additional-messages', () => {
173170
expect(result).toBeUndefined();
174171
});
175172
});
176-
177-
describe('getKeyUserSystemAdditionalMessages', () => {
178-
const mockDefaultAdaptation: AdaptationDescriptor = {
179-
id: DEFAULT_ADAPTATION_ID,
180-
title: '',
181-
type: 'DEFAULT'
182-
};
183-
184-
const mockMultipleAdaptations: AdaptationDescriptor[] = [
185-
mockDefaultAdaptation,
186-
{ id: 'CTX1', title: 'Context 1', type: 'CONTEXT', contexts: { role: ['/UI2/ADMIN'] } }
187-
];
188-
189-
it('should return message for multiple adaptations when auth matches', () => {
190-
const result = getKeyUserSystemAdditionalMessages({
191-
adaptations: mockMultipleAdaptations,
192-
isAuthRequired: false,
193-
isSystemPrompt: true
194-
});
195-
196-
expect(result).toEqual({
197-
message: t('prompts.keyUserAdaptationLabelMulti'),
198-
severity: Severity.information
199-
});
200-
});
201-
202-
it('should return undefined when auth does not match', () => {
203-
const result = getKeyUserSystemAdditionalMessages({
204-
adaptations: mockMultipleAdaptations,
205-
isAuthRequired: true,
206-
isSystemPrompt: true
207-
});
208-
209-
expect(result).toBeUndefined();
210-
});
211-
212-
it('should return undefined when auth does not match (password prompt, no auth)', () => {
213-
const result = getKeyUserSystemAdditionalMessages({
214-
adaptations: mockMultipleAdaptations,
215-
isAuthRequired: false,
216-
isSystemPrompt: false
217-
});
218-
219-
expect(result).toBeUndefined();
220-
});
221-
222-
it('should return undefined when no changes found for DEFAULT adaptation', () => {
223-
const result = getKeyUserSystemAdditionalMessages({
224-
adaptations: [mockDefaultAdaptation],
225-
isAuthRequired: false,
226-
isSystemPrompt: true
227-
});
228-
229-
expect(result).toBeUndefined();
230-
});
231-
232-
it('should return undefined when empty adaptations array', () => {
233-
const result = getKeyUserSystemAdditionalMessages({
234-
adaptations: [],
235-
isAuthRequired: false,
236-
isSystemPrompt: true
237-
});
238-
239-
expect(result).toBeUndefined();
240-
});
241-
});
242173
});

packages/generator-adp/test/unit/questions/key-user.test.ts

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ import type { SystemLookup } from '@sap-ux/adp-tooling';
1111
import { getConfiguredProvider } from '@sap-ux/adp-tooling';
1212
import { validateEmptyString } from '@sap-ux/project-input-validator';
1313

14-
import { getKeyUserSystemAdditionalMessages } from '../../../src/app/questions/helper/additional-messages';
15-
import { initI18n, t } from '../../../src/utils/i18n';
16-
import { keyUserPromptNames } from '../../../src/app/types';
1714
import {
1815
KeyUserImportPrompter,
1916
DEFAULT_ADAPTATION_ID,
2017
determineFlexVersion
2118
} from '../../../src/app/questions/key-user';
19+
import { initI18n, t } from '../../../src/utils/i18n';
20+
import { keyUserPromptNames } from '../../../src/app/types';
2221
import { getAdaptationChoices, getKeyUserSystemChoices } from '../../../src/app/questions/helper/choices';
2322

2423
jest.mock('@sap-ux/project-input-validator', () => ({
@@ -102,7 +101,6 @@ const getKeyUserDataMock = mockLayeredRepository.getKeyUserData as jest.Mock;
102101
const getFlexVersionsMock = mockLayeredRepository.getFlexVersions as jest.Mock;
103102
const listAdaptationsMock = mockLayeredRepository.listAdaptations as jest.Mock;
104103
const getSystemRequiresAuthMock = systemLookup.getSystemRequiresAuth as jest.Mock;
105-
const getKeyUserSystemAdditionalMessagesMock = getKeyUserSystemAdditionalMessages as jest.Mock;
106104

107105
describe('KeyUserImportPrompter', () => {
108106
const componentId = 'demoapps.rta';
@@ -116,7 +114,6 @@ describe('KeyUserImportPrompter', () => {
116114
beforeEach(() => {
117115
jest.clearAllMocks();
118116
validateEmptyStringMock.mockReturnValue(true);
119-
getKeyUserSystemAdditionalMessagesMock.mockReturnValue(undefined);
120117
getAdaptationChoicesMock.mockReturnValue([{ name: 'Default Adaptation', value: mockAdaptations[0] }]);
121118
getKeyUserSystemChoicesMock.mockReturnValue([
122119
{ name: 'SystemA', value: 'SystemA' },
@@ -257,22 +254,6 @@ describe('KeyUserImportPrompter', () => {
257254
expect(result).toBe('Connection failed');
258255
});
259256
});
260-
261-
describe('additionalMessages', () => {
262-
it('should call getKeyUserSystemAdditionalMessages with correct parameters', () => {
263-
prompter['adaptations'] = mockAdaptations;
264-
prompter['isAuthRequired'] = false;
265-
266-
const prompt = prompter['getSystemPrompt']();
267-
prompt?.additionalMessages?.();
268-
269-
expect(getKeyUserSystemAdditionalMessagesMock).toHaveBeenCalledWith({
270-
adaptations: mockAdaptations,
271-
isAuthRequired: false,
272-
isSystemPrompt: true
273-
});
274-
});
275-
});
276257
});
277258

278259
describe('Username Prompt', () => {
@@ -386,22 +367,6 @@ describe('KeyUserImportPrompter', () => {
386367
});
387368
});
388369

389-
describe('additionalMessages', () => {
390-
it('should call getKeyUserSystemAdditionalMessages with correct parameters', () => {
391-
prompter['adaptations'] = mockAdaptations;
392-
prompter['isAuthRequired'] = true;
393-
394-
const prompt = prompter['getPasswordPrompt']();
395-
prompt?.additionalMessages?.();
396-
397-
expect(getKeyUserSystemAdditionalMessagesMock).toHaveBeenCalledWith({
398-
adaptations: mockAdaptations,
399-
isAuthRequired: true,
400-
isSystemPrompt: false
401-
});
402-
});
403-
});
404-
405370
describe('when', () => {
406371
it('should return true when auth is required and system is selected', () => {
407372
prompter['isAuthRequired'] = true;

0 commit comments

Comments
 (0)