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: Modified indicators incorrectly displayed for some UI5 controls in Adaptation Project #2264

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0e58c1a
fix: incorrectly placed modified indicators
mmilko01 Aug 21, 2024
21d92fd
refacor: enhance types
mmilko01 Aug 27, 2024
0c74987
fix: type
mmilko01 Aug 27, 2024
3f485ce
refactor: get control instance based on App Component
mmilko01 Aug 28, 2024
8e35073
fix: check if change is available
mmilko01 Aug 28, 2024
5c8efed
Merge branch 'main' into fix/2263/incorrect-modified-indicators
mmilko01 Aug 28, 2024
d67e8eb
refactor: dynamically import ChangeHandlerAPI
mmilko01 Aug 29, 2024
0035131
refactor: get control id via JsControlTreeModifier
mmilko01 Aug 29, 2024
5eefabb
refactor: use different FL API based on UI5 Version
mmilko01 Aug 30, 2024
92f9fb5
test: amend tests
mmilko01 Sep 11, 2024
c4aafd3
chore: merge with main
mmilko01 Sep 11, 2024
e9018da
chore: fix main merge conflicts
mmilko01 Sep 11, 2024
11bd958
chore: create changeset
mmilko01 Sep 11, 2024
2b73513
Merge branch 'main' into fix/2263/incorrect-modified-indicators
mmilko01 Sep 11, 2024
130ba00
chore: fix lint error
mmilko01 Sep 11, 2024
dbc093f
Merge branch 'fix/2263/incorrect-modified-indicators' of https://gith…
mmilko01 Sep 11, 2024
0e6a23a
test: add tests
mmilko01 Sep 12, 2024
55b6b23
fix: sonar issue
mmilko01 Sep 12, 2024
b4f4ee6
test: improve coverage
mmilko01 Sep 12, 2024
4c99027
fix: lint issue
mmilko01 Sep 12, 2024
5dfca73
doc: fix JSDoc
mmilko01 Sep 12, 2024
1931d00
Merge branch 'main' into fix/2263/incorrect-modified-indicators
mmilko01 Sep 13, 2024
9931f05
refactor: do not leak change files to UI
mmilko01 Sep 13, 2024
67f0abf
Merge branch 'fix/2263/incorrect-modified-indicators' of https://gith…
mmilko01 Sep 13, 2024
748bd9d
refactor: change Selector type
mmilko01 Sep 13, 2024
75d7ba3
Merge branch 'main' into fix/2263/incorrect-modified-indicators
mmilko01 Sep 13, 2024
574c393
Merge branch 'main' into fix/2263/incorrect-modified-indicators
mmilko01 Sep 16, 2024
809dc7f
refactor: change changeFiles type
mmilko01 Sep 16, 2024
21ab914
refactor: define changedFiles as object
mmilko01 Sep 16, 2024
64b1527
fix: resolve conflicts
mmilko01 Oct 15, 2024
5a86c0d
fix: correctly display control changes
mmilko01 Oct 17, 2024
729bc12
feat: add control change component
nikmace Oct 17, 2024
fa6bd6e
Merge branch 'main' into fix/2263/incorrect-modified-indicators
mmilko01 Oct 17, 2024
9c4030d
chore: return cap.ts to original state
mmilko01 Oct 17, 2024
65d7d2f
refactor: rename interface
nikmace Oct 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions packages/control-property-editor-common/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export const PENDING_CHANGE_TYPE = 'pending';
export const SAVED_CHANGE_TYPE = 'saved';
export const PROPERTY_CHANGE_KIND = 'property';
export const UNKNOWN_CHANGE_KIND = 'unknown';
export const CONTROL_CHANGE_KIND = 'control';
export interface PendingPropertyChange<T extends PropertyValue = PropertyValue> extends PropertyChange<T> {
type: typeof PENDING_CHANGE_TYPE;
kind: typeof PROPERTY_CHANGE_KIND;
Expand All @@ -134,13 +135,20 @@ export interface PendingOtherChange {
kind: typeof UNKNOWN_CHANGE_KIND;
isActive: boolean;
changeType: string;
fileName: string;
}

export interface PendingControlChange {
type: typeof PENDING_CHANGE_TYPE;
kind: typeof CONTROL_CHANGE_KIND;
isActive: boolean;
changeType: string;
controlId: string;
controlName: string;
fileName: string;
}

export type PendingChange = PendingPropertyChange | PendingOtherChange;
export type SavedChange = SavedPropertyChange | UnknownSavedChange;
export type PendingChange = PendingPropertyChange | PendingOtherChange | PendingControlChange;
export type SavedChange = SavedPropertyChange | UnknownSavedChange | ControlSavedChange;

export interface SavedPropertyChange<T extends PropertyValue = PropertyValue> extends PropertyChange<T> {
type: typeof SAVED_CHANGE_TYPE;
Expand All @@ -154,7 +162,15 @@ export interface UnknownSavedChange {
kind: typeof UNKNOWN_CHANGE_KIND;
fileName: string;
changeType: string;
controlId?: string;
timestamp?: number;
}

export interface ControlSavedChange {
Copy link
Contributor

Choose a reason for hiding this comment

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

This word order sounds quite strange. It would be better if it matched other change type names e.g PendingControlChange and SavedPropertyChange.

Suggested change
export interface ControlSavedChange {
export interface SavedControlChange {

Copy link
Contributor

Choose a reason for hiding this comment

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

Renamed in: 65d7d2f

type: typeof SAVED_CHANGE_TYPE;
kind: typeof CONTROL_CHANGE_KIND;
controlId: string;
fileName: string;
changeType: string;
timestamp?: number;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import { Stack } from '@fluentui/react';
import type { Change } from '@sap-ux-private/control-property-editor-common';
import {
CONTROL_CHANGE_KIND,
convertCamelCaseToPascalCase,
PENDING_CHANGE_TYPE,
PROPERTY_CHANGE_KIND,
Expand Down Expand Up @@ -93,22 +94,34 @@ function convertChanges(changes: Change[]): Item[] {
while (i < changes.length) {
const change: Change = changes[i];
let group: ControlGroupProps;
if (change.kind === UNKNOWN_CHANGE_KIND && change.type === SAVED_CHANGE_TYPE) {
items.push({
if (change.kind === UNKNOWN_CHANGE_KIND) {
const item = {
fileName: change.fileName,
timestamp: change.timestamp,
header: true,
controlId: change.controlId ?? ''
});
timestamp: change.type === SAVED_CHANGE_TYPE ? change.timestamp : undefined
};
items.push(item);
i++;
} else {
group = {
controlId: change.controlId,
controlName: change.controlName,
text: convertCamelCaseToPascalCase(change.controlName),
index: i,
changes: [change]
};
if (change.kind === CONTROL_CHANGE_KIND) {
group = {
controlId: change.controlId,
controlName: '',
text: '',
index: i,
changes: [change],
timestamp: change.type === SAVED_CHANGE_TYPE ? change.timestamp : undefined
};
} else {
group = {
controlId: change.controlId,
controlName: change.controlName,
text: convertCamelCaseToPascalCase(change.controlName),
index: i,
changes: [change],
timestamp: change.type === SAVED_CHANGE_TYPE ? change.timestamp : undefined
};
}
items.push(group);
i++;
while (i < changes.length) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
.text {
line-height: 18px;
display: inline-block;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
color: var(--vscode-editor-foreground);
width: 240px;
direction: rtl;
text-align: left;
}
.fileLabel {
min-width: 30px;
margin-top: 5px;
}
.fileText {
margin-top: 5px;
line-height: 18px;
display: inline-block;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
color: var(--vscode-editor-foreground);
width: 210px;
direction: rtl;
text-align: left;
}
.controlLabel {
min-width: 75px;
margin-top: 5px;
}
.controlText {
margin-top: 5px;
line-height: 18px;
display: inline-block;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
color: var(--vscode-editor-foreground);
width: 165px;
direction: rtl;
text-align: left;
}
.timestamp {
margin-top: 5px;
color: var(--vscode-editor-foreground);
font-size: 11px;
line-height: 15px;
opacity: 0.5;
}
.textHeader {
display: inline-block;
color: var(--vscode-foreground);
font-size: 13px;
font-weight: bold;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
line-height: 18px;
}

.property {
overflow-wrap: anywhere;

&:hover {
background-color: var(--vscode-dropdown-background);
color: var(--vscode-dropdown-foreground);
outline: 1px dashed var(--vscode-contrastActiveBorder);

.actions {
visibility: visible;
}
}
}

.actions {
visibility: hidden;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import type { ReactElement } from 'react';
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Text, Stack, Link } from '@fluentui/react';
import { useDispatch } from 'react-redux';
import styles from './ControlChange.module.scss';
import { UIIconButton, UiIcons, UIDialog } from '@sap-ux/ui-components';
import type {
ControlSavedChange,
PendingControlChange,
PropertyChangeDeletionDetails
} from '@sap-ux-private/control-property-editor-common';
import {
SAVED_CHANGE_TYPE,
convertCamelCaseToPascalCase,
deletePropertyChanges,
selectControl
} from '@sap-ux-private/control-property-editor-common';
import { getFormattedDateAndTime } from './utils';

export interface ControlChangeProps {
/**
* Class used for showing and hiding actions
*/
actionClassName: string;
change: PendingControlChange | ControlSavedChange;
}

/**
* React element for control change in change stack.
*
* @returns ReactElement
*/
export function ControlChange({ change }: ControlChangeProps): ReactElement {
const { changeType, controlId, fileName, type, kind } = change;
const { t } = useTranslation();
const dispatch = useDispatch();
const [dialogState, setDialogState] = useState<PropertyChangeDeletionDetails | undefined>(undefined);

function onConfirmDelete(): void {
if (dialogState) {
dispatch(deletePropertyChanges(dialogState));
setDialogState(undefined);
}
}

function onCancelDelete(): void {
setDialogState(undefined);
}

const parts = fileName.split('_');
const changeName = parts[parts.length - 1];
const name = convertCamelCaseToPascalCase(changeName);

return (
<>
<Stack.Item className={styles.property}>
<Stack horizontal>
<Stack.Item>
{changeType === 'renameLabel' ? (
<Link
className={styles.textHeader}
onClick={(): void => {
const action = selectControl(controlId);
dispatch(action);
}}
style={{
color: 'var(--vscode-textLink-foreground)',
fontSize: '13px',
fontWeight: 'bold',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
overflowX: 'hidden',
lineHeight: '18px'
}}>
{name} {t('CHANGE')}
</Link>
) : (
<Text className={styles.textHeader}>
{name} {t('CHANGE')}
</Text>
)}

<Stack horizontal>
<Stack.Item className={styles.fileLabel}>{t('FILE')}</Stack.Item>
<Stack.Item className={styles.fileText} title={fileName}>
{fileName}
</Stack.Item>
</Stack>
{controlId && (
<Stack horizontal>
<Stack.Item className={styles.controlLabel}>{t('CONTROL')}</Stack.Item>
<Stack.Item className={styles.controlText} title={controlId}>
{controlId}
</Stack.Item>
</Stack>
)}
</Stack.Item>

{fileName && (
<Stack.Item className={styles.actions}>
<UIIconButton
iconProps={{ iconName: UiIcons.TrashCan }}
onClick={(): void => {
setDialogState({
controlId: '',
propertyName: '',
fileName
});
}}
/>
</Stack.Item>
)}
</Stack>
</Stack.Item>
{type === SAVED_CHANGE_TYPE && (
<Stack.Item>
<Stack horizontal horizontalAlign="space-between">
<Text className={styles.timestamp}>{getFormattedDateAndTime(change.timestamp ?? 0)}</Text>
</Stack>
</Stack.Item>
)}
{dialogState && (
<UIDialog
hidden={dialogState === undefined}
onAccept={onConfirmDelete}
acceptButtonText={t('CONFIRM_DELETE')}
cancelButtonText={t('CANCEL_DELETE')}
onCancel={onCancelDelete}
dialogContentProps={{
title: t('CONFIRM_OTHER_CHANGE_DELETE_TITLE'),
subText: t('CONFIRM_OTHER_CHANGE_DELETE_SUBTEXT', { name })
}}
/>
)}
</>
);
}
Loading
Loading