From 6fa652c88deafbc61ad27b79eea7e9f801c76cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Wed, 26 Jun 2024 17:12:28 +0200 Subject: [PATCH] improve default docs sorting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/eleven-radios-begin.md | 5 +++++ .../src/home/components/Tables/DocsTable.tsx | 14 +++++++------- .../src/home/components/Tables/columns.tsx | 6 ++++++ 3 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 .changeset/eleven-radios-begin.md diff --git a/.changeset/eleven-radios-begin.md b/.changeset/eleven-radios-begin.md new file mode 100644 index 0000000000..3fc2dd7895 --- /dev/null +++ b/.changeset/eleven-radios-begin.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs': patch +--- + +Improve default sorting of docs table diff --git a/plugins/techdocs/src/home/components/Tables/DocsTable.tsx b/plugins/techdocs/src/home/components/Tables/DocsTable.tsx index c0b39878cd..de57c70e6a 100644 --- a/plugins/techdocs/src/home/components/Tables/DocsTable.tsx +++ b/plugins/techdocs/src/home/components/Tables/DocsTable.tsx @@ -51,6 +51,13 @@ export type DocsTableProps = { options?: TableOptions; }; +const defaultColumns: TableColumn[] = [ + columnFactories.createNameColumn(), + columnFactories.createOwnerColumn(), + columnFactories.createKindColumn(), + columnFactories.createTypeColumn(), +]; + /** * Component which renders a table documents * @@ -84,13 +91,6 @@ export const DocsTable = (props: DocsTableProps) => { }; }); - const defaultColumns: TableColumn[] = [ - columnFactories.createNameColumn(), - columnFactories.createOwnerColumn(), - columnFactories.createKindColumn(), - columnFactories.createTypeColumn(), - ]; - const defaultActions: TableProps['actions'] = [ actionFactories.createCopyDocsUrlAction(copyToClipboard), ]; diff --git a/plugins/techdocs/src/home/components/Tables/columns.tsx b/plugins/techdocs/src/home/components/Tables/columns.tsx index bc85bb7a63..8c8346b406 100644 --- a/plugins/techdocs/src/home/components/Tables/columns.tsx +++ b/plugins/techdocs/src/home/components/Tables/columns.tsx @@ -35,6 +35,12 @@ export const columnFactories = { title: 'Document', field: 'entity.metadata.name', highlight: true, + defaultSort: 'asc', + customSort: (row1, row2) => { + const title1 = customTitle(row1.entity).toLocaleLowerCase(); + const title2 = customTitle(row2.entity).toLocaleLowerCase(); + return title1.localeCompare(title2); + }, render: (row: DocsTableRow) => (