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

Alertmanager: Refactored #3937

Conversation

dtaylor113
Copy link
Contributor

Refactored:

  • moved single-use functions out of utils, per @kyoto 's comment
  • updated alert-manager-yaml-editor to use new getAlertManagerYAML method in utils
  • moved sub-forms to separate files
  • updated ReceiverBaseForm, , per @kyoto 's comment, to:
    • clearly show INIT value handling
    • generically handle subforms via subFormFactory
    • implemended useFormStore custom hook for generic storing of form values

@openshift-ci-robot openshift-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. component/core Related to console core functionality component/monitoring Related to monitoring labels Jan 13, 2020
Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @dtaylor113, I'm still working through this, but wanted to get you some initial comments. I'm a little concerned with this approach since we lose type safety.

@dtaylor113
Copy link
Contributor Author

dtaylor113 commented Jan 14, 2020

Hi @spadgett , I believe I have addressed the majority of your initial review comments. Please see last commit for these updates, and additional comments above for unresolved issues. For fixed comments, I tag each comment as 'fixed' then resolve the conversation -let me know if this is ok for you, I feel it cleans up the code review and just leaves any open issues visible, but it could be annoying to you so I'm just checking :-)

@dtaylor113
Copy link
Contributor Author

/retest

@dtaylor113
Copy link
Contributor Author

dtaylor113 commented Jan 17, 2020

Hi @spadgett, thanks for round of comments, I believe I have addressed them. Please see last commits for changes.

frontend/integration-tests/protractor.conf.ts Outdated Show resolved Hide resolved
dropDownClassName="dropdown--full-width"
data-test-id="receiver-type"
selectedKey={formValues.receiverType}
onChange={(e) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't an event, so e as a name is misleading.

Suggested change
onChange={(e) =>
onChange={(receiverType) =>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@dtaylor113 dtaylor113 force-pushed the alertmanager-just-refactoring branch 2 times, most recently from 1a39279 to c68a971 Compare January 21, 2020 16:07
@openshift openshift deleted a comment from openshift-ci-robot Jan 21, 2020
@dtaylor113 dtaylor113 force-pushed the alertmanager-just-refactoring branch 2 times, most recently from cc32a5a to 1a66fee Compare January 21, 2020 16:31
@dtaylor113
Copy link
Contributor Author

/retest

@openshift openshift deleted a comment from openshift-ci-robot Jan 21, 2020
Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dtaylor113. This is looking a lot cleaner 👍

@@ -0,0 +1,3 @@
import { $ } from 'protractor';

export const firstDropdownMenuByTestID = (id: string) => $(`[data-test-dropdown-menu=${id}]`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop the first prefix :)

Suggested change
export const firstDropdownMenuByTestID = (id: string) => $(`[data-test-dropdown-menu=${id}]`);
export const dropdownMenuForID = (id: string) => $(`[data-test-dropdown-menu=${id}]`);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}
};

function formReducer(formValues, action) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function formReducer(formValues, action) {
const formReducer = (formValues, action) => {

Would be nice to have types here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

config = getAlertmanagerConfig(secret, setErrorMsg);
}

const INITIAL_STATE = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: why all caps in the name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just so it stands out more as it's being setup in the next couple of code blocks


const isFormInvalid =
_.isEmpty(formValues.receiverName) ||
_.isEmpty(formValues.receiverType) ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these are strings, you don't need to use _.isEmpty, just !formValues.receiverName

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I had these fixed in large PR we closed, it was one of Ben's initial comments. Lost them in recreating this PR. fixed

};

export const isFormInvalid = (formValues): boolean => {
return _.isEmpty(formValues.pagerDutyIntegrationKey);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a string, right?

Suggested change
return _.isEmpty(formValues.pagerDutyIntegrationKey);
return !formValues.pagerDutyIntegrationKey;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 28 to 32
return _.isEmpty(receiverConfig)
? { webhookUrl: '' }
: {
webhookUrl: receiverConfig?.url,
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be

return {
  webhookURL: receiverConfig?.url || ''
};

If this is not a prop in the Alertmanager config, use webhookURL

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

};

export const isFormInvalid = (formValues) => {
return _.isEmpty(formValues.webhookUrl);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return _.isEmpty(formValues.webhookUrl);
return !formValues.webhookUrl;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve
/lgtm

Thanks for your patience @dtaylor113

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 21, 2020
@spadgett spadgett added this to the v4.4 milestone Jan 21, 2020
@spadgett
Copy link
Member

/hold

@dtaylor113 do you mind squashing?

@openshift-ci-robot openshift-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jan 21, 2020
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jan 21, 2020
@spadgett
Copy link
Member

/approve
/lgtm
/hold cancel

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jan 21, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dtaylor113, spadgett

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@spadgett
Copy link
Member

/hold
the merge queue is blocked

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 21, 2020
@spadgett
Copy link
Member

/hold cancel
/retest

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 22, 2020
@openshift-merge-robot openshift-merge-robot merged commit 013a01c into openshift:master Jan 22, 2020
@dtaylor113 dtaylor113 deleted the alertmanager-just-refactoring branch April 27, 2020 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality component/monitoring Related to monitoring lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants