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

Bugfix/improve s alert message for unsuccessful attempts #3288

Conversation

saransh-dev
Copy link
Contributor

Related issue #3239
Related PR #3275

Changes

  • removed extra return

Developer checklist

This checklist is to be completed by the PR developer:

  • Alternative solutions were compared/discussed before writing code
    • trade-offs with this solution are considered acceptable
  • Code in this PR adheres to the project styleguide
  • This pull request does not decrease project test coverage
  • If the code changes existing database collection(s), migration has been written
  • If UI texts are added or changed, all texts are internationalized

Reviewer checklist

Reviewed by: @krashna-deligence @marla-singer

This list is to be completed by the pull request reviewer:

  • Code works as described/expected
  • Code seems to be error free
    • no browser console errors visible
    • no server console errors visible
    • passes CI build
  • Code is written in a way that promotes maintainability
    • easy to understand
    • well organized
    • follows project coding standards and conventions
    • well documented

krashna-deligence and others added 20 commits December 20, 2017 10:53
Added configuration to run 2017Q4 version of Travis Trusty env.
…-is-removed

s alert added with successful message
…er-visiting-feedback-tab-of-a-public-api

fixed Show text for anonymous user visiting feedback tab of a public API
Add version information of Chimp and Chromedriver to Travis logs.
…ld-validate-if-is-used-by-some-api

Bugfix/remove proxy settings should validate if is used by some api
…licate-error

Return id of duplicate API in post api duplicate error
…token

Feature/generate and store login token
@ghost ghost assigned saransh-dev Dec 26, 2017
@ghost ghost added the in progress label Dec 26, 2017
@saransh-dev saransh-dev force-pushed the bugfix/improve-s-alert-message-for-unsuccessful-attempts branch 3 times, most recently from 21e47e6 to 3c11e54 Compare December 26, 2017 11:52
s alerts added

travis error resolved

travis error resolved

condition for invalid url added

looping changed

travis resolved

travis resolved

s alerts added

travis error resolved

travis error resolved

condition for invalid url added

looping changed

travis resolved

travis resolved

s alerts added

travis resolved
@saransh-dev saransh-dev force-pushed the bugfix/improve-s-alert-message-for-unsuccessful-attempts branch from 1e5ef71 to a5c5167 Compare December 26, 2017 11:58
…ts' into bugfix/improve-s-alert-message-for-unsuccessful-attempts
isValidUrl = regex.test(apiData.url);

// If json does't contain name and URL
if (apiData && !apiData.name && !apiData.url) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You declared apiData above. Boolean value of {} returns true. It means to not add it in the condition

if (!apiData.name && !apiData.url) {
 ... 
}


// If json doesn't have name and valid url
} else if (apiData && !apiData.name && !isValidUrl) {
const isValidUrl = regex.test(apiData.url);
Copy link
Contributor

Choose a reason for hiding this comment

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

You declared this value above and make the same action!

// Make sure status is successful
if (status.isSuccessful) {
if (status) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The redundant checking. status variable has the default value

{
      isSuccessful: false,
      message: '',
    };

The boolean value of Object is true

Remove it

} else if (apiData && !apiData.name && !isValidUrl) {
const isValidUrl = regex.test(apiData.url);
const invalidUrlAndWithoutName = TAPi18n
.__('importApiConfiguration_file_with_invalid_url_withoutName');
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Create one variable to store a message text and name it "message"
  2. The i18n tag has camel case format
    Must be "importApiConfiguration_errorText_invalidUrl"
    Remake all i18n tags that you added
  3. Create a new variable to store value if a file has invalid format
if (invalidFileFormat) {
  sAlert.error(message)
} else {
  Meteor.call('importApiConfigs', apiData, .... )
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Make the sane scenario as provided in the issue

Pseudocode

  1. lowerCase all object keys
  2. If no name and no url then invalidFileFormat = true; message = "Name & URL are requered"
  3. If name & no url then ...
  4. if url exists then
    • if no name then ...
    • if invalid url format then ...
    • if invalid url format and name exists then ...

Copy link
Contributor

Choose a reason for hiding this comment

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

The better solution is to create separate function that will return object with property:

  • invalidFileFormat: true/false
  • message: string

@marla-singer
Copy link
Contributor

@krashna-deligence @saransh-dev What the status of the PR?

@marla-singer
Copy link
Contributor

Closed this PR and moved all requested changes to original PR

@Nazarah
Copy link
Contributor

Nazarah commented Feb 22, 2018

@krashna-deligence @saransh-dev have made chage requests in the PR #3275. Please have a look.

@preriasusi preriasusi deleted the bugfix/improve-s-alert-message-for-unsuccessful-attempts branch August 29, 2018 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants