Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,27 @@ describe('ResourceField', () => {

expect(emitted).toHaveLength(0);
});

it('keeps navigation buttons enabled and emitting when the resource is unavailable', () => {
const field: FieldDefinition = {
property: 'action',
uiSettings: {
displayAs: 'button',
buttonSettings: { action: 'navigate' },
},
};
const { fixture, component } = setup(field, { isAvailable: false });
const emitted: ResourceFieldButtonClickEvent<GenericResource>[] = [];
component.buttonClick.subscribe((event) => emitted.push(event));

expect(component.buttonDisabled()).toBe(false);

q(fixture, 'ui5-button')?.dispatchEvent(
new MouseEvent('click', { bubbles: true }),
);

expect(emitted).toHaveLength(1);
});
});

describe('displayAs: tag', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,14 @@ export class ResourceField<
isBoolLike = computed(() => this.boolValue() !== undefined);
isUrlValue = computed(() => this.checkValidUrl(this.stringValue()));
testId = computed(() => `resource-field-${this.fieldDefinition().property}`);
buttonDisabled = computed(() => this.resource()?.isAvailable === false);
// Only mutating actions are disabled on unavailable resources; navigation
// and custom actions must keep working so a not-ready resource can still be
// opened and inspected.
buttonDisabled = computed(() => {
const action = this.uiSettings()?.buttonSettings?.action;
const isMutation = action === 'update' || action === 'delete';
return isMutation && this.resource()?.isAvailable === false;
});
buttonAccessibleName = computed(
() =>
(this.buttonDisabled() ? this.resource()?.accessibleName : undefined) ??
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,15 @@ export class DeclarativeTableCard<R extends GenericResource> {
}

onButtonClick(event: ResourceFieldButtonClickEvent<R>): void {
if (event.resource?.isAvailable === false) {
const action = event.field.uiSettings?.buttonSettings?.action;

// Block only mutating actions on unavailable resources; navigation and
// custom actions must keep working so a not-ready resource can still be
// opened and inspected.
const isMutation = action === 'update' || action === 'delete';
if (isMutation && event.resource?.isAvailable === false) {
return;
}

const action = event.field.uiSettings?.buttonSettings?.action;
if (action === 'update' && event.resource) {
this.pendingResource.set(event.resource);
void this.openEditDialog(event.resource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<ui5-table-row
[attr.data-testid]="'generic-table-row-' + i"
[class.disabled]="item.isAvailable === false"
[interactive]="item.isAvailable !== false"
[interactive]="true"
(click)="onRowClick(item)"
>
@for (column of viewColumns(); track columnTrackBy(column, $index)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

.disabled {
filter: brightness(0.92);
pointer-events: none;

ui5-table-cell:not(:first-child) {
color: var(--sapContent_DisabledTextColor, #6a6d70);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ describe('DeclarativeTable', () => {
expect(emitted[0]).toEqual(resource);
});

it('does not emit tableRowClicked for an unavailable resource', () => {
it('emits tableRowClicked for an unavailable resource so it can still be inspected', () => {
const resource = {
id: '1',
name: 'Alice',
Expand All @@ -250,7 +250,8 @@ describe('DeclarativeTable', () => {
const row = el(fixture, 'generic-table-row-0') as HTMLElement;
row.click();

expect(emitted).toHaveLength(0);
expect(emitted).toHaveLength(1);
expect(emitted[0]).toEqual(resource);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ export class DeclarativeTable<T extends GenericResource> {
viewColumns = computed(() => processGroupFields(this.columns()));

onRowClick(item: T): void {
if (item.isAvailable !== false) {
this.tableRowClicked.emit(item);
}
// Unavailable rows stay visually dimmed but remain clickable: a resource
// that is not ready is exactly the one a user needs to open and inspect.
this.tableRowClicked.emit(item);
}

isPagerMode = computed(() => this.loadMode() === 'pager');
Expand Down