Skip to content

Commit 3a16d19

Browse files
committed
Add recent actions tab and log entry some styling, new icon
1 parent 37190d5 commit 3a16d19

17 files changed

Lines changed: 1179 additions & 951 deletions

File tree

‎assets/icons/clipboard.svg‎

Lines changed: 10 additions & 0 deletions
Loading

‎public/assets/fonts/tgico.svg‎

Lines changed: 316 additions & 315 deletions
Loading

‎public/assets/fonts/tgico.ttf‎

464 Bytes
Binary file not shown.

‎public/assets/fonts/tgico.woff‎

464 Bytes
Binary file not shown.

‎src/components/sidebarLeft/tabs/editFolderInput/index.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import {onCleanup} from 'solid-js';
22
import {TextWithEntities} from '../../../../layer';
33
import wrapEmojiText from '../../../../lib/richTextProcessor/wrapEmojiText';
44
import defineSolidElement, {PassedProps} from '../../../../lib/solidjs/defineSolidElement';
5-
import {InputFieldTsx} from '../../../inputFieldTsx';
65
import {InputFieldEmoji} from '../../../inputFieldEmoji';
6+
import {InputFieldTsx} from '../../../inputFieldTsx';
77

88
if(import.meta.hot) import.meta.hot.accept();
99

10+
1011
const MAX_FOLDER_NAME_LENGTH = 12;
1112

