From f19dba31da4fe6e68ca051f3f0781d25db0b9130 Mon Sep 17 00:00:00 2001
From: gingervitis <omqmail@gmail.com>
Date: Sun, 3 Jan 2021 04:10:08 -0800
Subject: [PATCH] clean up and extra fields

---
 .../components/config/form-textfield.tsx      | 29 +++++++------------
 web/pages/config-server-details.tsx           |  2 +-
 web/types/config-section.ts                   |  6 ++--
 3 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/web/pages/components/config/form-textfield.tsx b/web/pages/components/config/form-textfield.tsx
index 50ba29c12..096ac370a 100644
--- a/web/pages/components/config/form-textfield.tsx
+++ b/web/pages/components/config/form-textfield.tsx
@@ -1,21 +1,4 @@
-/*
-- auto saves ,ajax call (submit when blur or onEnter)
-- set default text
-- show error state/confirm states
-- show info
-- label
-- min/max length
 
-- populate with curren val (from local sstate)
-
-load page, 
-get all config vals, 
-save to local state/context.
-read vals from there.
-update vals to state, andthru api.
-
-
-*/
 import React, { useState, useContext } from 'react';
 import { Button, Form, Input, InputNumber } from 'antd';
 import { FormItemProps } from 'antd/es/form';
@@ -51,6 +34,8 @@ export default function TextField(props: TextFieldProps) {
     handleResetValue,
     initialValues = {},
     onSubmit,
+    onBlur,
+    onChange,
     type,
   } = props;
 
@@ -92,6 +77,10 @@ export default function TextField(props: TextFieldProps) {
       setHasChanged(true);
       setFieldValueForSubmit(val);
     }
+    // if an extra onChange handler was sent in as a prop, let's run that too.
+    if (onChange) {
+      onChange();
+    }
   };
 
   // if you blur a required field with an empty value, restore its original value
@@ -100,12 +89,16 @@ export default function TextField(props: TextFieldProps) {
     if (required && val === '') {
       handleResetValue(fieldName);
     }
+
+    // if an extra onBlur handler was sent in as a prop, let's run that too.
+    if (onBlur) {
+      onBlur();
+    }
   };
 
   // how to get current value of input
   const handleSubmit = async () => {
     if ((required && fieldValueForSubmit !== '') || fieldValueForSubmit !== initialValue) {
-      // postUpdateToAPI(fieldValueForSubmit);
       setSubmitStatus('validating');
 
       await postConfigUpdateToAPI({
diff --git a/web/pages/config-server-details.tsx b/web/pages/config-server-details.tsx
index 9f9567fe9..39f284f46 100644
--- a/web/pages/config-server-details.tsx
+++ b/web/pages/config-server-details.tsx
@@ -1,7 +1,7 @@
 import React, { useContext, useEffect } from 'react';
 import { Typography, Form } from 'antd';
 
-import TextField, { TEXTFIELD_TYPE_NUMBER, TEXTFIELD_TYPE_PASSWORD, TEXTFIELD_TYPE_TEXTAREA } from './components/config/form-textfield';
+import TextField, { TEXTFIELD_TYPE_NUMBER, TEXTFIELD_TYPE_PASSWORD } from './components/config/form-textfield';
 
 import { ServerStatusContext } from '../utils/server-status-context';
 import { TEXTFIELD_DEFAULTS } from './components/config/constants';
diff --git a/web/types/config-section.ts b/web/types/config-section.ts
index ce4159d32..4e60b3eb4 100644
--- a/web/types/config-section.ts
+++ b/web/types/config-section.ts
@@ -1,7 +1,7 @@
 // TS types for elements on the Config pages
 
 export interface TextFieldProps {
-  handleResetValue?: (fieldName) => void;
+  handleResetValue?: (fieldName: string) => void;
   fieldName: string;
   initialValues?: any;
   type?: string;
@@ -27,8 +27,8 @@ export interface UpdateArgs {
 export interface ApiPostArgs {
   apiPath: string,
   data: object,
-  onSuccess?: (arg: any) => {},
-  onError?: (arg: any) => {},
+  onSuccess?: (arg: any) => void,
+  onError?: (arg: any) => void,
 }
 
 export interface ConfigDirectoryFields {