* fix(player): fix initial visual offset jump check * change(ui): add empty feature flags page * change(ui): add empty feature flags page * fix(ui): some more fixes * change(ui): add subrouting for sessions tab * change(ui): more fixes for routing * change(ui): add flag creation page, flags list table, flag store/type * change(tracker): flags in tracker * change(tracker): return all flags * feat(ui): add API and types connector * feat(ui): split components to prevent rerendering * feat(ui): add icon, fix redirect.path crashlooping * feat(ui): add conditions and stuff, add flags class to tracker to handle stuff * feat(ui): add condition state and filters * feat(ui): fix flag creation with api change * feat(ui): fix flag editing (api changes); simplify new/edit flag component * feat(ui): add filters, make table pretty :insert_magic_emoji: * feat(ui): remove rollout percentage from list, remove console logs * feat(ui): multivar toggler * feat(tracker): add more methods to tracker * feat(tracker): more type coverage * feat(tracker): add tests * fix(ui): some fixes for multivar * feat(ui): multivar api support * fix(ui):start adding tests for fflags * fix(ui): rm not working file.. * fix(ui): rm unused packages * fix(ui): remove name field, fix some api and type names * fix(ui): fix crash * fix(tracker/ui): keep flags in sessionStorage, support API errors in feature flags storage * fix(tracker/ui): clear unused things, fix url handling, fix icons rendering etc
89 lines
3 KiB
TypeScript
89 lines
3 KiB
TypeScript
import React from 'react';
|
|
import { Link } from 'UI';
|
|
import PlayLink from 'Shared/SessionItem/PlayLink';
|
|
import { tagProps, Note } from 'App/services/NotesService';
|
|
import { formatTimeOrDate } from 'App/date';
|
|
import { useStore } from 'App/mstore';
|
|
import { observer } from 'mobx-react-lite';
|
|
import { ItemMenu } from 'UI';
|
|
import copy from 'copy-to-clipboard';
|
|
import { toast } from 'react-toastify';
|
|
import { session } from 'App/routes';
|
|
import TeamBadge from './TeamBadge';
|
|
|
|
interface Props {
|
|
note: Note;
|
|
}
|
|
|
|
function NoteItem(props: Props) {
|
|
const { settingsStore, notesStore } = useStore();
|
|
const { timezone } = settingsStore.sessionSettings;
|
|
|
|
const onCopy = () => {
|
|
copy(
|
|
`${window.location.origin}/${window.location.pathname.split('/')[1]}${session(
|
|
props.note.sessionId
|
|
)}${props.note.timestamp > 0 ? `?jumpto=${props.note.timestamp}¬e=${props.note.noteId}` : `?note=${props.note.noteId}`}`
|
|
);
|
|
toast.success('Note URL copied to clipboard');
|
|
};
|
|
const onDelete = () => {
|
|
notesStore.deleteNote(props.note.noteId).then((r) => {
|
|
notesStore.fetchNotes();
|
|
toast.success('Note deleted');
|
|
});
|
|
};
|
|
const menuItems = [
|
|
{ icon: 'link-45deg', text: 'Copy Note URL', onClick: onCopy },
|
|
{ icon: 'trash', text: 'Delete', onClick: onDelete },
|
|
];
|
|
|
|
const safeStrMessage =
|
|
props.note.message.length > 150 ? props.note.message.slice(0, 150) + '...' : props.note.message;
|
|
return (
|
|
<div className="flex items-center p-2 border-b">
|
|
<Link
|
|
style={{ width: '90%' }}
|
|
to={
|
|
session(props.note.sessionId) +
|
|
(props.note.timestamp > 0
|
|
? `?jumpto=${props.note.timestamp}¬e=${props.note.noteId}`
|
|
: `?note=${props.note.noteId}`)
|
|
}
|
|
>
|
|
<div className="flex flex-col gap-1 p-2 rounded cursor-pointer note-hover">
|
|
<div className="py-1 capitalize-first text-lg">{safeStrMessage}</div>
|
|
<div className="flex items-center gap-2">
|
|
{props.note.tag ? (
|
|
<div
|
|
style={{
|
|
// @ts-ignore
|
|
background: tagProps[props.note.tag],
|
|
padding: '1px 6px',
|
|
}}
|
|
className="rounded-full text-white text-xs select-none w-fit"
|
|
>
|
|
{props.note.tag}
|
|
</div>
|
|
) : null}
|
|
<div className="text-disabled-text flex items-center text-sm">
|
|
<span className="color-gray-darkest mr-1">By </span>
|
|
{props.note.userName},{' '}
|
|
{formatTimeOrDate(props.note.createdAt as unknown as number, timezone)}
|
|
<div className="mx-2" />
|
|
{!props.note.isPublic ? null : <TeamBadge />}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</Link>
|
|
<div className="ml-auto">
|
|
<PlayLink isAssist={false} viewed={false} sessionId={props.note.sessionId} />
|
|
</div>
|
|
<div className="ml-2 cursor-pointer">
|
|
<ItemMenu bold items={menuItems} />
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default observer(NoteItem);
|