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

services: filter by labels ux enhancement #160

Merged
merged 79 commits into from
Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
d29e4a9
modify search styling
Forfold Sep 30, 2019
55868a0
remove unused style
Forfold Sep 30, 2019
8b7a478
allow changing icon props in filter container
Forfold Sep 30, 2019
a7b211d
move search above list and add option to provide additional filters t…
Forfold Sep 30, 2019
5ba78ae
rename filter icon
Forfold Sep 30, 2019
ff290ec
update react-select
Forfold Oct 1, 2019
ebb39c6
adjust width on filter container such that content is always within t…
Forfold Oct 1, 2019
b4c23bb
adjustments to make menu items word wrap instead of get cut off
Forfold Oct 1, 2019
1039ae7
get service router working with additional key select for search
Forfold Oct 1, 2019
8a5b7de
match icon color with search bar on desktop
Forfold Oct 1, 2019
5d8a13b
fmt
Forfold Oct 1, 2019
2b684e9
add reset option to filter
Forfold Oct 1, 2019
a947abd
add unique values query for label value select
Forfold Oct 1, 2019
0483a75
ok we actually don't need this stuff
Forfold Oct 1, 2019
b9e60be
get search working properly
Forfold Oct 1, 2019
d58bbcc
add label value select
Forfold Oct 1, 2019
51254f5
add label value select to filter
Forfold Oct 1, 2019
cdc0540
use context to render pagination controls outside of query render chain
Forfold Oct 2, 2019
fb3bc6d
convert to Component to prevent rerendering
Forfold Oct 2, 2019
094fb8e
jk
Forfold Oct 2, 2019
d262ffa
just render the search and filter in querylist
Forfold Oct 2, 2019
4f7d78f
remove spinner so search and list render together
Forfold Oct 2, 2019
b7b6866
cleanup
Forfold Oct 2, 2019
8cdc8c4
only show label values pertinent to the key selected
Forfold Oct 2, 2019
bd988c2
Merge branch 'master' into service-search-labels
Forfold Oct 2, 2019
28e0d79
remove duplicate search on users list page
Forfold Oct 2, 2019
f65df54
adjust filter button's aria label
Forfold Oct 2, 2019
dd7bd17
add attributes for testing
Forfold Oct 2, 2019
eb3f523
add more test attributes
Forfold Oct 2, 2019
c96b713
add tests for filtering with labels
Forfold Oct 2, 2019
d8c9f1d
make check gofmt
Forfold Oct 2, 2019
44caf17
remove `only` command on label tests
Forfold Oct 3, 2019
f3f995a
fix search tests
Forfold Oct 3, 2019
d800fad
go back to a fixed with, but a bit wider than before to fit select dr…
Forfold Oct 3, 2019
e49309c
word break select value if width would be too long
Forfold Oct 3, 2019
1160dd4
add filter title
Forfold Oct 3, 2019
6d01c3b
Move stuff around.
Forfold Oct 3, 2019
a8c2b20
update aria label
Forfold Oct 7, 2019
5ca0b01
remove pass-through prop
mastercactapus Oct 10, 2019
fc54904
anchor search filter to input field
mastercactapus Oct 10, 2019
306d343
set min-width on widescreen
mastercactapus Oct 10, 2019
509616e
use title instead of aria-label
mastercactapus Oct 10, 2019
238800a
animate search bar extend
mastercactapus Oct 10, 2019
b7fc327
set min width for entire bar (fixes other page shift)
mastercactapus Oct 10, 2019
668275d
Merge branch 'master' into service-search-labels
Forfold Oct 21, 2019
3a8cbc3
remove uniqueValues (not needed)
Forfold Oct 22, 2019
bc2875d
move filter container to its own component
Forfold Oct 22, 2019
7a84792
fetch by unique key value pairs if uniqueKeys is not specified
Forfold Oct 22, 2019
229b349
fix render issue with ref
Forfold Oct 22, 2019
85c3668
fmt
Forfold Oct 22, 2019
b437df3
fix cursor
Forfold Oct 24, 2019
6175e9c
fix order by sorting
Forfold Oct 24, 2019
e900841
tweak grabbing label value from search param
Forfold Oct 24, 2019
b0dc219
Merge branch 'master' into service-search-labels
arurao Oct 24, 2019
0984310
pagination & ordering
arurao Oct 24, 2019
8b2727f
merging latest
arurao Oct 24, 2019
e4d45f7
Merge branch 'master' into service-search-labels
arurao Oct 24, 2019
6061546
Merge branch 'service-search-labels' of https://github.com/target/goa…
arurao Oct 24, 2019
fe25546
fix query
arurao Oct 24, 2019
81ea8eb
Merge branch 'master' into service-search-labels
Forfold Oct 29, 2019
a60b387
Merge branch 'master' into service-search-labels
arurao Oct 30, 2019
23c24af
fix search on alerts list
Forfold Oct 30, 2019
398e594
fix prop types
Forfold Oct 31, 2019
e9cac11
add new specific search methods
mastercactapus Oct 31, 2019
be9f904
yeeted old search code
mastercactapus Oct 31, 2019
ede361a
map existing label query to key search
mastercactapus Oct 31, 2019
33c14dc
add new gql queries for labels
mastercactapus Oct 31, 2019
046423e
Merge branch 'master' into service-search-labels
arurao Oct 31, 2019
7da6f8a
update searchselect stuff
mastercactapus Oct 31, 2019
449b936
update container prop
mastercactapus Oct 31, 2019
9d2e1fd
Merge branch 'service-search-labels' of github.com:target/goalert int…
mastercactapus Oct 31, 2019
1df07cf
simplify label select form api
mastercactapus Nov 4, 2019
b029657
use value for initial label key query
Forfold Nov 4, 2019
08abeec
pr comments
Forfold Nov 4, 2019
1f6a799
update key validation while searching
Forfold Nov 5, 2019
224c712
remove search var
Forfold Nov 5, 2019
d1074bc
enable default queries on search-selects
mastercactapus Nov 5, 2019
4c5a2a7
just call `makeQuerySelect` for `LabelKeySelect`
mastercactapus Nov 5, 2019
ddb4fa6
add prop-derived variables in `makeQuerySelect`
mastercactapus Nov 5, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
436 changes: 436 additions & 0 deletions graphql2/generated.go

