todo,todo-backend: add tag field to TodoItems

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-03-11 22:10:47 +01:00
parent 378f77b4f6
commit c07728eec8
10 changed files with 21 additions and 6 deletions
@@ -96,8 +96,9 @@ export class TodoScmReader implements TodoReader {
});
todos.push(
...items.map(({ lineNumber, text, author }) => ({
...items.map(({ lineNumber, text, tag, author }) => ({
text,
tag,
author,
lineNumber,
repoFilePath: file.path,
@@ -34,6 +34,7 @@ export function createTodoParser(options: TodoParserOptions = {}): TodoParser {
return comments.map(comment => ({
text: comment.text,
tag: comment.tag,
author: comment.ref,
lineNumber: comment.line,
}));
@@ -18,6 +18,9 @@ export type TodoItem = {
/** The contents of the TODO comment */
text: string;
/** The tag used, e.g. TODO, FIXME */
tag: string;
/** References author, if any */
author?: string;
@@ -59,6 +62,7 @@ type TodoParserContext = {
type TodoParserResult = {
text: string;
tag: string;
author?: string;
lineNumber: number;
};
@@ -21,7 +21,7 @@ import { createRouter } from './router';
import { TodoService } from './types';
const mockListBody = {
items: [{ text: 'my todo' }],
items: [{ text: 'my todo', tag: 'TODO' }],
totalCount: 1,
offset: 0,
limit: 10,
@@ -22,6 +22,7 @@ import { TodoService } from './types';
const ALLOWED_ORDER_BY_FIELDS = [
'text',
'tag',
'author',
'viewUrl',
'repoFilePath',
+1 -1
View File
@@ -22,7 +22,7 @@ export type ListTodosRequest = {
offset?: number;
limit?: number;
orderBy?: {
field: 'text' | 'author' | 'viewUrl' | 'repoFilePath';
field: 'text' | 'tag' | 'author' | 'viewUrl' | 'repoFilePath';
direction: 'asc' | 'desc';
};
};
+1
View File
@@ -50,6 +50,7 @@ const mockedApi = {
items: [
{
text: 'Make sure this works',
tag: 'TODO',
author: 'Rugvip',
viewUrl: 'https://github.com/backstage/backstage',
},
+4 -1
View File
@@ -21,6 +21,9 @@ export type TodoItem = {
/** The contents of the TODO comment */
text: string;
/** The tag used, e.g. TODO, FIXME */
tag: string;
/** References author, if any */
author?: string;
@@ -39,7 +42,7 @@ export type TodoListOptions = {
offset?: number;
limit?: number;
orderBy?: {
field: 'text' | 'author' | 'viewUrl' | 'repoFilePath';
field: 'text' | 'tag' | 'author' | 'viewUrl' | 'repoFilePath';
direction: 'asc' | 'desc';
};
};
@@ -29,6 +29,7 @@ describe('TodoList', () => {
items: [
{
text: 'My TODO',
tag: 'FIXME',
viewUrl: 'https://example.com',
repoFilePath: '/my-file.js',
},
@@ -48,6 +49,6 @@ describe('TodoList', () => {
</ApiProvider>,
);
await expect(rendered.findByText('1-1 of 1')).resolves.toBeInTheDocument();
await expect(rendered.findByText('FIXME')).resolves.toBeInTheDocument();
});
});
@@ -30,6 +30,10 @@ import { TodoItem, TodoListOptions } from '../../api/types';
const PAGE_SIZE = 10;
const columns: TableColumn<TodoItem>[] = [
{
title: 'Tag',
field: 'tag',
},
{
title: 'Text',
field: 'text',
@@ -53,7 +57,6 @@ const columns: TableColumn<TodoItem>[] = [
{
title: 'Author',
field: 'author',
width: '20%',
render: ({ author }) => <OverflowTooltip text={author} />,
},
];