diff --git a/plugins/todo-backend/src/lib/TodoReader/TodoScmReader.ts b/plugins/todo-backend/src/lib/TodoReader/TodoScmReader.ts index 302c5985d6..07ebdf97eb 100644 --- a/plugins/todo-backend/src/lib/TodoReader/TodoScmReader.ts +++ b/plugins/todo-backend/src/lib/TodoReader/TodoScmReader.ts @@ -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, diff --git a/plugins/todo-backend/src/lib/TodoReader/createTodoParser.ts b/plugins/todo-backend/src/lib/TodoReader/createTodoParser.ts index deb0ed8800..1abbb901db 100644 --- a/plugins/todo-backend/src/lib/TodoReader/createTodoParser.ts +++ b/plugins/todo-backend/src/lib/TodoReader/createTodoParser.ts @@ -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, })); diff --git a/plugins/todo-backend/src/lib/TodoReader/types.ts b/plugins/todo-backend/src/lib/TodoReader/types.ts index 78859841d7..a6f046d2ea 100644 --- a/plugins/todo-backend/src/lib/TodoReader/types.ts +++ b/plugins/todo-backend/src/lib/TodoReader/types.ts @@ -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; }; diff --git a/plugins/todo-backend/src/service/router.test.ts b/plugins/todo-backend/src/service/router.test.ts index 3c17176dab..8fda603937 100644 --- a/plugins/todo-backend/src/service/router.test.ts +++ b/plugins/todo-backend/src/service/router.test.ts @@ -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, diff --git a/plugins/todo-backend/src/service/router.ts b/plugins/todo-backend/src/service/router.ts index d4f1a49c70..7b73ff93af 100644 --- a/plugins/todo-backend/src/service/router.ts +++ b/plugins/todo-backend/src/service/router.ts @@ -22,6 +22,7 @@ import { TodoService } from './types'; const ALLOWED_ORDER_BY_FIELDS = [ 'text', + 'tag', 'author', 'viewUrl', 'repoFilePath', diff --git a/plugins/todo-backend/src/service/types.ts b/plugins/todo-backend/src/service/types.ts index 0f06951132..e37307a4cf 100644 --- a/plugins/todo-backend/src/service/types.ts +++ b/plugins/todo-backend/src/service/types.ts @@ -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'; }; }; diff --git a/plugins/todo/dev/index.tsx b/plugins/todo/dev/index.tsx index 25a6769cb5..71e5e36355 100644 --- a/plugins/todo/dev/index.tsx +++ b/plugins/todo/dev/index.tsx @@ -50,6 +50,7 @@ const mockedApi = { items: [ { text: 'Make sure this works', + tag: 'TODO', author: 'Rugvip', viewUrl: 'https://github.com/backstage/backstage', }, diff --git a/plugins/todo/src/api/types.ts b/plugins/todo/src/api/types.ts index 22eff72b3a..e615532113 100644 --- a/plugins/todo/src/api/types.ts +++ b/plugins/todo/src/api/types.ts @@ -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'; }; }; diff --git a/plugins/todo/src/components/TodoList/TodoList.test.tsx b/plugins/todo/src/components/TodoList/TodoList.test.tsx index bd90f40215..2fb4f780bc 100644 --- a/plugins/todo/src/components/TodoList/TodoList.test.tsx +++ b/plugins/todo/src/components/TodoList/TodoList.test.tsx @@ -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', () => { , ); - await expect(rendered.findByText('1-1 of 1')).resolves.toBeInTheDocument(); + await expect(rendered.findByText('FIXME')).resolves.toBeInTheDocument(); }); }); diff --git a/plugins/todo/src/components/TodoList/TodoList.tsx b/plugins/todo/src/components/TodoList/TodoList.tsx index 999aa4fcbe..2ef8fceeef 100644 --- a/plugins/todo/src/components/TodoList/TodoList.tsx +++ b/plugins/todo/src/components/TodoList/TodoList.tsx @@ -30,6 +30,10 @@ import { TodoItem, TodoListOptions } from '../../api/types'; const PAGE_SIZE = 10; const columns: TableColumn[] = [ + { + title: 'Tag', + field: 'tag', + }, { title: 'Text', field: 'text', @@ -53,7 +57,6 @@ const columns: TableColumn[] = [ { title: 'Author', field: 'author', - width: '20%', render: ({ author }) => , }, ];