Skip to content

Commit 00a2398

Browse files
Merge pull request #128 from rakutentech/feature/v2-bugs
(v2.1) add auto releaser
2 parents 129483e + b3cc5e6 commit 00a2398

File tree

8 files changed

+56
-10
lines changed

8 files changed

+56
-10
lines changed

.github/workflows/releaser.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
branches:
44
- master
55

6-
name: "CI Node"
6+
name: "CI Release Dist"
77

88
jobs:
99
test:
@@ -39,6 +39,9 @@ jobs:
3939
4040
- name: Create Pull Request
4141
uses: peter-evans/create-pull-request@v4
42+
with:
43+
commit-message: (action) Update dist
44+
title: '(action) update dist astro'
4245

4346

4447

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,4 @@ Fixing lints
181181
- v2.0 UI Renewal to React static
182182
- `@QAParam` is now `@LRDparam`
183183
- No special changes for users, upgrade to v2.x as usual
184-
184+
- v2.1 UI - adds search bar and few aligment fixes on table

src/Controllers/LaravelRequestDocsController.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@ public function api(Request $request)
5555
);
5656
}
5757

58-
5958
return response()->json(
6059
$docs,
6160
Response::HTTP_OK,
6261
[
63-
'Content-type'=> 'application/json; charset=utf-8'
62+
'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),
6465
],
6566
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
6667
);
@@ -95,8 +96,8 @@ public function assets(Request $request)
9596
}
9697

9798
// set cache control headers
98-
$headers['Cache-Control'] = 'public, max-age=31536000';
99-
$headers['Expires'] = gmdate('D, d M Y H:i:s \G\M\T', time() + 31536000);
99+
$headers['Cache-Control'] = 'public, max-age=1800';
100+
$headers['Expires'] = gmdate('D, d M Y H:i:s \G\M\T', time() + 1800);
100101
return response()->file($path, $headers);
101102
}
102103
return response()->json(['error' => 'file not found'], 404);

ui/package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"@fontsource/roboto": "^4.5.8",
1818
"@heroicons/react": "^2.0.15",
1919
"astro": "^2.0.6",
20+
"fuse.js": "^6.6.2",
2021
"react-ace": "^10.1.0",
2122
"react-anchor-link-smooth-scroll": "^1.0.12",
2223
"react-markdown": "^8.0.5",

ui/src/components/App.tsx

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import ApiInfo from './ApiInfo';
55
import ApiAction from './ApiAction';
66
import useLocalStorage from 'react-use-localstorage';
77
import shortid from 'shortid';
8+
import Fuse from 'fuse.js';
89

910
interface IAPIRule {
1011
[key: string]: string[];
@@ -24,6 +25,7 @@ interface IAPIInfo {
2425
export default function App() {
2526

2627
const [lrdDocsJson, setLrdDocsJson] = useState<IAPIInfo[]>([]);
28+
const [lrdDocsJsonCopy, setLrdDocsJsonCopy] = useState<IAPIInfo[]>([]);
2729
const [allParamsRegistry, setAllParamsRegistery] = useLocalStorage('allParamsRegistry', "{}");
2830
const [apiURL, setApiURL] = useState<string>('');
2931
const [host, setHost] = useState<string>('');
@@ -39,7 +41,10 @@ export default function App() {
3941
const [showPatch] = useLocalStorage('showPatch', 'true');
4042
const [showHead] = useLocalStorage('showHead', 'true');
4143

42-
44+
const searchOptions = {
45+
keys: ['uri', 'docBlock'],
46+
threshold: 0.3
47+
};
4348

4449
useEffect(() => {
4550
// get query param named api
@@ -72,13 +77,31 @@ export default function App() {
7277
.then((lrdDocsJson) => {
7378
setError(null)
7479
setLrdDocsJson(lrdDocsJson)
80+
setLrdDocsJsonCopy(lrdDocsJson)
7581
setSendingRequest(false)
7682
}).catch((error) => {
7783
setError(error.message)
7884
setSendingRequest(false)
7985
})
8086
}
8187

88+
const handleSearch = (search: string) => {
89+
search = search.trim()
90+
if (!search) {
91+
setLrdDocsJson(lrdDocsJsonCopy)
92+
return
93+
}
94+
const fuse = new Fuse(lrdDocsJson, searchOptions);
95+
96+
const filteredData = fuse.search(search);
97+
const filteredLrdJson: IAPIInfo[] = []
98+
for (let i = 0; i < filteredData.length; i++) {
99+
filteredLrdJson.push(filteredData[i].item)
100+
}
101+
102+
setLrdDocsJson(filteredLrdJson)
103+
}
104+
82105
const handleChangeSettings = (showGet: string,
83106
showPost: string,
84107
showDelete: string,
@@ -92,7 +115,7 @@ export default function App() {
92115
}
93116
return (
94117
<>
95-
<TopNav handleChangeSettings={handleChangeSettings} />
118+
<TopNav handleChangeSettings={handleChangeSettings} handleSearch={handleSearch} />
96119
{sendingRequest && (
97120
<progress className="progress progress-success w-full"></progress>
98121
)}

ui/src/components/Sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default function Sidebar(props: Props) {
2929
<>
3030
<aside>
3131
<h2 className="title pl-5 pt-2 mb-5">
32-
API List
32+
API List <span className='text-slate-500 capitalize'>Total {lrdDocsJson.length}</span>
3333
</h2>
3434
<ul>
3535
{lrdDocsJson.map((lrdDocsItem) => (

ui/src/components/TopNav.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ interface Props {
1313
showHead: string,
1414
sort: string,
1515
groupby: string) => void
16+
handleSearch: (search: string) => void
1617
}
1718
export default function TopNav(props: Props) {
1819

19-
const { handleChangeSettings } = props
20+
const { handleChangeSettings, handleSearch } = props
2021
const [theme, setTheme] = useLocalStorage('theme', '');
2122
const [sort, setSort] = useLocalStorage('sort', 'default');
2223
const [groupby, setGroupby] = useLocalStorage('groupby', 'default');
@@ -97,6 +98,9 @@ export default function TopNav(props: Props) {
9798
</a>
9899
</div>
99100
<div className="flex-none">
101+
<div className="form-control">
102+
<input type="text" placeholder="Search" className="input input-sm input-bordered" onChange={ (e) => handleSearch(e.target.value) } />
103+
</div>
100104
<div className="menu menu-horizontal px-6 ">
101105
<label className="swap swap-rotate">
102106
<input type="checkbox" onChange={toggleDarkMode} />

0 commit comments

Comments
 (0)