Skip to content

Commit 8973813

Browse files
committed
web,graphql: Support AGENT.md
1 parent 50f1ed7 commit 8973813

File tree

12 files changed

+22
-14
lines changed

12 files changed

+22
-14
lines changed

graphql-server/schema.gql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ enum DocType {
395395
Unspecified
396396
Readme
397397
License
398+
Agent
398399
}
399400

400401
enum DiffRowType {

graphql-server/src/docs/doc.enum.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export enum DocType {
55
Unspecified = "Unspecified",
66
Readme = "README.md",
77
License = "LICENSE.md",
8+
Agent = "AGENT.md",
89
}
910

1011
registerEnumType(DocType, { name: "DocType" });
@@ -15,6 +16,8 @@ export function toDocType(r: Row): DocType {
1516
return DocType.Readme;
1617
case "LICENSE.md":
1718
return DocType.License;
19+
case "AGENT.md":
20+
return DocType.Agent;
1821
default:
1922
return DocType.Unspecified;
2023
}

graphql-server/src/docs/doc.resolver.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@ export class DocsResolver {
2222
const conn = this.conn.connection();
2323
const docRows = await conn.getDocs(args);
2424
if (!docRows?.length) return { list: [] };
25-
const sortedDocs = docRows.sort(d =>
26-
d.doc_name === DocType.Readme ? -1 : 1,
27-
);
2825
return {
29-
list: sortedDocs.map(d => fromDoltDocsRow(args.refName, d)),
26+
list: docRows.map(d => fromDoltDocsRow(args.refName, d)),
3027
};
3128
}
3229

graphql-server/src/queryFactory/dolt/doltEntityManager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ export async function getDoltDocs(em: EntityManager): t.UPR {
141141
const sel = em
142142
.createQueryBuilder()
143143
.select("*")
144-
.from(DoltSystemTable.DOCS, "");
144+
.from(DoltSystemTable.DOCS, "")
145+
.orderBy("doc_name", "DESC");
145146
return handleTableNotFound(async () => sel.getRawMany());
146147
}
147148

web/renderer/components/DatabaseHeaderAndNav/AddItemDropdown/DocItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function Inner(props: InnerProps) {
2323

2424
const canCreateNewDoc =
2525
props.userHasWritePerms &&
26-
(!res.data?.docs || res.data.docs.list.length < 2);
26+
(!res.data?.docs || res.data.docs.list.length < 3);
2727

2828
return <NewDocLink params={props.params} hide={!canCreateNewDoc} />;
2929
}
@@ -55,7 +55,7 @@ function NewDocLink(props: {
5555
doltDisabled={props.doltDisabled}
5656
hide={props.hide}
5757
>
58-
New README/LICENSE
58+
New doc
5959
</DropdownItem>
6060
);
6161
}

web/renderer/components/pageComponents/DatabasePage/ForDocs/DocsPage/DocList/NewDocButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function NewDocButton(props: Props) {
1717
<Button data-cy="add-doc-button">
1818
<div>
1919
<FiPlus />
20-
Add README/LICENSE
20+
Add doc
2121
</div>
2222
</Button>
2323
</Link>

web/renderer/components/pageComponents/DatabasePage/ForDocs/DocsPage/DocList/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type InnerProps = Props & {
1717
};
1818

1919
function Inner({ docs, params }: InnerProps) {
20-
const canCreateNewDoc = docs.list.length < 2;
20+
const canCreateNewDoc = docs.list.length < 3;
2121
return (
2222
<div className={css.docsContainer}>
2323
{docs.list.length > 0 && (

web/renderer/components/pageComponents/DatabasePage/ForDocs/NewDocPage/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default function Header(props: Props) {
1515
pageName="docs"
1616
className={css.goBack}
1717
/>
18-
<div className={css.title}>Add a README or LICENSE</div>
18+
<div className={css.title}>Add a doc</div>
1919
</div>
2020
);
2121
}

web/renderer/components/pageComponents/DatabasePage/ForDocs/NewDocPage/NewDocForm.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jest.mock("next/router", () => {
2020
};
2121
});
2222

23-
const docTitle = "Add a README or LICENSE";
23+
const docTitle = "Add a doc";
2424

2525
describe("test NewDocForm", () => {
2626
it("renders new doc form for no docs", async () => {

web/renderer/components/pageComponents/DatabasePage/ForDocs/NewDocPage/NewDocForm.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function Inner(props: InnerProps) {
4040
<div className={css.body}>
4141
<HideForNoWritesWrapper
4242
params={props.params}
43-
noWritesAction="add LICENSE or README"
43+
noWritesAction="add a doc"
4444
>
4545
<form onSubmit={onSubmit}>
4646
<div className={css.selectContainer}>
@@ -63,8 +63,8 @@ function Inner(props: InnerProps) {
6363
</div>
6464
) : (
6565
<p className={css.marTop}>
66-
Both README and LICENSE exist. Click on an individual document
67-
in the About section to edit.
66+
All docs exist. Click on an individual document in the About
67+
section to edit.
6868
</p>
6969
)}
7070
<Button
@@ -94,6 +94,7 @@ function getOptions(docRows?: DocForDocPageFragment[]): Option[] {
9494
const options: Option[] = [
9595
{ label: "README", value: DocType.Readme },
9696
{ label: "LICENSE", value: DocType.License },
97+
{ label: "AGENT", value: DocType.Agent },
9798
];
9899
return (
99100
options

0 commit comments

Comments
 (0)