22
33namespace ZPMLabs \FilamentApiDocsBuilder \Filament \Actions ;
44
5+ use Filament \Actions \Action ;
6+ use Filament \Forms \Components \KeyValue ;
7+ use Filament \Forms \Components \TextInput ;
8+ use Filament \Forms \Components \ViewField ;
9+ use Filament \Schemas \Components \Actions ;
10+ use Filament \Schemas \Components \Grid ;
11+ use Filament \Schemas \Components \Utilities \Get ;
12+ use Filament \Schemas \Components \Utilities \Set ;
13+ use Filament \Support \Enums \Width ;
514use ZPMLabs \FilamentApiDocsBuilder \Enums \HttpStatuses ;
6- use Filament \Infolists \Components \Actions \Action ;
715use Illuminate \Support \Facades \Http ;
816use InvalidArgumentException ;
9- use Filament \Forms ;
10- use Filament \Forms \Get ;
11- use Filament \Forms \Set ;
12- use Filament \Support \Enums \MaxWidth ;
1317use Illuminate \Support \Collection ;
14- use Illuminate \Support \HtmlString ;
1518use Tempest \Highlight \Highlighter ;
1619use Tempest \Highlight \Themes \InlineTheme ;
1720
@@ -38,7 +41,7 @@ public function item($item, $parameters, $allParams)
3841 $ testingForm = [];
3942
4043 if ($ item ['details ' ]['auth_required ' ]) {
41- $ testingForm [] = Forms \ Components \ TextInput::make ('token ' )
44+ $ testingForm [] = TextInput::make ('token ' )
4245 ->columnSpanFull ()
4346 ->revealable ()
4447 ->password (); // Token input for authentication
@@ -50,23 +53,23 @@ public function item($item, $parameters, $allParams)
5053 $ this ->hidden (fn () => empty ($ item ['details ' ]['endpoint ' ]))
5154 ->label ('Test Endpoint ' )
5255 ->modalDescription ($ item ['details ' ]['endpoint ' ])
53- ->modalWidth (MaxWidth ::FiveExtraLarge)
56+ ->modalWidth (Width ::FiveExtraLarge)
5457 ->modalCancelAction (false )
5558 ->modalSubmitAction (false )
5659 ->form ([
57- Forms \ Components \ Grid::make ()
60+ Grid::make ()
5861 ->columns ()
5962 ->schema ([
60- Forms \ Components \ Grid::make ()
63+ Grid::make ()
6164 ->columnSpan (1 )
6265 ->schema ($ testingForm ), // Form fields for API testing
63- Forms \ Components \ ViewField::make ('response ' )
66+ ViewField::make ('response ' )
6467 ->view ('filament-api-docs-builder::filament.viewJson ' )
6568 ->default (['response ' => '{} ' ])
6669 ->columnSpan (1 ) // Display formatted response
6770 ]),
68- Forms \ Components \ Actions::make ([
69- Forms \ Components \ Actions \ Action::make ('send ' )
71+ Actions::make ([
72+ Action::make ('send ' )
7073 ->action (function (Set $ set , Get $ get ) use ($ item , $ allParams ) {
7174 // Handle request sending and response processing
7275 $ data = $ get ();
@@ -99,7 +102,7 @@ protected function handleResponse($response, $set)
99102 $ prettyResponse = json_encode ($ responseData , JSON_PRETTY_PRINT );
100103
101104 // Highlight the JSON response using a syntax highlighter
102- $ formated = (new Highlighter (new InlineTheme (__DIR__ . '/../../../vendor/tempest/highlight/src/Themes/Css /solarized-dark.css ' )))
105+ $ formated = (new Highlighter (new InlineTheme (__DIR__ . '/../../../resources/themes /solarized-dark.css ' )))
103106 ->parse ($ prettyResponse , 'json ' );
104107
105108 $ set ('response ' , [
@@ -211,7 +214,7 @@ protected function buildTestingFormComponents($parameters, $allParams)
211214
212215 foreach ($ parameters as $ location => $ data ) {
213216 if (!empty ($ data ['params ' ])) {
214- $ components [$ location ] = Forms \ Components \ KeyValue::make (strtolower ($ location ))
217+ $ components [$ location ] = KeyValue::make (strtolower ($ location ))
215218 ->label (ucfirst ($ location ))
216219 ->columnSpanFull ()
217220 ->addable (false )
@@ -239,7 +242,7 @@ protected function updateStateOnChange($state, $allParams, $location)
239242 {
240243 foreach ($ allParams ->where ('visible ' , 'conditionally ' ) as $ param ) {
241244 $ name = $ param ['required ' ] ? $ param ['name ' ] . '* ' : $ param ['name ' ];
242- $ condParam = $ allParams ->where ('name ' , $ param ['visibility_condition_param ' ])->first ();
245+ $ condParam = ( $ param [ ' visible ' ] == ' always ' || ! isset ( $ param [ ' visibility_condition_param ' ])) ? null : $ allParams ->where ('name ' , $ param ['visibility_condition_param ' ])->first ();
243246
244247 if ($ this ->shouldRemoveParamFromState ($ param , $ location , $ state , $ name , $ condParam )) {
245248 unset($ state [$ name ]);
@@ -250,7 +253,7 @@ protected function updateStateOnChange($state, $allParams, $location)
250253
251254 foreach ($ allParams ->where ('visible ' , 'conditionally ' ) as $ param ) {
252255 $ name = $ param ['required ' ] ? $ param ['name ' ] . '* ' : $ param ['name ' ];
253- $ condParam = $ allParams ->where ('name ' , $ param ['visibility_condition_param ' ])->first ();
256+ $ condParam = ( $ param [ ' visible ' ] == ' always ' || ! isset ( $ param [ ' visibility_condition_param ' ])) ? null : $ allParams ->where ('name ' , $ param ['visibility_condition_param ' ])->first ();
254257
255258 if ($ this ->shouldAddParamToState ($ param , $ location , $ state , $ name , $ condParam )) {
256259 $ state [$ name ] = $ param ['value ' ];
0 commit comments