Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source loggingConfig tab #363

Merged
merged 4 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const ActionFormTemplate: React.FC<ActionFormTemplateProps> = ({ action }
};

const handleSetFormValues = (): void => {
const basicFields: string[] = ["name", "description", "priority", "async", "isLockable", "isEnabled"];
const basicFields: string[] = ["reference", "name", "description", "priority", "async", "isLockable", "isEnabled"];
basicFields.forEach((field) => setValue(field, action[field]));

setActionConditionsFieldValue(JSON.stringify(action["conditions"], null, 2));
Expand Down
145 changes: 143 additions & 2 deletions pwa/src/templates/templateParts/sourcesForm/SourceFormTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useTranslation } from "react-i18next";
import { InputCheckbox, InputText, SelectSingle, Textarea } from "@conduction/components";
import { useSource } from "../../../hooks/source";
import { useQueryClient } from "react-query";
import { CreateKeyValue, IKeyValue } from "@conduction/components/lib/components/formFields";
import { CreateKeyValue, IKeyValue, InputNumber } from "@conduction/components/lib/components/formFields";
import { SourcesAuthFormTemplate } from "./SourcesAuthFormTemplate";
import { useIsLoadingContext } from "../../../context/isLoading";
import { translateDate } from "../../../services/dateFormat";
Expand Down Expand Up @@ -108,6 +108,17 @@ export const SourceFormTemplate: React.FC<SourceTemplateProps> = ({ source }) =>
advancedSwitchState.decodeContent === "string" ? data.decode_content_str : data.decode_content_bool,
proxy: data.proxy,
},
loggingConfig: {
callBody: data.callBody,
callContentType: data.callContentType,
callQuery: data.callQuery,
callUrl: data.callUrl,
maxCharCountBody: data.maxCharCountBody,
maxCharCountErrorBody: data.maxCharCountErrorBody,
responseBody: data.responseBody,
responseContentType: data.responseContentType,
responseStatusCode: data.responseStatusCode,
},
};

Object.keys(payload)
Expand Down Expand Up @@ -152,6 +163,19 @@ export const SourceFormTemplate: React.FC<SourceTemplateProps> = ({ source }) =>
];
basicFields.forEach((field) => setValue(field, source[field]));

const loggingConfigFields: string[] = [
"callBody",
"callContentType",
"callQuery",
"callUrl",
"maxCharCountBody",
"maxCharCountErrorBody",
"responseBody",
"responseContentType",
"responseStatusCode",
];
loggingConfigFields.forEach((field) => setValue(field, source["loggingConfig"]?.field));

setValue(
"auth",
authSelectOptions.find((option) => source.auth === option.value),
Expand Down Expand Up @@ -257,6 +281,7 @@ export const SourceFormTemplate: React.FC<SourceTemplateProps> = ({ source }) =>
<Tab className={styles.tab} label={t("Query")} value={1} />
<Tab className={styles.tab} label={t("Header")} value={2} />
<Tab className={styles.tab} label={t("Advanced")} value={3} />
<Tab className={styles.tab} label={t("Logging config")} value={4} />
</Tabs>

<TabPanel className={styles.tabPanel} value="0">
Expand Down Expand Up @@ -288,7 +313,7 @@ export const SourceFormTemplate: React.FC<SourceTemplateProps> = ({ source }) =>
<FormField>
<FormFieldInput>
<FormFieldLabel>{t("Reference")}</FormFieldLabel>
<InputText {...{ register, errors }} name="reference" disabled={isLoading.actionForm} />
<InputText {...{ register, errors }} name="reference" disabled={isLoading.sourceForm} />
</FormFieldInput>
</FormField>

Expand Down Expand Up @@ -402,6 +427,122 @@ export const SourceFormTemplate: React.FC<SourceTemplateProps> = ({ source }) =>
<TabPanel className={styles.tabPanel} value="3">
<AdvancedSwitch />
</TabPanel>

<TabPanel className={styles.tabPanel} value="4">
<div className={styles.gridContainer}>
<p className={styles.infoParagraph}>
{t("Here you can configure what you want to log for requests that are made to this source.")}
</p>
<div className={styles.grid}>
<FormField>
<div className={styles.formFieldHeader}>
<FormFieldLabel>{t("Call body")}</FormFieldLabel>
</div>
<InputCheckbox
{...{ register, errors, control }}
name="callBody"
disabled={isLoading.sourceForm}
defaultChecked={true}
label="True"
/>
</FormField>
<FormField>
<div className={styles.formFieldHeader}>
<FormFieldLabel>{t("Call content type")}</FormFieldLabel>
</div>
<InputCheckbox
{...{ register, errors, control }}
name="callContentType"
disabled={isLoading.sourceForm}
defaultChecked={true}
label="True"
/>
</FormField>
<FormField>
<div className={styles.formFieldHeader}>
<FormFieldLabel>{t("Call query")}</FormFieldLabel>
</div>
<InputCheckbox
{...{ register, errors, control }}
name="callQuery"
disabled={isLoading.sourceForm}
defaultChecked={true}
label="True"
/>
</FormField>
<FormField>
<div className={styles.formFieldHeader}>
<FormFieldLabel>{t("Call url")}</FormFieldLabel>
</div>
<InputCheckbox
{...{ register, errors, control }}
name="callUrl"
disabled={isLoading.sourceForm}
defaultChecked={true}
label="True"
/>
</FormField>
<FormField>
<div className={styles.formFieldHeader}>
<FormFieldLabel>{t("Max character count body")}</FormFieldLabel>
</div>
<InputNumber
{...{ register, errors, control }}
name="maxCharCountBody"
disabled={isLoading.sourceForm}
defaultValue="500"
/>
</FormField>
<FormField>
<div className={styles.formFieldHeader}>
<FormFieldLabel>{t("Max character count error body")}</FormFieldLabel>
</div>
<InputNumber
{...{ register, errors, control }}
name="maxCharCountErrorBody"
disabled={isLoading.sourceForm}
defaultValue="2000"
/>
</FormField>
<FormField>
<div className={styles.formFieldHeader}>
<FormFieldLabel>{t("Response body")}</FormFieldLabel>
</div>
<InputCheckbox
{...{ register, errors, control }}
name="responseBody"
disabled={isLoading.sourceForm}
defaultChecked={true}
label="True"
/>
</FormField>
<FormField>
<div className={styles.formFieldHeader}>
<FormFieldLabel>{t("Response content type")}</FormFieldLabel>
</div>
<InputCheckbox
{...{ register, errors, control }}
name="responseContentType"
disabled={isLoading.sourceForm}
defaultChecked={true}
label="True"
/>
</FormField>
<FormField>
<div className={styles.formFieldHeader}>
<FormFieldLabel>{t("Response status code")}</FormFieldLabel>
</div>
<InputCheckbox
{...{ register, errors, control }}
name="responseStatusCode"
disabled={isLoading.sourceForm}
defaultChecked={true}
label="True"
/>
</FormField>
</div>
</div>
</TabPanel>
</TabContext>
</form>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
margin-block-end: var(--gateway-ui-size-xl);
}

.infoParagraph {
margin-block-end: var(--gateway-ui-size-xl);
}

.tooltip {
max-width: 250px;
background-color: var(--gateway-ui-color-black) !important;
Expand Down
Loading