mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 18:57:05 +08:00
AIRequests: URL is not modifiable for requests
This commit is contained in:
@@ -16,6 +16,8 @@ class EditorPaneRequestURLCard extends ConsumerWidget {
|
||||
ref.watch(selectedIdStateProvider);
|
||||
final apiType = ref
|
||||
.watch(selectedRequestModelProvider.select((value) => value?.apiType));
|
||||
final aiHC = ref.watch(selectedRequestModelProvider
|
||||
.select((v) => v?.aiRequestModel?.hashCode));
|
||||
return Card(
|
||||
color: kColorTransparent,
|
||||
surfaceTintColor: kColorTransparent,
|
||||
@@ -44,8 +46,10 @@ class EditorPaneRequestURLCard extends ConsumerWidget {
|
||||
APIType.rest => kHSpacer5,
|
||||
_ => kHSpacer8,
|
||||
},
|
||||
const Expanded(
|
||||
child: URLTextField(),
|
||||
Expanded(
|
||||
child: URLTextField(
|
||||
key: aiHC == null ? null : ValueKey(aiHC),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
@@ -61,8 +65,10 @@ class EditorPaneRequestURLCard extends ConsumerWidget {
|
||||
APIType.rest => kHSpacer20,
|
||||
_ => kHSpacer8,
|
||||
},
|
||||
const Expanded(
|
||||
child: URLTextField(),
|
||||
Expanded(
|
||||
child: URLTextField(
|
||||
key: aiHC == null ? null : ValueKey(aiHC),
|
||||
),
|
||||
),
|
||||
kHSpacer20,
|
||||
const SizedBox(
|
||||
@@ -104,15 +110,31 @@ class URLTextField extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final selectedId = ref.watch(selectedIdStateProvider);
|
||||
|
||||
final reqM = ref.read(collectionStateNotifierProvider)![selectedId]!;
|
||||
final aiReqM = reqM.aiRequestModel;
|
||||
final payload = aiReqM?.payload;
|
||||
|
||||
return EnvURLField(
|
||||
selectedId: selectedId!,
|
||||
initialValue: ref
|
||||
.read(collectionStateNotifierProvider.notifier)
|
||||
.getRequestModel(selectedId)
|
||||
?.httpRequestModel
|
||||
?.url,
|
||||
initialValue: payload?.endpoint ??
|
||||
ref
|
||||
.read(collectionStateNotifierProvider.notifier)
|
||||
.getRequestModel(selectedId)
|
||||
?.httpRequestModel
|
||||
?.url,
|
||||
onChanged: (value) {
|
||||
ref.read(collectionStateNotifierProvider.notifier).update(url: value);
|
||||
final aim = ref
|
||||
.read(collectionStateNotifierProvider)![selectedId]!
|
||||
.aiRequestModel;
|
||||
if (aim != null) {
|
||||
aim.payload.endpoint = value;
|
||||
ref
|
||||
.read(collectionStateNotifierProvider.notifier)
|
||||
.update(aiRequestModel: aim.updatePayload(aim.payload));
|
||||
} else {
|
||||
ref.read(collectionStateNotifierProvider.notifier).update(url: value);
|
||||
}
|
||||
},
|
||||
onFieldSubmitted: (value) {
|
||||
ref.read(collectionStateNotifierProvider.notifier).sendRequest();
|
||||
|
||||
Reference in New Issue
Block a user