-
Notifications
You must be signed in to change notification settings - Fork 472
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
UI – Calendar events modal follow up #17788
Merged
jacobshandling
merged 8 commits into
17230-calendar-feature
from
cal-events-modal-follow-up
Mar 22, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
df7b515
finalize disabled dropdown option styles
7133d79
only update changed policies
2870384
update type name, investigate further improvements
913ee81
refactor onInputChange into 2 functions
c59e7c7
only update config if changed
8f8030d
make automations button always blue
9aa3c15
grey help text for valid dropdown options
955a098
restore on tooltips to prevent chaos
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/_styles.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,19 +21,43 @@ | |
.Select > .Select-menu-outer { | ||
left: -186px; | ||
width: 360px; | ||
.dropdown__help-text { | ||
color: $ui-fleet-black-50; | ||
} | ||
.is-disabled * { | ||
color: $ui-fleet-black-25; | ||
.label-text { | ||
font-style: normal; | ||
// increase height to allow for broader tooltip activation area | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. love it |
||
position: absolute; | ||
height: 34px; | ||
width: 100%; | ||
} | ||
.dropdown__help-text { | ||
// compensate for absolute label-text height | ||
margin-top: 20px; | ||
} | ||
.react-tooltip { | ||
@include tooltip-text; | ||
font-style: normal; | ||
text-align: center; | ||
} | ||
} | ||
} | ||
.Select-control { | ||
margin-top: 0; | ||
gap: 6px; | ||
} | ||
.Select-placeholder { | ||
font-weight: $bold; | ||
.Select-placeholder { | ||
color: $core-vibrant-blue; | ||
font-weight: $bold; | ||
} | ||
.dropdown__custom-arrow .dropdown__icon { | ||
svg { | ||
path { | ||
stroke: $core-vibrant-blue-over; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,10 +55,6 @@ const CalendarEventsModal = ({ | |
const [formData, setFormData] = useState<ICalendarEventsFormData>({ | ||
enabled, | ||
url, | ||
// TODO - stay udpdated on state of backend approach to syncing policies in the policies table | ||
// and in the new calendar table | ||
// id may change if policy was deleted | ||
// name could change if policy was renamed | ||
policies: policies.map((policy) => ({ | ||
name: policy.name, | ||
id: policy.id, | ||
|
@@ -87,29 +83,26 @@ const CalendarEventsModal = ({ | |
return errors; | ||
}; | ||
|
||
// TODO - separate change handlers for checkboxes: | ||
// const onPolicyUpdate = ... | ||
// const onTextFieldUpdate = ... | ||
|
||
const onInputChange = useCallback( | ||
(newVal: { name: FormNames; value: string | number | boolean }) => { | ||
// two onChange handlers to handle different levels of nesting in the form data | ||
const onFeatureEnabledOrUrlChange = useCallback( | ||
(newVal: { name: "enabled" | "url"; value: string | boolean }) => { | ||
const { name, value } = newVal; | ||
let newFormData: ICalendarEventsFormData; | ||
// for the first two fields, set the new value directly | ||
if (["enabled", "url"].includes(name)) { | ||
newFormData = { ...formData, [name]: value }; | ||
} else if (typeof value === "boolean") { | ||
// otherwise, set the value for a nested policy | ||
const newFormPolicies = formData.policies.map((formPolicy) => { | ||
if (formPolicy.name === name) { | ||
return { ...formPolicy, isChecked: value }; | ||
} | ||
return formPolicy; | ||
}); | ||
newFormData = { ...formData, policies: newFormPolicies }; | ||
} else { | ||
throw TypeError("Unexpected value type for policy checkbox"); | ||
} | ||
const newFormData = { ...formData, [name]: value }; | ||
setFormData(newFormData); | ||
setFormErrors(validateCalendarEventsFormData(newFormData)); | ||
}, | ||
[formData] | ||
); | ||
const onPolicyEnabledChange = useCallback( | ||
(newVal: { name: FormNames; value: boolean }) => { | ||
const { name, value } = newVal; | ||
const newFormPolicies = formData.policies.map((formPolicy) => { | ||
if (formPolicy.name === name) { | ||
return { ...formPolicy, isChecked: value }; | ||
} | ||
return formPolicy; | ||
}); | ||
const newFormData = { ...formData, policies: newFormPolicies }; | ||
setFormData(newFormData); | ||
setFormErrors(validateCalendarEventsFormData(newFormData)); | ||
}, | ||
|
@@ -157,7 +150,7 @@ const CalendarEventsModal = ({ | |
name={name} | ||
// can't use parseTarget as value needs to be set to !currentValue | ||
onChange={() => { | ||
onInputChange({ name, value: !isChecked }); | ||
onPolicyEnabledChange({ name, value: !isChecked }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔥 |
||
}} | ||
> | ||
{name} | ||
|
@@ -232,7 +225,10 @@ const CalendarEventsModal = ({ | |
<Slider | ||
value={formData.enabled} | ||
onChange={() => { | ||
onInputChange({ name: "enabled", value: !formData.enabled }); | ||
onFeatureEnabledOrUrlChange({ | ||
name: "enabled", | ||
value: !formData.enabled, | ||
}); | ||
}} | ||
inactiveText="Disabled" | ||
activeText="Enabled" | ||
|
@@ -251,7 +247,7 @@ const CalendarEventsModal = ({ | |
<InputField | ||
placeholder="https://server.com/example" | ||
label="Resolution webhook URL" | ||
onChange={onInputChange} | ||
onChange={onFeatureEnabledOrUrlChange} | ||
name="url" | ||
value={formData.url} | ||
parseTarget | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