-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: Fuzzy and Regex searching (#9424)
Moves search things around to match an interface that can be switched in and out of fuzzy searching using fuse.js. We add both fuzzy searching and regex based searching to the codebase here, but it is not yet compiled in.
- Loading branch information
Showing
25 changed files
with
638 additions
and
500 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export default { | ||
ID: (item, value) => item.ID.toLowerCase().indexOf(value.toLowerCase()) !== -1, | ||
Name: (item, value) => item.Name.toLowerCase().indexOf(value.toLowerCase()) !== -1, | ||
ID: item => item.ID, | ||
Name: item => item.Name, | ||
}; |
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 |
---|---|---|
@@ -1,9 +1,7 @@ | ||
const allLabel = 'All Services (*)'.toLowerCase(); | ||
const allLabel = 'All Services (*)'; | ||
export default { | ||
SourceName: (item, value) => | ||
item.SourceName.toLowerCase().indexOf(value.toLowerCase()) !== -1 || | ||
(item.SourceName === '*' && allLabel.indexOf(value.toLowerCase()) !== -1), | ||
DestinationName: (item, value) => | ||
item.DestinationName.toLowerCase().indexOf(value.toLowerCase()) !== -1 || | ||
(item.DestinationName === '*' && allLabel.indexOf(value.toLowerCase()) !== -1), | ||
SourceName: item => | ||
[item.SourceName, item.SourceName === '*' ? allLabel : undefined].filter(Boolean), | ||
DestinationName: item => | ||
[item.DestinationName, item.DestinationName === '*' ? allLabel : undefined].filter(Boolean), | ||
}; |
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 |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import rightTrim from 'consul-ui/utils/right-trim'; | ||
export default { | ||
Key: (item, value) => | ||
Key: item => | ||
rightTrim(item.Key.toLowerCase()) | ||
.split('/') | ||
.filter(item => Boolean(item)) | ||
.pop() | ||
.indexOf(value.toLowerCase()) !== -1, | ||
.pop(), | ||
}; |
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 |
---|---|---|
@@ -1,8 +1,5 @@ | ||
export default { | ||
Node: (item, value) => item.Node.toLowerCase().indexOf(value.toLowerCase()) !== -1, | ||
Address: (item, value) => item.Address.toLowerCase().indexOf(value.toLowerCase()) !== -1, | ||
Meta: (item, value) => | ||
Object.entries(item.Meta || {}).some(entry => | ||
entry.some(item => item.toLowerCase().indexOf(value.toLowerCase()) !== -1) | ||
), | ||
Node: item => item.Node, | ||
Address: item => item.Address, | ||
Meta: item => Object.entries(item.Meta || {}).reduce((prev, entry) => prev.concat(entry), []), | ||
}; |
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 |
---|---|---|
@@ -1,16 +1,12 @@ | ||
export default { | ||
Name: (item, value) => item.Name.toLowerCase().indexOf(value.toLowerCase()) !== -1, | ||
Description: (item, value) => item.Description.toLowerCase().indexOf(value.toLowerCase()) !== -1, | ||
Name: (item, value) => item.Name, | ||
Description: (item, value) => item.Description, | ||
Role: (item, value) => { | ||
const acls = item.ACLs || {}; | ||
return (acls.RoleDefaults || []).some( | ||
item => item.Name.toLowerCase().indexOf(value.toLowerCase()) !== -1 | ||
); | ||
return (acls.RoleDefaults || []).map(item => item.Name); | ||
}, | ||
Policy: (item, value) => { | ||
const acls = item.ACLs || {}; | ||
return (acls.PolicyDefaults || []).some( | ||
item => item.Name.toLowerCase().indexOf(value.toLowerCase()) !== -1 | ||
); | ||
return (acls.PolicyDefaults || []).map(item => item.Name); | ||
}, | ||
}; |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export default { | ||
Name: (item, value) => item.Name.toLowerCase().indexOf(value.toLowerCase()) !== -1, | ||
Description: (item, value) => item.Description.toLowerCase().indexOf(value.toLowerCase()) !== -1, | ||
Name: item => item.Name, | ||
Description: item => item.Description, | ||
}; |
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 |
---|---|---|
@@ -1,17 +1,10 @@ | ||
export default { | ||
Name: (item, value) => item.Name.toLowerCase().indexOf(value.toLowerCase()) !== -1, | ||
Description: (item, value) => item.Description.toLowerCase().indexOf(value.toLowerCase()) !== -1, | ||
Name: (item, value) => item.Name, | ||
Description: (item, value) => item.Description, | ||
Policy: (item, value) => { | ||
return ( | ||
(item.Policies || []).some( | ||
item => item.Name.toLowerCase().indexOf(value.toLowerCase()) !== -1 | ||
) || | ||
(item.ServiceIdentities || []).some( | ||
item => item.ServiceName.toLowerCase().indexOf(value.toLowerCase()) !== -1 | ||
) || | ||
(item.NodeIdentities || []).some( | ||
item => item.NodeName.toLowerCase().indexOf(value.toLowerCase()) !== -1 | ||
) | ||
); | ||
return (item.Policies || []) | ||
.map(item => item.Name) | ||
.concat((item.ServiceIdentities || []).map(item => item.ServiceName)) | ||
.concat((item.NodeIdentities || []).map(item => item.NodeName)); | ||
}, | ||
}; |
31 changes: 9 additions & 22 deletions
31
ui/packages/consul-ui/app/search/predicates/service-instance.js
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 |
---|---|---|
@@ -1,24 +1,11 @@ | ||
export default { | ||
Name: (item, value) => { | ||
return item.Name.toLowerCase().indexOf(value.toLowerCase()) !== -1; | ||
}, | ||
Tags: (item, value) => | ||
(item.Service.Tags || []).some(item => item.toLowerCase().indexOf(value.toLowerCase()) !== -1), | ||
ID: (item, value) => (item.Service.ID || '').toLowerCase().indexOf(value.toLowerCase()) !== -1, | ||
Address: (item, value) => | ||
item.Address.toString() | ||
.toLowerCase() | ||
.indexOf(value.toLowerCase()) !== -1, | ||
Port: (item, value) => | ||
item.Service.Port.toString() | ||
.toLowerCase() | ||
.indexOf(value.toLowerCase()) !== -1, | ||
['Service.Meta']: (item, value) => | ||
Object.entries(item.Meta || item.Service.Meta || {}).some(entry => | ||
entry.some(item => item.toLowerCase().indexOf(value.toLowerCase()) !== -1) | ||
), | ||
['Node.Meta']: (item, value) => | ||
Object.entries(item.Node.Meta || {}).some(entry => | ||
entry.some(item => item.toLowerCase().indexOf(value.toLowerCase()) !== -1) | ||
), | ||
Name: item => item.Name, | ||
Tags: item => item.Service.Tags || [], | ||
ID: (item, value) => item.Service.ID || '', | ||
Address: item => item.Address || '', | ||
Port: item => (item.Service.Port || '').toString(), | ||
['Service.Meta']: item => | ||
Object.entries(item.Service.Meta || {}).reduce((prev, entry) => prev.concat(entry), []), | ||
['Node.Meta']: item => | ||
Object.entries(item.Node.Meta || {}).reduce((prev, entry) => prev.concat(entry), []), | ||
}; |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export default { | ||
Name: (item, value) => item.Name.toLowerCase().indexOf(value.toLowerCase()) !== -1, | ||
Tags: (item, value) => (item.Tags || []).some(item => item.toLowerCase().indexOf(value.toLowerCase()) !== -1) | ||
Name: item => item.Name, | ||
Tags: item => item.Tags || [], | ||
}; |
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 |
---|---|---|
@@ -1,20 +1,12 @@ | ||
export default { | ||
Name: (item, value) => item.Name.toLowerCase().indexOf(value.toLowerCase()) !== -1, | ||
Description: (item, value) => item.Description.toLowerCase().indexOf(value.toLowerCase()) !== -1, | ||
AccessorID: (item, value) => item.AccessorID.toLowerCase().indexOf(value.toLowerCase()) !== -1, | ||
Role: (item, value) => | ||
(item.Roles || []).some(item => item.Name.toLowerCase().indexOf(value.toLowerCase()) !== -1), | ||
Name: (item, value) => item.Name, | ||
Description: (item, value) => item.Description, | ||
AccessorID: (item, value) => item.AccessorID, | ||
Role: (item, value) => (item.Roles || []).map(item => item.Name), | ||
Policy: (item, value) => { | ||
return ( | ||
(item.Policies || []).some( | ||
item => item.Name.toLowerCase().indexOf(value.toLowerCase()) !== -1 | ||
) || | ||
(item.ServiceIdentities || []).some( | ||
item => item.ServiceName.toLowerCase().indexOf(value.toLowerCase()) !== -1 | ||
) || | ||
(item.NodeIdentities || []).some( | ||
item => item.NodeName.toLowerCase().indexOf(value.toLowerCase()) !== -1 | ||
) | ||
); | ||
return (item.Policies || []) | ||
.map(item => item.Name) | ||
.concat((item.ServiceIdentities || []).map(item => item.ServiceName)) | ||
.concat((item.NodeIdentities || []).map(item => item.NodeName)); | ||
}, | ||
}; |
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
Oops, something went wrong.