Large diffs are not rendered by default.

114 changes: 91 additions & 23 deletions graphql2/graphqlapp/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,132 @@ package graphqlapp
import (
context "context"
"database/sql"

"github.com/target/goalert/config"
"github.com/target/goalert/graphql2"
"github.com/target/goalert/label"
"github.com/target/goalert/search"
"github.com/target/goalert/validation"
)

func (q *Query) Labels(ctx context.Context, input *graphql2.LabelSearchOptions) (conn *graphql2.LabelConnection, err error) {
func (q *Query) LabelKeys(ctx context.Context, input *graphql2.LabelKeySearchOptions) (conn *graphql2.StringConnection, err error) {
if input == nil {
input = &graphql2.LabelSearchOptions{}
input = &graphql2.LabelKeySearchOptions{}
}

var searchOpts label.SearchOptions
var opts label.KeySearchOptions
if input.Search != nil {
searchOpts.Search = *input.Search
opts.Search = *input.Search
}
opts.Omit = input.Omit
if input.After != nil && *input.After != "" {
err = search.ParseCursor(*input.After, &opts)
if err != nil {
return conn, err
}
}
if input.First != nil {
opts.Limit = *input.First
}
searchOpts.Omit = input.Omit
if input.UniqueKeys != nil {
searchOpts.UniqueKeys = *input.UniqueKeys
if opts.Limit == 0 {
opts.Limit = 15
}

opts.Limit++
labelKeys, err := q.LabelStore.SearchKeys(ctx, &opts)
if err != nil {
return nil, err
}
conn = new(graphql2.StringConnection)
if len(labelKeys) == opts.Limit {
labelKeys = labelKeys[:len(labelKeys)-1]
conn.PageInfo.HasNextPage = true
}
if len(labelKeys) > 0 {
last := labelKeys[len(labelKeys)-1]
opts.After = last

cur, err := search.Cursor(opts)
if err != nil {
return nil, err
}
conn.PageInfo.EndCursor = &cur
}
conn.Nodes = labelKeys
return conn, err
}

func (q *Query) LabelValues(ctx context.Context, input *graphql2.LabelValueSearchOptions) (conn *graphql2.StringConnection, err error) {
if input == nil {
input = &graphql2.LabelValueSearchOptions{}
}

var opts label.ValueSearchOptions
if input.Search != nil {
opts.Search = *input.Search
}
opts.Omit = input.Omit
opts.Key = input.Key
if input.After != nil && *input.After != "" {
err = search.ParseCursor(*input.After, &searchOpts)
err = search.ParseCursor(*input.After, &opts)
if err != nil {
return conn, err
}
}
if input.First != nil {
searchOpts.Limit = *input.First
opts.Limit = *input.First
}
if searchOpts.Limit == 0 {
searchOpts.Limit = 15
if opts.Limit == 0 {
opts.Limit = 15
}

searchOpts.Limit++
labels, err := q.LabelStore.Search(ctx, &searchOpts)
opts.Limit++
values, err := q.LabelStore.SearchValues(ctx, &opts)
if err != nil {
return nil, err
}
conn = new(graphql2.LabelConnection)
if len(labels) == searchOpts.Limit {
labels = labels[:len(labels)-1]
conn = new(graphql2.StringConnection)
if len(values) == opts.Limit {
values = values[:len(values)-1]
conn.PageInfo.HasNextPage = true
}
if len(labels) > 0 {
last := labels[len(labels)-1]
searchOpts.After.Key = last.Key
searchOpts.After.TargetType = last.Target.TargetType()
searchOpts.After.TargetID = last.Target.TargetID()
if len(values) > 0 {
last := values[len(values)-1]
opts.After = last

cur, err := search.Cursor(searchOpts)
cur, err := search.Cursor(opts)
if err != nil {
return nil, err
}
conn.PageInfo.EndCursor = &cur
}
conn.Nodes = labels
conn.Nodes = values
return conn, err
}

func (q *Query) Labels(ctx context.Context, input *graphql2.LabelSearchOptions) (conn *graphql2.LabelConnection, err error) {
if input == nil {
input = &graphql2.LabelSearchOptions{}
}
keyConn, err := q.LabelKeys(ctx, &graphql2.LabelKeySearchOptions{
Search: input.Search,
After: input.After,
Omit: input.Omit,
First: input.First,
})
if err != nil {
return nil, err
}

conn = new(graphql2.LabelConnection)
conn.PageInfo = keyConn.PageInfo
conn.Nodes = make([]label.Label, len(keyConn.Nodes))
for i, k := range keyConn.Nodes {
conn.Nodes[i].Key = k
}

return conn, nil
}
func (m *Mutation) SetLabel(ctx context.Context, input graphql2.SetLabelInput) (bool, error) {
err := withContextTx(ctx, m.DB, func(ctx context.Context, tx *sql.Tx) error {
cfg := config.FromContext(ctx)
Expand Down
20 changes: 20 additions & 0 deletions graphql2/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions graphql2/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ type Query {
# Allows searching for assigned labels.
labels(input: LabelSearchOptions): LabelConnection!

# Allows searching for label keys.
labelKeys(input: LabelKeySearchOptions): StringConnection!

# Allows searching for label values.
labelValues(input: LabelValueSearchOptions): StringConnection!

# Allows searching for user overrides.
userOverrides(input: UserOverrideSearchOptions): UserOverrideConnection!

Expand Down Expand Up @@ -152,11 +158,31 @@ input LabelSearchOptions {
omit: [ID!]
}

input LabelKeySearchOptions {
first: Int = 15
after: String = ""
search: String = ""
omit: [String!]
}

input LabelValueSearchOptions {
key: String!
first: Int = 15
after: String = ""
search: String = ""
omit: [String!]
}

type LabelConnection {
nodes: [Label!]!
pageInfo: PageInfo!
}

type StringConnection {
nodes: [String!]!
pageInfo: PageInfo!
}

type Mutation {
addAuthSubject(input: AuthSubjectInput!): Boolean!
deleteAuthSubject(input: AuthSubjectInput!): Boolean!
Expand Down
Loading