Skip to content

Commit

Permalink
Merge branch 'main' into test/0/pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
voicis authored Nov 15, 2024
2 parents aa25676 + 4b75e2d commit 8e1796a
Show file tree
Hide file tree
Showing 23 changed files with 250 additions and 28 deletions.
8 changes: 8 additions & 0 deletions examples/ui-prompting-examples/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @sap-ux-private/ui-prompting-examples

## 0.2.17

### Patch Changes

- Updated dependencies [32191dd]
- @sap-ux/ui-components@1.21.1
- @sap-ux/ui-prompting@0.3.3

## 0.2.16

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/ui-prompting-examples/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sap-ux-private/ui-prompting-examples",
"version": "0.2.16",
"version": "0.2.17",
"description": "This project contains UI storybook stories with exampleS with prompt ui and FPM based building blocks.",
"license": "Apache-2.0",
"private": true,
Expand Down
8 changes: 8 additions & 0 deletions packages/create/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @sap-ux/create

## 0.8.77

### Patch Changes

- Updated dependencies [f2d3335]
- @sap-ux/preview-middleware@0.16.117
- @sap-ux/app-config-writer@0.4.52

## 0.8.76

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/create/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@sap-ux/create",
"description": "SAP Fiori tools module to add or remove features",
"version": "0.8.76",
"version": "0.8.77",
"repository": {
"type": "git",
"url": "https://github.com/SAP/open-ux-tools.git",
Expand Down
6 changes: 6 additions & 0 deletions packages/preview-middleware-client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @sap-ux-private/preview-middleware-client

## 0.11.30

### Patch Changes

- f2d3335: Hide "Semantic Date Range" Quick Action behind feature toggle.

## 0.11.29

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/preview-middleware-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sap-ux-private/preview-middleware-client",
"version": "0.11.29",
"version": "0.11.30",
"description": "Client-side coding hosted by the preview middleware",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import FlexCommand from 'sap/ui/rta/command/FlexCommand';
import FilterBar from 'sap/ui/mdc/FilterBar';

import { FeatureService } from '../../../cpe/feature-service';
import { QuickActionContext, SimpleQuickActionDefinition } from '../../../cpe/quick-actions/quick-action-definition';
import { pageHasControlId } from '../../../cpe/quick-actions/utils';
import { getControlById } from '../../../utils/core';
Expand Down Expand Up @@ -28,6 +29,9 @@ export class ToggleSemanticDateRangeFilterBar
private isUseDateRangeTypeEnabled = false;

initialize(): void {
if (FeatureService.isFeatureEnabled('cpe.beta.quick-actions') === false) {
return;
}
const controls = this.context.controlIndex[CONTROL_TYPE] ?? [];
for (const control of controls) {
const isActionApplicable = pageHasControlId(this.context.view, control.controlId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,91 @@ describe('FE V2 quick actions', () => {
});

describe('disable/enable "Semantic Date Range" in Filter Bar', () => {
test('not available by default', async () => {
jest.spyOn(FeatureService, 'isFeatureEnabled').mockReturnValue(false);
const appComponent = new AppComponentMock();
const component = new TemplateComponentMock();
jest.spyOn(component, 'getAppComponent').mockReturnValue(appComponent);
jest.spyOn(ComponentMock, 'getOwnerComponentFor').mockImplementation(() => {
return component as unknown as UIComponent;
});
sapCoreMock.byId.mockImplementation((id) => {
if (id == 'FilterBar') {
return {
getDomRef: () => ({}),
getParent: () => ({}),
data: jest.fn().mockImplementation((key) => {
// Mock the return value for 'useSemanticDateRange'
if (key === 'useSemanticDateRange') {
return true;
}
return undefined;
})
};
}
if (id == 'NavContainer') {
const container = new NavContainer();
const pageView = new XMLView();
pageView.getDomRef.mockImplementation(() => {
return {
contains: () => true
};
});
pageView.getId.mockReturnValue('test.app::ProductsList');
pageView.getViewName.mockImplementation(() => 'sap.fe.templates.ListReport.ListReport');
const componentContainer = new ComponentContainer();
jest.spyOn(componentContainer, 'getComponent').mockImplementation(() => {
return 'component-id';
});
jest.spyOn(Component, 'getComponentById').mockImplementation((id: string | undefined) => {
if (id === 'component-id') {
return component;
}
});
container.getCurrentPage.mockImplementation(() => {
return componentContainer;
});
component.getRootControl.mockImplementation(() => {
return pageView;
});
return container;
}
});

CommandFactory.getCommandFor.mockImplementation((control, type, value, _, settings) => {
return { type, value, settings };
});

const rtaMock = new RuntimeAuthoringMock({} as RTAOptions) as unknown as RuntimeAuthoring;
const registry = new FEV4QuickActionRegistry();
const service = new QuickActionService(rtaMock, new OutlineService(rtaMock, mockChangeService), [
registry
]);
await service.init(sendActionMock, subscribeMock);

await service.reloadQuickActions({
'sap.fe.macros.controls.FilterBar': [
{
controlId: 'FilterBar'
} as any
],
'sap.m.NavContainer': [
{
controlId: 'NavContainer'
} as any
]
});

expect(sendActionMock).toHaveBeenCalledWith(
quickActionListChanged([
{
title: 'LIST REPORT',
actions: []
}
])
);
});

test('initialize and execute action', async () => {
const appComponent = new AppComponentMock();
const component = new TemplateComponentMock();
Expand Down Expand Up @@ -949,7 +1034,8 @@ describe('FE V2 quick actions', () => {
parameters: {
page: 'ProductsList',
entityPropertyChange: {
propertyPath: 'controlConfiguration/@com.sap.vocabularies.UI.v1.SelectionFields/useSemanticDateRange',
propertyPath:
'controlConfiguration/@com.sap.vocabularies.UI.v1.SelectionFields/useSemanticDateRange',
propertyValue: false,
operation: 'UPSERT'
}
Expand Down
6 changes: 6 additions & 0 deletions packages/preview-middleware/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @sap-ux/preview-middleware

## 0.16.117

### Patch Changes

- f2d3335: Hide "Semantic Date Range" Quick Action behind feature toggle.

## 0.16.116

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/preview-middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"bugs": {
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apreview-middleware"
},
"version": "0.16.116",
"version": "0.16.117",
"license": "Apache-2.0",
"author": "@SAP/ux-tools-team",
"main": "dist/index.js",
Expand Down
6 changes: 6 additions & 0 deletions packages/reload-middleware/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @sap-ux/reload-middleware

## 0.2.6

### Patch Changes

- f2d3335: Expose `watchManifestChanges` function.

## 0.2.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/reload-middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"bugs": {
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Areload-middleware"
},
"version": "0.2.5",
"version": "0.2.6",
"author": "@SAP/ux-tools-team",
"license": "Apache-2.0",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/reload-middleware/src/base/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { getLivereloadServer, getConnectLivereload } from './livereload';
export { getLivereloadServer, getConnectLivereload, watchManifestChanges } from './livereload';
export { ReloaderConfig, LiveReloadOptions, ConnectLivereloadOptions, HttpsOptions } from './types';
export { defaultLiveReloadOpts, defaultConnectLivereloadOpts } from './constants';
1 change: 1 addition & 0 deletions packages/reload-middleware/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export {
getLivereloadServer,
getConnectLivereload,
watchManifestChanges,
ReloaderConfig,
LiveReloadOptions,
ConnectLivereloadOptions,
Expand Down
6 changes: 6 additions & 0 deletions packages/ui-components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @sap-ux/ui-components

## 1.21.1

### Patch Changes

- 32191dd: UITranslationInput. Screen readers read the resolved translation tooltip/title of UITranslationInput as part of the screen reader speech, displaying it as 'Value: ... Translation: ...'.

## 1.21.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sap-ux/ui-components",
"version": "1.21.0",
"version": "1.21.1",
"license": "Apache-2.0",
"description": "SAP UI Components Library",
"repository": {
Expand Down
47 changes: 34 additions & 13 deletions packages/ui-components/src/components/UIInput/UITextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const COLOR_STYLES = {
}
};

type InputRenderProps = React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>;
export type InputRenderProps = React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>;

/**
* UITextInput component
Expand All @@ -57,7 +57,7 @@ export class UITextInput extends React.Component<UITextInputProps> {
public constructor(props: UITextInputProps) {
super(props);

this.onRenderDisabledInput = this.onRenderDisabledInput.bind(this);
this.onRenderInput = this.onRenderInput.bind(this);
}

/**
Expand Down Expand Up @@ -227,25 +227,46 @@ export class UITextInput extends React.Component<UITextInputProps> {
};

/**
* Method to render HTML input element.
* Method to extend HTML input element.
* Custom rendering is used to use "readonly" attribute instead of "disabled" to make disabled field focusable.
*
* @param {InputRenderProps} [props] Input props.
* @param {(props?: InputRenderProps) => JSX.Element | null} [defaultRender] Default renderer.
* @returns {JSX.Element | null} Input element to render.
*/
private onRenderDisabledInput = (
private onRenderDisabledInput(
props?: InputRenderProps,
defaultRender?: (props?: InputRenderProps) => JSX.Element | null
): JSX.Element | null => {
const inputProps = {
...props,
disabled: undefined,
readOnly: true,
['aria-disabled']: true
};
): JSX.Element | null {
const inputProps = this.props.disabled
? {
...props,
disabled: undefined,
readOnly: true,
['aria-disabled']: true
}
: props;
return defaultRender?.(inputProps) || null;
};
}

/**
* Method to render HTML input element.
*
* @param {InputRenderProps} [props] Input props.
* @param {(props?: InputRenderProps) => JSX.Element | null} [defaultRender] Default renderer.
* @returns {JSX.Element | null} Input element to render.
*/
private onRenderInput(
props?: InputRenderProps,
defaultRender?: (props?: InputRenderProps) => JSX.Element | null
): JSX.Element | null {
if (this.props.onRenderInput) {
return this.props.onRenderInput(props, (renderProps?: InputRenderProps): JSX.Element | null => {
return this.onRenderDisabledInput(renderProps, defaultRender);
});
}
return this.onRenderDisabledInput(props, defaultRender);
}

/**
* @returns {JSX.Element}
Expand All @@ -255,8 +276,8 @@ export class UITextInput extends React.Component<UITextInputProps> {
const textFieldStyles = this.getStyles;
return (
<TextField
onRenderInput={this.props.disabled ? this.onRenderDisabledInput : undefined}
{...this.props}
onRenderInput={this.onRenderInput}
errorMessage={messageInfo.message}
styles={textFieldStyles}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,11 @@
}
}
}
&__field {
width: 100%;
height: 100%;
input {
height: 100%;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback } from 'react';
import type { ReactElement } from 'react';
import { UITextInput } from '../UIInput';
import type { ITextFieldProps } from '../UIInput';
import type { InputRenderProps, ITextFieldProps } from '../UIInput';
import { UiIcons } from '../Icons';
import { UITranslationButton } from './UITranslationButton';
import type {
Expand Down Expand Up @@ -216,12 +216,29 @@ export const UITranslationInput = <T extends TranslationEntry = TranslationEntry
onUpdateValue
]);

const onRenderInput = useCallback(
(
props?: InputRenderProps,
defaultRender?: (props?: InputRenderProps) => JSX.Element | null
): JSX.Element | null => {
if (defaultRender) {
return (
<div className="ui-translatable__field" title={title}>
{defaultRender({ ...props, title: undefined })}
</div>
);
}
return null;
},
[title]
);

return (
<UITextInput
{...props}
title={title}
onRenderSuffix={value?.trim() ? onRenderSuffix : undefined}
className={classNames}
onRenderInput={onRenderInput}
/>
);
};
Expand Down
Loading

0 comments on commit 8e1796a

Please sign in to comment.