Skip to content

Commit 3f417a2

Browse files
authored
Merge pull request #477 from easyops-cn/steve/sidebar
Steve/sidebar
2 parents afb3515 + a7c253b commit 3f417a2

File tree

6 files changed

+45
-5
lines changed

6 files changed

+45
-5
lines changed

bricks/advanced/src/next-table/Table.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export interface NextTableComponentProps extends NextTableProps {
6969
onPageChange?: (detail: { page: number; pageSize: number }) => void;
7070
onPageSizeChange?: (detail: { page: number; pageSize: number }) => void;
7171
onSort?: (detail?: Sort | Sort[]) => void;
72+
onRowClick?: (detail: RecordType) => void;
7273
onRowSelect?: (detail: {
7374
keys: (string | number)[];
7475
rows: RecordType[];
@@ -106,6 +107,7 @@ export const NextTableComponent = forwardRef(function LegacyNextTableComponent(
106107
expandable,
107108
childrenColumnName,
108109
rowDraggable,
110+
rowClickable,
109111
searchFields,
110112
size,
111113
showHeader,
@@ -116,6 +118,7 @@ export const NextTableComponent = forwardRef(function LegacyNextTableComponent(
116118
onPageChange,
117119
onPageSizeChange,
118120
onSort,
121+
onRowClick,
119122
onRowSelect,
120123
onRowExpand,
121124
onExpandedRowsChange,
@@ -618,6 +621,15 @@ export const NextTableComponent = forwardRef(function LegacyNextTableComponent(
618621
},
619622
}
620623
}
624+
onRow={
625+
rowClickable
626+
? (record) => ({
627+
onClick: () => {
628+
onRowClick?.(record);
629+
},
630+
})
631+
: undefined
632+
}
621633
onChange={(pagination, _filters, sorter, extra) => {
622634
switch (extra.action) {
623635
case "paginate": {
@@ -661,7 +673,9 @@ export const NextTableComponent = forwardRef(function LegacyNextTableComponent(
661673
}
662674
}
663675
}}
664-
className="next-table"
676+
className={classNames("next-table", {
677+
"row-clickable": rowClickable,
678+
})}
665679
/>
666680
</SortableContext>
667681
</DndContext>

bricks/advanced/src/next-table/index.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ class EoNextTable extends ReactNextElement implements NextTableProps {
159159
})
160160
accessor rowDraggable: boolean | undefined;
161161

162+
/**
163+
* 表格行可点击(激活鼠标手势)
164+
*/
165+
@property({
166+
type: Boolean,
167+
})
168+
accessor rowClickable: boolean | undefined;
169+
162170
/**
163171
* 进行前端搜索的字段,支持嵌套的写法。不配置的时候默认为对所有 column.dataIndex 进行前端搜索
164172
*/
@@ -260,6 +268,17 @@ class EoNextTable extends ReactNextElement implements NextTableProps {
260268
this.#sortChangeEvent.emit(detail);
261269
};
262270

271+
/**
272+
* 行点击时的回调
273+
* @detail 被点击的行数据
274+
*/
275+
@event({ type: "row.click" })
276+
accessor #rowClickEvent!: EventEmitter<RecordType>;
277+
278+
#handleRowClick = (detail: RecordType): void => {
279+
this.#rowClickEvent.emit(detail);
280+
};
281+
263282
/**
264283
* 行选中项发生变化时的回调
265284
* @detail 改变后的 rowKey 及行数据
@@ -356,6 +375,7 @@ class EoNextTable extends ReactNextElement implements NextTableProps {
356375
expandedRowKeys={this.expandedRowKeys}
357376
childrenColumnName={this.childrenColumnName}
358377
rowDraggable={this.rowDraggable}
378+
rowClickable={this.rowClickable}
359379
searchFields={this.searchFields}
360380
size={this.size}
361381
showHeader={this.showHeader}
@@ -366,6 +386,7 @@ class EoNextTable extends ReactNextElement implements NextTableProps {
366386
onPageChange={this.#handlePageChange}
367387
onPageSizeChange={this.#handlePageSizeChange}
368388
onSort={this.#handleSort}
389+
onRowClick={this.#handleRowClick}
369390
onRowSelect={this.#handleRowSelect}
370391
onRowExpand={this.#handleRowExpand}
371392
onExpandedRowsChange={this.#handleExpandedRowsChange}

bricks/advanced/src/next-table/interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface NextTableProps {
2525
expandedRowKeys?: (string | number)[];
2626
childrenColumnName?: string;
2727
rowDraggable?: boolean;
28+
rowClickable?: boolean;
2829
searchFields?: (string | string[])[];
2930
size?: TableProps<RecordType>["size"];
3031
showHeader?: boolean;

bricks/advanced/src/next-table/styles.shadow.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@
207207
border-inline-end: none;
208208
}
209209

210+
.next-table.row-clickable .ant-table-tbody > tr {
211+
cursor: pointer;
212+
}
213+
210214
:host([theme-variant="elevo"]) {
211215
--eo-next-table-header-border-radius: var(--elevo-border-radius);
212216
--eo-table-head-cell-height: 41px;

bricks/ai-portal/src/elevo-sidebar/SpaceNav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function SpaceNav({
6363
<WrappedIconButton
6464
icon={MODEL_ICON}
6565
variant="mini-light"
66-
tooltip={t(K.BUSINESS_OBJECTS_SETTINGS)}
66+
tooltip={t(K.BUSINESS_OBJECT_MODELS)}
6767
tooltipHoist={true}
6868
className="button"
6969
active={introActive}

bricks/ai-portal/src/elevo-sidebar/i18n.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ export enum K {
1616
UNTITLED = "UNTITLED",
1717
UNNAMED = "UNNAMED",
1818
BUSINESS_OBJECTS = "BUSINESS_OBJECTS",
19+
BUSINESS_OBJECT_MODELS = "BUSINESS_OBJECT_MODELS",
1920
SERVICEFLOWS = "SERVICEFLOWS",
2021
COLLABORATION_SPACES = "COLLABORATION_SPACES",
2122
CREATE_SERVICEFLOW = "CREATE_SERVICEFLOW",
22-
BUSINESS_OBJECTS_SETTINGS = "BUSINESS_OBJECTS_SETTINGS",
2323
}
2424

2525
const en: Locale = {
@@ -41,7 +41,7 @@ const en: Locale = {
4141
[K.SERVICEFLOWS]: "Serviceflows",
4242
[K.COLLABORATION_SPACES]: "Collaboration spaces",
4343
[K.CREATE_SERVICEFLOW]: "Create serviceflow",
44-
[K.BUSINESS_OBJECTS_SETTINGS]: "Business objects settings",
44+
[K.BUSINESS_OBJECT_MODELS]: "Business object models",
4545
};
4646

4747
const zh: Locale = {
@@ -63,7 +63,7 @@ const zh: Locale = {
6363
[K.SERVICEFLOWS]: "业务流",
6464
[K.COLLABORATION_SPACES]: "协作空间",
6565
[K.CREATE_SERVICEFLOW]: "创建业务流",
66-
[K.BUSINESS_OBJECTS_SETTINGS]: "业务对象设置",
66+
[K.BUSINESS_OBJECT_MODELS]: "业务对象模型",
6767
};
6868

6969
export const NS = "bricks/ai-portal/elevo-sidebar";

0 commit comments

Comments
 (0)