Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions packages/preview-middleware-client/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
},
rules: {
'quotes': ['error', 'single', { 'allowTemplateLiterals': true }],
'no-undef': 'off',
'valid-jsdoc': [
'error',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class AddHeaderFieldQuickAction
const headerContent = this.control.getHeaderContent();

// check if only flex box exist in the headerContent.
if (headerContent.length === 1 && isA<FlexBox>('sap.m.FlexBox', headerContent[0])) {
if (headerContent.length === 1 && isA('sap.m.FlexBox', headerContent[0])) {
const overlay = OverlayRegistry.getOverlay(headerContent[0]) || [];
await DialogFactory.createDialog(
overlay,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import ODataModelV2 from 'sap/ui/model/odata/v2/ODataModel';
import ODataMetaModelV2, { EntityContainer, EntitySet, EntityType } from 'sap/ui/model/odata/ODataMetaModel';
import TemplateComponent from 'sap/suite/ui/generic/template/lib/TemplateComponent';
import type AppComponent from 'sap/suite/ui/generic/template/lib/AppComponent';

import { getV2ApplicationPages } from '../../../utils/fe-v2';
Expand Down Expand Up @@ -53,7 +52,7 @@ export class AddNewSubpage extends AddNewSubpageBase<ODataMetaModelV2> {
}

protected getEntitySetNameFromPageComponent(component: Component | undefined): Promise<string> {
if (!isA<TemplateComponent>('sap.suite.ui.generic.template.lib.TemplateComponent', component)) {
if (!isA('sap.suite.ui.generic.template.lib.TemplateComponent', component)) {
throw new Error('Unexpected type of page owner component');
}
return Promise.resolve(component.getEntitySet());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import FlexCommand from 'sap/ui/rta/command/FlexCommand';
import type Table from 'sap/m/Table';
import type SmartTable from 'sap/ui/comp/smarttable/SmartTable';
import ManagedObject from 'sap/ui/base/ManagedObject';

import { QuickActionContext, NestedQuickActionDefinition } from '../../../cpe/quick-actions/quick-action-definition';
Expand Down Expand Up @@ -51,9 +49,9 @@ export class ChangeTableColumnsQuickAction
if (changeColumnActionId) {
const executeAction = async () =>
await this.context.actionService.execute(table.getId(), changeColumnActionId);
if (isA<SmartTable>(SMART_TABLE_TYPE, table)) {
if (isA(SMART_TABLE_TYPE, table)) {
await executeAction();
} else if (isA<Table>(M_TABLE_TYPE, table)) {
} else if (isA(M_TABLE_TYPE, table)) {
// if table is busy, i.e. lazy loading, then we subscribe to 'updateFinished' event and call action service when loading is done
// to avoid reopening the dialog after close
if (this.isTableLoaded(table)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import FlexCommand from 'sap/ui/rta/command/FlexCommand';
import type Table from 'sap/m/Table';
import type SmartTable from 'sap/ui/comp/smarttable/SmartTable';
import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
import ManagedObject from 'sap/ui/base/ManagedObject';
import UI5Element from 'sap/ui/core/Element';
Expand Down Expand Up @@ -88,21 +86,21 @@ export class AddTableActionQuickAction extends TableQuickActionDefinitionBase im

getHeaderToolbar(table: UI5Element): ManagedObject | ManagedObject[] | OverflowToolbar | null | undefined {
let headerToolbar;
if (isA<SmartTable>(SMART_TABLE_TYPE, table)) {
if (isA(SMART_TABLE_TYPE, table)) {
for (const item of table.getAggregation('items') as ManagedObject[]) {
if (item.getAggregation('headerToolbar')) {
headerToolbar = item.getAggregation('headerToolbar');
break;
}
if (isA<OverflowToolbar>('sap.m.OverflowToolbar', item)) {
if (isA('sap.m.OverflowToolbar', item)) {
headerToolbar = item;
break;
}
}
if (!headerToolbar) {
headerToolbar = table.getToolbar();
}
} else if (isA<Table>(M_TABLE_TYPE, table)) {
} else if (isA(M_TABLE_TYPE, table)) {
headerToolbar = table.getAggregation('headerToolbar');
}
return headerToolbar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import ObjectPageLayout from 'sap/uxap/ObjectPageLayout';

import IconTabBar from 'sap/m/IconTabBar';

import type SmartTable from 'sap/ui/comp/smarttable/SmartTable';

import { QuickActionContext, NestedQuickActionDefinition } from '../../../cpe/quick-actions/quick-action-definition';
import { getControlById, isA } from '../../../utils/core';
import { DialogNames, DialogFactory } from '../../dialog-factory';
Expand Down Expand Up @@ -90,20 +88,12 @@ export class AddTableCustomColumnQuickAction
preprocessActionExecution(table, sectionInfo, this.iconTabBar, iconTabBarFilterKey);
this.selectOverlay(table);

let tableInternal: ManagedObject | undefined = table;
if (isA<SmartTable>(SMART_TABLE_TYPE, table)) {
const itemsAggregation = table.getAggregation('items') as ManagedObject[];
tableInternal = itemsAggregation.find((item) => {
return [M_TABLE_TYPE, TREE_TABLE_TYPE, ANALYTICAL_TABLE_TYPE, GRID_TABLE_TYPE].some((tType) =>
isA(tType, item)
);
});
if (!tableInternal) {
return [];
}
const tableInternal = this.getInternalTable(table);
if (!tableInternal) {
return [];
}

const overlay = OverlayRegistry.getOverlay(tableInternal as UI5Element) || [];
const overlay = OverlayRegistry.getOverlay(tableInternal);
if (!overlay) {
return [];
}
Expand All @@ -119,11 +109,12 @@ export class AddTableCustomColumnQuickAction
});
return [];
}
const dialog = [TREE_TABLE_TYPE, ANALYTICAL_TABLE_TYPE, GRID_TABLE_TYPE].some((type) =>
isA(type, tableInternal)
)
? DialogNames.ADD_FRAGMENT
: DialogNames.ADD_TABLE_COLUMN_FRAGMENTS;
const dialog =
isA(TREE_TABLE_TYPE, tableInternal) ||
isA(ANALYTICAL_TABLE_TYPE, tableInternal) ||
isA(GRID_TABLE_TYPE, tableInternal)
? DialogNames.ADD_FRAGMENT
: DialogNames.ADD_TABLE_COLUMN_FRAGMENTS;
await DialogFactory.createDialog(
overlay,
this.context.rta,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ export class ToggleSemanticDateRangeFilterBar
const version = await getUi5Version();
const isLowerMinimalVersion = isLowerThanMinimalUi5Version(version, { major: 1, minor: 126 });
let entitySet;
if (isLowerMinimalVersion && isA<SmartFilterBar>(CONTROL_TYPE_LR, this.control)) {
if (isLowerMinimalVersion && isA(CONTROL_TYPE_LR, this.control)) {
// In older versions of UI5, the getEntitySet method is unavailable, so this workaround has been introduced.
const regex = /::([^:]+)--/;
entitySet = regex.exec(this.control?.getId() ?? '')?.[1];
} else {
entitySet =
isA<SmartFilterBar>(CONTROL_TYPE_LR, this.control) ||
isA<SmartFilterBar>(CONTROL_TYPE_ALP, this.control)
isA(CONTROL_TYPE_LR, this.control) ||
isA(CONTROL_TYPE_ALP, this.control)
? this.control.getEntitySet()
: undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class EnableTableFilteringQuickAction
return [];
}

const entitySet = isA<SmartTable>(SMART_TABLE_TYPE, this.control) ? this.control.getEntitySet() : undefined;
const entitySet = isA(SMART_TABLE_TYPE, this.control) ? this.control.getEntitySet() : undefined;
const command = await prepareManifestChange(
this.context,
'component/settings',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { preprocessActionExecution } from './create-table-custom-column';
export const ENABLE_TABLE_EMPTY_ROW_MODE = 'enable-table-empty-row-mode';

const CONTROL_TYPES = [SMART_TABLE_TYPE];
const UNSUPPORTED_TABLES = [ANALYTICAL_TABLE_TYPE, TREE_TABLE_TYPE];
const UNSUPPORTED_TABLES: (keyof TypeMap)[] = [ANALYTICAL_TABLE_TYPE, TREE_TABLE_TYPE];
const CREATION_ROWS_MODE = 'creationRows';
const OBJECT_PAGE_COMPONENT_NAME = 'sap.suite.ui.generic.template.ObjectPage';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Component from 'sap/ui/core/Component';
import type AppComponent from 'sap/suite/ui/generic/template/lib/AppComponent';
import type ManagedObject from 'sap/ui/base/ManagedObject';
import type TemplateComponent from 'sap/suite/ui/generic/template/lib/TemplateComponent';
import SmartTableExtended from 'sap/ui/comp/smarttable';
import { isA } from '../../../utils/core';

/**
* Gets app component of a v2 project.
Expand Down Expand Up @@ -120,7 +120,7 @@ export function isVariantManagementEnabledOPPage(
if (typeof id !== 'string') {
throw new Error('Could not retrieve configuration property because control id is not valid!');
}
if (!control.isA<SmartTableExtended>('sap.ui.comp.smarttable.SmartTable')) {
if (!isA('sap.ui.comp.smarttable.SmartTable', control)) {
// variant management is only supported by SmartTable
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import AppComponent from 'sap/fe/core/AppComponent';
import { getV4AppComponent, getV4ApplicationPages } from '../../../utils/fe-v4';
import { AddNewSubpageBase, ApplicationPageData } from '../add-new-subpage-quick-action-base';
import { isA } from '../../../utils/core';
import FEObjectPageComponent from 'sap/fe/templates/ObjectPage/Component';
import FEListReportComponent from 'sap/fe/templates/ListReport/Component';
import { getUi5Version, isLowerThanMinimalUi5Version } from '../../../utils/version';
import { PageDescriptorV4 } from '../../controllers/AddSubpage.controller';

Expand Down Expand Up @@ -122,8 +120,8 @@ export class AddNewSubpage extends AddNewSubpageBase<ODataMetaModelV4> {
metaModel: ODataMetaModelV4
): Promise<string | undefined> {
if (
!isA<FEObjectPageComponent>('sap.fe.templates.ListReport.Component', component) &&
!isA<FEListReportComponent>('sap.fe.templates.ObjectPage.Component', component)
!isA('sap.fe.templates.ListReport.Component', component) &&
!isA('sap.fe.templates.ObjectPage.Component', component)
) {
throw new Error('Unexpected type of page owner component');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { preprocessActionExecution } from '../fe-v2/create-table-custom-column';

export const ENABLE_TABLE_EMPTY_ROW_MODE = 'enable-table-empty-row-mode';
const CONTROL_TYPES = [MDC_TABLE_TYPE, GRID_TABLE_TYPE, ANALYTICAL_TABLE_TYPE, TREE_TABLE_TYPE];
const UNSUPPORTED_TABLES = [ANALYTICAL_TABLE_TYPE, TREE_TABLE_TYPE];
const UNSUPPORTED_TABLES: (keyof TypeMap)[] = [ANALYTICAL_TABLE_TYPE, TREE_TABLE_TYPE];

const INLINE_CREATION_ROWS_MODE = 'InlineCreationRows';
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import UI5Element from 'sap/ui/core/Element';
import { NESTED_QUICK_ACTION_KIND, NestedQuickAction } from '@sap-ux-private/control-property-editor-common';
import type IconTabBar from 'sap/m/IconTabBar';
import type IconTabFilter from 'sap/m/IconTabFilter';
import type Table from 'sap/m/Table';
import type MdcTable from 'sap/ui/mdc/Table';
import type SmartTable from 'sap/ui/comp/smarttable/SmartTable';
import { QuickActionContext } from '../../cpe/quick-actions/quick-action-definition';
import OverlayUtil from 'sap/ui/dt/OverlayUtil';
import type { NestedQuickActionChild } from '@sap-ux-private/control-property-editor-common';
Expand All @@ -14,7 +10,6 @@ import { getUi5Version, isLowerThanMinimalUi5Version } from '../../utils/version
import ObjectPageSection from 'sap/uxap/ObjectPageSection';
import ObjectPageSubSection from 'sap/uxap/ObjectPageSubSection';
import ObjectPageLayout from 'sap/uxap/ObjectPageLayout';
import ManagedObject from 'sap/ui/base/ManagedObject';
import { EnablementValidator } from './enablement-validator';
import { QuickActionDefinitionBase } from './quick-action-base';
import {
Expand All @@ -26,7 +21,6 @@ import {
TREE_TABLE_TYPE
} from './control-types';
import { isVariantManagementEnabledOPPage } from './fe-v2/utils';

const SMART_TABLE_ACTION_ID = 'CTX_COMP_VARIANT_CONTENT';
const M_TABLE_ACTION_ID = 'CTX_ADD_ELEMENTS_AS_CHILD';
const SETTINGS_ID = 'CTX_SETTINGS';
Expand Down Expand Up @@ -145,7 +139,7 @@ export abstract class TableQuickActionDefinitionBase extends QuickActionDefiniti
this.controlTypes
)) {
const tabKey = Object.keys(iconTabBarfilterMap).find((key) => table.getId().endsWith(key));
const section = getParentContainer<ObjectPageSection>(table, 'sap.uxap.ObjectPageSection');
const section = getParentContainer(table, 'sap.uxap.ObjectPageSection');
if (section) {
await this.collectChildrenInSection(section, table);
} else if (this.iconTabBar && tabKey) {
Expand Down Expand Up @@ -176,17 +170,27 @@ export abstract class TableQuickActionDefinitionBase extends QuickActionDefiniti
*/
protected getInternalTable(table: UI5Element): UI5Element | undefined {
try {
let tableInternal: ManagedObject | undefined;
if (!isA(SMART_TABLE_TYPE, table)) {
return undefined;
}

if (isA<SmartTable>(SMART_TABLE_TYPE, table)) {
const itemsAggregation = table.getAggregation('items') as ManagedObject[];
tableInternal = itemsAggregation.find((item) =>
[M_TABLE_TYPE, TREE_TABLE_TYPE, ANALYTICAL_TABLE_TYPE, GRID_TABLE_TYPE].some((tType) =>
isA(tType, item)
)
);
const itemsAggregation = table.getAggregation('items');
if (!Array.isArray(itemsAggregation)) {
return undefined;
}

for (const item of itemsAggregation) {
if (
isA(M_TABLE_TYPE, item) ||
isA(TREE_TABLE_TYPE, item) ||
isA(ANALYTICAL_TABLE_TYPE, item) ||
isA(GRID_TABLE_TYPE, item)
) {
return item;
}
}
return tableInternal as UI5Element | undefined;

return undefined;
} catch (error) {
return undefined;
}
Expand All @@ -198,12 +202,12 @@ export abstract class TableQuickActionDefinitionBase extends QuickActionDefiniti
* @returns table label if found or 'Unnamed table'
*/
private getTableLabel(table: UI5Element): string {
if (isA<SmartTable>(SMART_TABLE_TYPE, table) || isA<MdcTable>(MDC_TABLE_TYPE, table)) {
if (isA(SMART_TABLE_TYPE, table) || isA(MDC_TABLE_TYPE, table)) {
const header = table.getHeader();
if (header) {
return `'${header}' table`;
}
} else if (isA<Table>(M_TABLE_TYPE, table)) {
} else if (isA(M_TABLE_TYPE, table)) {
const title = table?.getHeaderToolbar()?.getTitleControl()?.getText();
if (title) {
return `'${title}' table`;
Expand All @@ -226,10 +230,10 @@ export abstract class TableQuickActionDefinitionBase extends QuickActionDefiniti
])[0];
if (tabBar) {
const control = getControlById(tabBar.getId());
if (isA<IconTabBar>(ICON_TAB_BAR_TYPE, control)) {
if (isA(ICON_TAB_BAR_TYPE, control)) {
this.iconTabBar = control;
for (const item of control.getItems()) {
if (isManagedObject(item) && isA<IconTabFilter>('sap.m.IconTabFilter', item)) {
if (isManagedObject(item) && isA('sap.m.IconTabFilter', item)) {
iconTabBarFilterMap[item.getKey()] = item.getText();
}
}
Expand All @@ -245,9 +249,9 @@ export abstract class TableQuickActionDefinitionBase extends QuickActionDefiniti
* @param table - table element
*/
private async collectChildrenInSection(section: ObjectPageSection, table: UI5Element): Promise<void> {
const layout = getParentContainer<ObjectPageLayout>(table, 'sap.uxap.ObjectPageLayout');
const layout = getParentContainer(table, 'sap.uxap.ObjectPageLayout');
const subSections = section.getSubSections();
const subSection = getParentContainer<ObjectPageSubSection>(table, 'sap.uxap.ObjectPageSubSection');
const subSection = getParentContainer(table, 'sap.uxap.ObjectPageSubSection');
if (subSection) {
if (subSections?.length === 1) {
await this.processTable(table, { section, subSection: subSections[0], layout });
Expand Down Expand Up @@ -293,14 +297,12 @@ export abstract class TableQuickActionDefinitionBase extends QuickActionDefiniti
): Promise<void> {
const tableMapKey = this.children.length.toString();
if (
[
SMART_TABLE_TYPE,
M_TABLE_TYPE,
MDC_TABLE_TYPE,
TREE_TABLE_TYPE,
GRID_TABLE_TYPE,
ANALYTICAL_TABLE_TYPE
].some((type) => isA(type, table))
isA(SMART_TABLE_TYPE, table) ||
isA(M_TABLE_TYPE, table) ||
isA(MDC_TABLE_TYPE, table) ||
isA(TREE_TABLE_TYPE, table) ||
isA(GRID_TABLE_TYPE, table) ||
isA(ANALYTICAL_TABLE_TYPE, table)
) {
const label = this.getTableLabel(table);
const child = this.createChild(label, table, tableMapKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ export class ChangeService extends EventTarget {
.map((id: string) => {
return getControlById(id);
})
.filter((ui5Element) => isA<UI5Element>('sap.ui.core.Element', ui5Element));
.filter((ui5Element) => isA('sap.ui.core.Element', ui5Element));
acc.push(...controls);
return acc;
}, [])
Expand Down
Loading
Loading