Use "Example payload" for all payload example buttons and always enable example buttons (#47167)
**Related issue:** #44719 Also, make sure the **Dashboard > Activity > Automations** modal is grayed out when in GitOps mode. # Checklist for submitter ## Testing - [x] QA'd all new/changed functionality manually <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Style** * Standardized button labels across modals to use "Example payload" / "Example data" consistently instead of mixed "Preview" or "Show/Hide" variants. * **Bug Fixes** * Disabled relevant controls (example toggles, payload preview, destination URL inputs, toggles) when GitOps mode is enabled so UI reflects read-only mode. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -127,8 +127,7 @@ interface ISoftwareCountResponse {
|
||||
// *FormData instead, even for programmatic request bodies (e.g.
|
||||
// IDeleteQueriesFormData). One consistent suffix is easier to follow than
|
||||
// asking each dev to judge "is this form-driven enough?"
|
||||
// *PreviewPayload is fine for outgoing webhook shapes (matches the
|
||||
// "Preview payload" UI terminology).
|
||||
// *PreviewPayload is fine for outgoing webhook shapes.
|
||||
```
|
||||
|
||||
## Utilities
|
||||
|
||||
+16
-13
@@ -9,6 +9,7 @@ import InputField from "components/forms/fields/InputField";
|
||||
import Button from "components/buttons/Button";
|
||||
import RevealButton from "components/buttons/RevealButton";
|
||||
|
||||
import useGitOpsMode from "hooks/useGitOpsMode";
|
||||
import { syntaxHighlight } from "utilities/helpers";
|
||||
import CustomLink from "components/CustomLink";
|
||||
|
||||
@@ -44,6 +45,8 @@ const ActivityFeedAutomationsModal = ({
|
||||
);
|
||||
const [showExamplePayload, setShowExamplePayload] = useState(false);
|
||||
|
||||
const { gitOpsModeEnabled } = useGitOpsMode();
|
||||
|
||||
const validateForm = (newFormData: IAFAMFormData) => {
|
||||
const errors: Record<string, string> = {};
|
||||
const { url: newUrl } = newFormData;
|
||||
@@ -143,6 +146,7 @@ const ActivityFeedAutomationsModal = ({
|
||||
onChange={onFeatureEnabledChange}
|
||||
inactiveText="Disabled"
|
||||
activeText="Enabled"
|
||||
disabled={gitOpsModeEnabled}
|
||||
/>
|
||||
<div
|
||||
className={`form ${formData.enabled ? "" : "form-fields--disabled"}`}
|
||||
@@ -155,21 +159,20 @@ const ActivityFeedAutomationsModal = ({
|
||||
value={formData.url}
|
||||
error={formErrors.url}
|
||||
helpText="Fleet will send a JSON payload to this URL whenever a new activity is generated."
|
||||
disabled={!formData.enabled}
|
||||
disabled={!formData.enabled || gitOpsModeEnabled}
|
||||
/>
|
||||
<RevealButton
|
||||
isShowing={showExamplePayload}
|
||||
className={`${baseClass}__show-example-payload-toggle`}
|
||||
hideText="Hide example payload"
|
||||
showText="Show example payload"
|
||||
caretPosition="after"
|
||||
onClick={() => {
|
||||
setShowExamplePayload(!showExamplePayload);
|
||||
}}
|
||||
disabled={!formData.enabled}
|
||||
/>
|
||||
{showExamplePayload && renderExamplePayload()}
|
||||
</div>
|
||||
<RevealButton
|
||||
isShowing={showExamplePayload}
|
||||
className={`${baseClass}__show-example-payload-toggle`}
|
||||
hideText="Example payload"
|
||||
showText="Example payload"
|
||||
caretPosition="after"
|
||||
onClick={() => {
|
||||
setShowExamplePayload(!showExamplePayload);
|
||||
}}
|
||||
/>
|
||||
{showExamplePayload && renderExamplePayload()}
|
||||
<div className="modal-cta-wrap">
|
||||
<Button
|
||||
type="submit"
|
||||
|
||||
+1
-2
@@ -471,9 +471,8 @@ const ManageAutomationsModal = ({
|
||||
type="button"
|
||||
variant="inverse"
|
||||
onClick={togglePreviewPayloadModal}
|
||||
disabled={!softwareAutomationsEnabled}
|
||||
>
|
||||
Preview payload
|
||||
Example payload
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
|
||||
+1
-1
@@ -245,7 +245,7 @@ const EndUserMigrationSection = ({ router }: IEndUserMigrationSectionProps) => {
|
||||
variant="inverse"
|
||||
onClick={toggleExamplePayloadModal}
|
||||
>
|
||||
Preview payload
|
||||
Example payload
|
||||
</Button>
|
||||
<GitOpsModeTooltipWrapper
|
||||
tipOffset={8}
|
||||
|
||||
+9
-10
@@ -187,17 +187,16 @@ const CalendarEventsModal = forwardRef<
|
||||
helpText="A request will be sent to this URL during the calendar event. Use it to trigger auto-remediation."
|
||||
disabled={!formData.enabled || gitOpsModeEnabled}
|
||||
/>
|
||||
<RevealButton
|
||||
isShowing={showExamplePayload}
|
||||
className={`${baseClass}__show-example-payload-toggle`}
|
||||
hideText="Hide example payload"
|
||||
showText="Show example payload"
|
||||
caretPosition="after"
|
||||
onClick={() => setShowExamplePayload(!showExamplePayload)}
|
||||
disabled={!formData.enabled}
|
||||
/>
|
||||
{showExamplePayload && renderExamplePayload()}
|
||||
</div>
|
||||
<RevealButton
|
||||
isShowing={showExamplePayload}
|
||||
className={`${baseClass}__show-example-payload-toggle`}
|
||||
hideText="Example payload"
|
||||
showText="Example payload"
|
||||
caretPosition="after"
|
||||
onClick={() => setShowExamplePayload(!showExamplePayload)}
|
||||
/>
|
||||
{showExamplePayload && renderExamplePayload()}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
+13
-10
@@ -241,16 +241,6 @@ const OtherWorkflowsModal = forwardRef<
|
||||
tooltip="Provide a URL to deliver a webhook request to."
|
||||
disabled={!isPolicyAutomationsEnabled || gitOpsModeEnabled}
|
||||
/>
|
||||
<RevealButton
|
||||
isShowing={showExamplePayload}
|
||||
className={baseClass}
|
||||
hideText="Hide example payload"
|
||||
showText="Show example payload"
|
||||
caretPosition="after"
|
||||
onClick={() => setShowExamplePayload(!showExamplePayload)}
|
||||
disabled={!isPolicyAutomationsEnabled}
|
||||
/>
|
||||
{showExamplePayload && <ExamplePayload />}
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -353,6 +343,19 @@ const OtherWorkflowsModal = forwardRef<
|
||||
</div>
|
||||
{isWebhookEnabled ? renderWebhook() : renderIntegrations()}
|
||||
</div>
|
||||
{isWebhookEnabled && (
|
||||
<>
|
||||
<RevealButton
|
||||
isShowing={showExamplePayload}
|
||||
className={baseClass}
|
||||
hideText="Example payload"
|
||||
showText="Example payload"
|
||||
caretPosition="after"
|
||||
onClick={() => setShowExamplePayload(!showExamplePayload)}
|
||||
/>
|
||||
{showExamplePayload && <ExamplePayload />}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
+1
-1
@@ -230,7 +230,7 @@ const ManageQueryAutomationsModal = ({
|
||||
onClick={togglePreviewDataModal}
|
||||
className={`${baseClass}__preview-data`}
|
||||
>
|
||||
Preview data
|
||||
Example data
|
||||
</Button>
|
||||
<div className="modal-cta-wrap">
|
||||
<GitOpsModeTooltipWrapper
|
||||
|
||||
Reference in New Issue
Block a user