8000 Add basic account filter/search by bturner-r7 · Pull Request #120 · rapid7/awsaml · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add basic account filter/search #120

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

Merged
merged 5 commits into from
Aug 7, 2018
Merged

Add basic account filter/search #120

merged 5 commits into from
Aug 7, 2018

Conversation

bturner-r7
Copy link
Contributor

This adds a very rudimentary search function for recent logins. It's a simple case insenstive search. It doesn't re-order results or anything fancy like that. This should make it easier to quickly find accounts if you have given them helpful aliases.

Currently it searches both the name and url. Searching the URL may not make sense, but it didn't hurt in my tests.

awsaml-search

GH-118

This adds a very rudimentary search function for recent logins.  It's a
simple case insenstive search.  It doesn't re-order results or anything
fancy like that.  This should make it easier to quickly find accounts if
you have given them helpful aliases.

Currently it searches both the name and url.  Searching the URL may not
make sense, but it didn't hurt in my tests.

GH-118
@coveralls
Copy link
coveralls commented Aug 6, 2018

Coverage Status

Coverage remained the same at 90.625% when pulling c5470b1 on recent-login-filter into 155506d on master.

@rapid7 rapid7 deleted a comment from dgreene-r7 Aug 6, 2018
Copy link
Contributor
@dgreene-r7 dgreene-r7 left a comment

Choose a reason for hiding this comment

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

I'd like @tquetano-r7 to take a look at this if he has a chance too.

const mapDispatchToProps = () => ({
});

export const RecentLogins = connect(mapStateToProps, mapDispatchToProps)(RecentLoginsComponent);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need to connect the Redux state here.

const metadataUrls = this.props.metadataUrls;
const filterText = this.state.filterText;

if (filterText === undefined || filterText === '') {
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be simplified as if (!filterText) {.

@bturner-r7
Copy link
Contributor Author

Thanks @dgreene-r7 - I disconnected redux state and simplified the empty check.

});
};

filterMetadataUrls = () => {

Choose a reason for hiding this comment

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

theres no reason this needs to be an instance field ... this could easily be a pure standalone function if passed the metadata / filterText as parameters.

<Login
key={url}
pretty={name}
profileId={i}

Choose a reason for hiding this comment

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

using the iteration index as an ID of any kind is very dangerous and de-optimizes react rerender cycles, u should consider using a consistent unique value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great call-out. This would have actually broken deleting a profile when URLs were filtered because the delete uses the iteration index.

Unfortunately, this is how the code was when I found it. I've attempted to fix by starting to store a UUID with each profile and then referencing the UUID instead of the iteration index: c5470b1

Thoughts?

filterText: '',
};

handleFilterInputChange = ({target: {value}}) => {
Copy link
@tquetano-r7 tquetano-r7 Aug 6, 2018

Choose a reason for hiding this comment

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

u may consider renaming value to take advantage of shorthand (and define the assignment contract in the initial line):

handleFilterInputChange = ({currentTarget: {value: filterText}}) => this.setState({filterText});

also, its considered best practice to use currentTarget instead of target.

This makes deletes a little safer and prevents us from needing to use
the iteration index for deletes.
@bturner-r7
Copy link
Contributor Author

I think I've addressed the code review comments. If @dgreene-r7 and @tquetano-r7 could take one more look I'd appreciate it. Especially this commit: c5470b1, which I added as a way to ensure deletes still work even when filtering URLs.

Copy link
@tquetano-r7 tquetano-r7 left a comment

Choose a reason for hiding this comment

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

👺

@bturner-r7 bturner-r7 merged commit 5f45c37 into master Aug 7, 2018
@bturner-r7 bturner-r7 deleted the recent-login-filter branch August 7, 2018 14:38
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.

5 participants
0