Skip to content
Merged
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
2 changes: 2 additions & 0 deletions src/authz-module/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ export const rolesObject = [
userCount: 1,
name: 'Course Editor',
description: 'building and maintaining course content and supporting assets, without operational controls or high impact actions that can affect a live course.',
disabled: true,
},
{
role: 'course_auditor',
Expand All @@ -513,6 +514,7 @@ export const rolesObject = [
userCount: 1,
name: 'Course Auditor',
description: ' QA, compliance review, content review, and general oversight, no changes in Studio.',
disabled: true,
},

];
Expand Down
8 changes: 6 additions & 2 deletions src/authz-module/utils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ import { getCellHeader, getScopeManageAction, getScopeManageActionPermission } f
import { CONTENT_COURSE_PERMISSIONS, CONTENT_LIBRARY_PERMISSIONS } from './constants';

const renderCellHeader = (columnId: string, columnTitle: string, filtersApplied: string[]) => {
const component = getCellHeader(columnId, columnTitle, filtersApplied);
return renderWrapper(<div>{component}</div>);
const result = getCellHeader(columnId, columnTitle, filtersApplied);
if (typeof result === 'function') {
const Component = result;
return renderWrapper(<Component />);
}
return renderWrapper(<div>{result}</div>);
};

describe('utils', () => {
Expand Down
19 changes: 18 additions & 1 deletion src/authz-module/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,31 @@ import { Icon } from '@openedx/paragon';
import { FilterList } from '@openedx/paragon/icons';
import { CONTENT_COURSE_PERMISSIONS, CONTENT_LIBRARY_PERMISSIONS } from './constants';

/**
* Returns a header value for a DataTable column that shows a filter icon
* when the column has an active filter.
*
* When a filter is active, returns a **component function** with a custom
* toString() override. This is necessary because Paragon's TableRow builds
* cell keys via: `${cell.column.Header}${row.id}`
*
* - A JSX element stringifies to "[object Object]", causing duplicate keys.
* - A function with a custom toString() produces a unique string per column.
*
* react-table's render('Header') calls the function as a component, so the
* JSX is still rendered correctly in the table header.
*/
export const getCellHeader = (columnId: string, columnTitle: string, filtersApplied: string[]) => {
if (filtersApplied.includes(columnId)) {
return (
const FilteredHeader = () => (
<span className="d-flex flex-row align-items-center">
<Icon src={FilterList} size="sm" className="mr-2" />
{columnTitle}
</span>
);
FilteredHeader.displayName = `FilteredHeader_${columnId}`;
FilteredHeader.toString = () => `FilteredHeader_${columnId}`;
return FilteredHeader;
}
return columnTitle;
};
Expand Down