@autobusal/common 1.26.0 → 1.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/Table/Header/Header.tsx +2 -1
- package/Table/Rows/Rows.tsx +2 -1
- package/Table/rowActions.ts +22 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.26.1
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **`Table` drew an empty "Options" column when a table had only
|
|
8
|
+
top-of-table controls.** `create`, `search` and `extra` all live *above* the
|
|
9
|
+
table — `Actions/Get` already returns null for each — but `Header` and
|
|
10
|
+
`Rows` decided whether to draw the options column from `actions.length > 0`,
|
|
11
|
+
which counted them. A table using the component purely for sorting, search
|
|
12
|
+
and paging therefore got an "Options" heading with an empty cell under every
|
|
13
|
+
row.
|
|
14
|
+
|
|
15
|
+
Invisible on the admin screens, where every table has row actions anyway;
|
|
16
|
+
visible the moment the public bus-company directory used it. The row/top
|
|
17
|
+
split is one shared list now (`Table/rowActions.ts`) rather than a condition
|
|
18
|
+
repeated in three files that could drift.
|
|
19
|
+
|
|
3
20
|
## 1.26.0
|
|
4
21
|
|
|
5
22
|
### Added
|
package/Table/Header/Header.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TFunction } from 'i18next';
|
|
2
2
|
import Sort from './Sort';
|
|
3
3
|
import { getUrl } from '../browseUrl';
|
|
4
|
+
import { rowActions } from '../rowActions';
|
|
4
5
|
import { Container, Td, Column, Text } from './styles';
|
|
5
6
|
import { ColumnData, SortingData } from '../types';
|
|
6
7
|
|
|
@@ -31,7 +32,7 @@ const Header = ({ url, data, sorting, t, actions }: Props): JSX.Element => {
|
|
|
31
32
|
<tr>
|
|
32
33
|
{ columns }
|
|
33
34
|
|
|
34
|
-
{ (actions
|
|
35
|
+
{ rowActions(actions).length > 0 && (
|
|
35
36
|
<Td $width={ 10 }>
|
|
36
37
|
<Column>
|
|
37
38
|
<Text>{ t('table.options', { ns: 'common' }) }</Text>
|
package/Table/Rows/Rows.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import { NavigateFunction } from 'react-router-dom';
|
|
|
3
3
|
import Loading from './Loading';
|
|
4
4
|
import NotFound from './NotFound';
|
|
5
5
|
import Actions from '../Actions/Actions';
|
|
6
|
+
import { rowActions } from '../rowActions';
|
|
6
7
|
import { Tbody, Tr } from './styles';
|
|
7
8
|
|
|
8
9
|
interface Props {
|
|
@@ -39,7 +40,7 @@ const Rows = ({ url, urlWith, data, loading, fetching, colLength, t, actions, ha
|
|
|
39
40
|
<Tr key={ index } $viewable={ isViewable } onClick={ () => onClick(item.props.id) }>
|
|
40
41
|
{ item }
|
|
41
42
|
|
|
42
|
-
{ (actions
|
|
43
|
+
{ rowActions(actions).length > 0 && (
|
|
43
44
|
<Actions
|
|
44
45
|
id={ item.props.id }
|
|
45
46
|
url={ url }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which of a table's actions belong to a ROW rather than to the top of the
|
|
3
|
+
* table.
|
|
4
|
+
*
|
|
5
|
+
* Ferjolt Ozuni - Date: 2026-08-06
|
|
6
|
+
*
|
|
7
|
+
* `create`, `search` and `extra` are all controls that live ABOVE the table -
|
|
8
|
+
* Top renders them and Actions/Get already returns null for each. But Header
|
|
9
|
+
* and Rows both decided whether to draw the options column from
|
|
10
|
+
* `actions.length > 0`, counting those three, so a table with only
|
|
11
|
+
* top-of-table controls got an "Options" heading with an empty cell under
|
|
12
|
+
* every row. Harmless on the admin screens, where every table has row actions
|
|
13
|
+
* anyway - visible the moment a PUBLIC page used the component for its
|
|
14
|
+
* sorting and paging alone.
|
|
15
|
+
*
|
|
16
|
+
* One list, shared by the three places that need it, so it cannot drift.
|
|
17
|
+
*/
|
|
18
|
+
export const TOP_ACTIONS = ['create', 'search', 'extra'];
|
|
19
|
+
|
|
20
|
+
export const rowActions = (actions?: string[]): string[] => (
|
|
21
|
+
(actions ?? []).filter(action => !TOP_ACTIONS.includes(action))
|
|
22
|
+
);
|