Skip to content

Commit

Permalink
Improve columns
Browse files Browse the repository at this point in the history
  • Loading branch information
hsluoyz committed Mar 11, 2024
1 parent 3862e31 commit 8abae84
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
11 changes: 10 additions & 1 deletion web/src/ChatListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,16 @@ class ChatListPage extends React.Component {
}

if (!this.props.account || this.props.account.name !== "admin") {
columns = columns.filter(column => column.key !== "price");
columns = columns.filter(column => column.key !== "name" && column.key !== "price" && column.key !== "clientIp");

const tokenCountIndex = columns.findIndex(column => column.key === "tokenCount");
if (tokenCountIndex !== -1) {
const [tokenCountElement] = columns.splice(tokenCountIndex, 1);

const actionIndex = columns.findIndex(column => column.key === "action");
const insertIndex = actionIndex !== -1 ? actionIndex : columns.length;
columns.splice(insertIndex, 0, tokenCountElement);
}
}

const sumFields = (chats, field) => {
Expand Down
16 changes: 12 additions & 4 deletions web/src/MessageListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,9 @@ class MessageListPage extends React.Component {
width: "100px",
sorter: (a, b) => a.replyTo.localeCompare(b.replyTo),
render: (text, record, index) => {
const textTemp = text.split("/")[1];
return (
<Link to={`/messages/${textTemp}`}>
{textTemp}
<Link to={`/messages/${text}`}>
{text}
</Link>
);
},
Expand Down Expand Up @@ -303,7 +302,16 @@ class MessageListPage extends React.Component {
];

if (!this.props.account || this.props.account.name !== "admin") {
columns = columns.filter(column => column.key !== "price");
columns = columns.filter(column => column.key !== "name" && column.key !== "price");

const tokenCountIndex = columns.findIndex(column => column.key === "tokenCount");
if (tokenCountIndex !== -1) {
const [tokenCountElement] = columns.splice(tokenCountIndex, 1);

const actionIndex = columns.findIndex(column => column.key === "action");
const insertIndex = actionIndex !== -1 ? actionIndex : columns.length;
columns.splice(insertIndex, 0, tokenCountElement);
}
}

return (
Expand Down

0 comments on commit 8abae84

Please sign in to comment.