1213
type Props = {
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import {createEffect, createResource, For} from 'solid-js';
2+
import {logger} from '../../../../lib/logger';
3+
import {useHotReloadGuard} from '../../../../lib/solidjs/hotReloadGuard';
4+
import {useSuperTab} from '../../../solidJsTabs/superTabProvider';
5+
import {type AppAdminRecentActionsTab} from '../../../solidJsTabs/tabs';
6+
import {LogEntry} from './logEntry';
7+
import {IconTsx} from '../../../iconTsx';
8+
9+
const log = logger('AdminRecentActionsTab');
10+
11+
const AdminRecentActionsTab = () => {
12+
const {rootScope, PeerTitleTsx} = useHotReloadGuard();
13+
const [tab] = useSuperTab<typeof AppAdminRecentActionsTab>();
14+
15+
const [logs] = createResource(async() => {
16+
const startTime = performance.now();
17+
const result = await rootScope.managers.appChatsManager.getAdminLogs({channelId: tab.payload.channelId})
18+
const endTime = performance.now();
19+
20+
log(`getAdminLogs took ${endTime - startTime}ms`);
21+
22+
return result;
23+
});
24+
25+
createEffect(() => {
26+
console.log('logs :>> ', logs());
27+
});
28+
29+
return (
30+
<For each={logs() || []}>
31+
{(log) => (
32+
<div style={{padding: '6px 12px'}}>
33+
<LogEntry
34+
peerTitle={<PeerTitleTsx peerId={log.user_id.toPeerId()} />}
35+
// peerTitle={'lsdfkj alsdfj alskdjf alskdjf alsdkfj alsdkfja lsdkjf asldfj'}
36+
// message={'Chnaged the title from This to That and edited some messages'}
37+
message={'Chnaged the title from This to That'}
38+
date={new Date(log.date * 1000)}
39+
icon='clipboard'
40+
// expandableContent={<div>
41+
// lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
42+
// </div>}
43+
/>
44+
</div>
45+
)}
46+
</For>
47+
);
48+
};
49+
50+
/**
51+
* - cases for each log action type
52+
* - infinite scroll fetching
53+
* - dynamic virtual list
54+
* - collapsing
55+
* - filters
56+
* - downloading log
57+
*/
58+
59+
export default AdminRecentActionsTab;
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
.Container {
2+
border-radius: 12px;
3+
background-color: var(--surface-color);
4+
}
5+
6+
.Header {
7+
display: flex;
8+
align-items: center;
9+
gap: 12px;
10+
11+
padding: 10px 12px;
12+
13+
--border-color: 0, 0, 0;
14+
border-bottom: 1px solid var(--background-color);
15+
16+
:global(.night) & {
17+
--border-color: 255, 255, 255;
18+
}
19+
}
20+
21+
.Group {
22+
flex: 1;
23+
min-width: 0; /* crucial – allows the item to shrink below its content width */
24+
display: flex;
25+
flex-direction: column;
26+
gap: 2px;
27+
}
28+
29+
.Icon {
30+
display: flex;
31+
font-size: 20px;
32+
/* align-self: flex-start;
33+
padding-top: 12px; */
34+
/* color: var(--primary-color); */
35+
}
36+
37+
.PeerTitle {
38+
overflow: hidden;
39+
text-overflow: ellipsis;
40+
font-weight: 600;
41+
white-space: nowrap;
42+
font-size: 14px;
43+
line-height: 1.2;
44+
padding-top: 1px;
45+
}
46+
47+
.Message {
48+
white-space: nowrap;
49+
overflow: hidden;
50+
text-overflow: ellipsis;
51+
52+
font-size: 14px;
53+
color: var(--secondary-text-color);
54+
line-height: 1.2;
55+
}
56+
57+
.Date {
58+
font-size: 13px;
59+
line-height: 1;
60+
/* opacity: 0.6; */
61+
color: var(--secondary-text-color);
62+
}
63+
64+
.ExpandableContent {
65+
font-size: 16px;
66+
padding: 8px 12px;
67+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import {JSX} from 'solid-js';
2+
import {formatTime} from '../../../../helpers/date';
3+
import {IconTsx} from '../../../iconTsx';
4+
import styles from './logEntry.module.scss';
5+
6+
type LogEntryProps = {
7+
date: Date;
8+
peerTitle: JSX.Element;
9+
message: JSX.Element;
10+
icon: Icon;
11+
12+
expanded?: boolean;
13+
expandableContent?: JSX.Element;
14+
};
15+
16+
export const LogEntry = (props: LogEntryProps) => {
17+
const isExpandable = () => props.expandableContent !== undefined;
18+
19+
return (
20+
<div class={styles.Container}>
21+
<div class={styles.Header}>
22+
<div class={styles.Icon}><IconTsx icon={props.icon} /></div>
23+
<div class={styles.Group}>
24+
<div class={styles.PeerTitle}>{props.peerTitle}</div>
25+
<div class={styles.Message}>{props.message} adsf asdf asd sdf</div>
26+
</div>
27+
<div class={styles.Date}>{formatTime(props.date)}</div>
28+
</div>
29+
{/* {isExpandable() && (
30+
)}*/}
31+
<div class={styles.ExpandableContent}>
32+
<div class={styles.ExpandableContentTitle}>
33+
{props.message}
34+
</div>
35+
{props.expandableContent}
36+
</div>
37+
</div>
38+
);
39+
};

‎src/components/sidebarRight/tabs/editChat.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import PopupBoost from '../../popups/boost';
4141
import namedPromises from '../../../helpers/namedPromises';
4242
import apiManagerProxy from '../../../lib/mtproto/mtprotoworker';
4343
import {AppDirectMessagesTab} from '../../solidJsTabs';
44+
import {AppAdminRecentActionsTab} from '../../solidJsTabs/tabs';
4445

4546
export default class AppEditChatTab extends SliderSuperTab {
4647
private chatNameInputField: InputField;
@@ -440,6 +441,19 @@ export default class AppEditChatTab extends SliderSuperTab {
440441
section.content.append(topicsRow.container);
441442
}
442443

444+
if(isAdmin) {
445+
const recentActionsRow = new Row({
446+
icon: 'clipboard',
447+
titleLangKey: 'RecentActions',
448+
clickable: () => {
449+
this.slider.createTab(AppAdminRecentActionsTab).open({channelId: this.chatId});
450+
},
451+
listenerSetter: this.listenerSetter
452+
});
453+
454+
section.content.append(recentActionsRow.container);
455+
}
456+
443457
section.caption.classList.toggle('hide', !section.caption.childElementCount);
444458

445459
if(section.content.childElementCount) this.scrollable.append(section.container);

‎src/components/solidJsTabs/scaffoldSolidJSTab.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export function scaffoldSolidJSTab<Payload = void>({
4242
this.dispose = render(() => (
4343
<SolidJSHotReloadGuardProvider>
4444
<PromiseCollector onCollect={promiseCollectorHelper.onCollect}>
45-
{/* Providing other tabs here to avoid circular imports */}
4645
<SuperTabProvider self={this}>
4746
<Component />
4847
</SuperTabProvider>

0 commit comments

Comments
 (0)