Skip to content

Commit b782284

Browse files
(v2.3) group by UI
1 parent 5b7ba1e commit b782284

File tree

4 files changed

+32
-24
lines changed

4 files changed

+32
-24
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
- Support for Authorization Headers
3030
- Display extra documentation using markdown
3131
- Saves history previous requests
32-
- Added filters to sort, group and filter routes by methods, controllers, middlewares, routes (also see Roadmap 2.x)
32+
- Added filters to sort, group and filter routes by methods, controllers, middlewares, routes
3333
- Export laravel API, routes, rules and documentation to Postman and OpenAPI 3.0.0
3434

3535
# Read on Medium
@@ -156,9 +156,8 @@ Fixing lints
156156

157157
# Roadmap for v2.x
158158

159-
- [DONE] UI renewal
160-
- [WIP] Introduce groupby controller names, routes, middlewares
161-
- [WIP] Introduce fetch rules from PHP doc annotations
159+
- UI renewal
160+
- Introduce groupby controller names, routes, middlewares
162161

163162
# Changelog
164163

@@ -181,5 +180,7 @@ Fixing lints
181180
- v2.0 UI Renewal to React static
182181
- `@QAParam` is now `@LRDparam`
183182
- No special changes for users, upgrade to v2.x as usual
183+
- Upgrading users will need to republish config
184184
- v2.1 UI - adds search bar and few aligment fixes on table
185185
- v2.2 PHP 8.1 and 8.2 support added
186+
- v2.3 Groupby enabled for routes and controllers

src/Controllers/LaravelRequestDocsController.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ public function api(Request $request)
6060
Response::HTTP_OK,
6161
[
6262
'Content-type'=> 'application/json; charset=utf-8',
63-
'Cache-Control' => 'public, max-age=60',
64-
'Expires' => gmdate('D, d M Y H:i:s \G\M\T', time() + 60),
6563
],
6664
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
6765
);

ui/src/components/Sidebar.tsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ interface IAPIInfo {
1616
httpMethod: string;
1717
rules: IAPIRule;
1818
docBlock: string;
19+
group: string|null;
20+
group_index: number|null;
1921
}
2022

2123
interface Props {
@@ -33,17 +35,25 @@ export default function Sidebar(props: Props) {
3335
</h2>
3436
<ul>
3537
{lrdDocsJson.map((lrdDocsItem) => (
36-
lrdDocsItem.methods.map((method) => (
37-
<li key={shortid.generate()}>
38-
<AnchorLink href={'#' + method + lrdDocsItem.uri} className="flex flex-row px-0 py-1">
39-
<span className={`method-${method} uppercase text-xs w-12 p-0 flex flex-row-reverse`}>
40-
{method}
41-
</span>
42-
<span className="flex-1 p-0 text-sm text-left break-all">
43-
{lrdDocsItem.uri}
44-
</span>
45-
</AnchorLink>
46-
</li>
38+
lrdDocsItem.methods.map((method, methodIndex) => (
39+
<div key={shortid.generate()}>
40+
{(lrdDocsItem.group != null && lrdDocsItem.group != "" && lrdDocsItem.group_index == 0 && methodIndex == 0) && (
41+
<li className="pt-5 text-slate-600">
42+
{/* Only in case of controller names full path -> just controller name */}
43+
{lrdDocsItem.group.split('\\').pop()}
44+
</li>
45+
)}
46+
<li>
47+
<AnchorLink href={'#' + method + lrdDocsItem.uri} className="flex flex-row px-0 py-1">
48+
<span className={`method-${method} uppercase text-xs w-12 p-0 flex flex-row-reverse`}>
49+
{method}
50+
</span>
51+
<span className="flex-1 p-0 text-sm text-left break-all">
52+
{lrdDocsItem.uri}
53+
</span>
54+
</AnchorLink>
55+
</li>
56+
</div>
4757
))
4858
))}
4959
<li className='bg-transparent'></li>

ui/src/components/TopNav.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,21 +130,20 @@ export default function TopNav(props: Props) {
130130
<span className="label-text">HTTP Methods</span>
131131
</label>
132132
</div>
133-
{/* Not Implemented */}
134-
{/* <h4 className="font-bold mt-10">Group By</h4>
133+
<h4 className="font-bold mt-10">Group By</h4>
135134
<div className="form-control">
136135
<label className="label">
137136

138137
<input type="radio" onChange={handleChangeGroupby} value="default" className="radio" checked={groupby == "default"} />
139138
<span className="label-text">Default</span>
140139

141-
<input type="radio" onChange={handleChangeGroupby} value="controller_names" className="radio" checked={groupby == "controller_names"} />
142-
<span className="label-text">Controllers</span>
140+
<input type="radio" onChange={handleChangeGroupby} value="api_uri" className="radio" checked={groupby == "api_uri"} />
141+
<span className="label-text">API URI</span>
143142

144-
<input type="radio" onChange={handleChangeGroupby} value="middleware_names" className="radio" checked={groupby == "middleware_names"} />
145-
<span className="label-text">Middlewares</span>
143+
<input type="radio" onChange={handleChangeGroupby} value="controller_full_path" className="radio" checked={groupby == "controller_full_path"} />
144+
<span className="label-text">Controller Names</span>
146145
</label>
147-
</div> */}
146+
</div>
148147
<h4 className="font-bold mt-10">Display Settings</h4>
149148
<div className="form-control">
150149
<label className="label">

0 commit comments

Comments
 (0)