Skip to content

Commit

Permalink
Merge pull request #117 from scalyr/DSET-3658-switch-to-teamemails
Browse files Browse the repository at this point in the history
DSET-3658 Change AccountEmails to TeamEmails for consistency
  • Loading branch information
dlobue authored May 17, 2023
2 parents 98c7624 + 8c2f868 commit 618c7b9
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ dashboard using Scalyr data.

![PowerQuery](https://raw.githubusercontent.com/scalyr/scalyr-grafana-datasource-plugin/master/src/img/PowerQuery.png)

7. **Cross Team Search** - The AccountEmails field is used to specify which
7. **Cross Team Search** - The Team Emails field is used to specify which
teams the query should be run against. Works the same as
[Cross Team Search](https://app.scalyr.com/help/graphs#crossTeam) in the
DataSet app. More information on teams can be found
Expand Down
20 changes: 10 additions & 10 deletions pkg/plugin/lrq_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ type DistributionOptions struct {
}

type LRQRequest struct {
QueryType string `json:"queryType"`
StartTime int64 `json:"startTime"`
EndTime int64 `json:"endTime"`
AccountEmails []string `json:"accountEmails"`
Log *LogOptions `json:"log"`
Facet *FacetOptions `json:"facetValues"`
TopFacet *TopFacetOptions `json:"topFacets"`
Pq *PQOptions `json:"pq"`
Plot *PlotOptions `json:"plot"`
Distribution *DistributionOptions `json:"distribution"`
QueryType string `json:"queryType"`
StartTime int64 `json:"startTime"`
EndTime int64 `json:"endTime"`
TeamEmails []string `json:"teamEmails"`
Log *LogOptions `json:"log"`
Facet *FacetOptions `json:"facetValues"`
TopFacet *TopFacetOptions `json:"topFacets"`
Pq *PQOptions `json:"pq"`
Plot *PlotOptions `json:"plot"`
Distribution *DistributionOptions `json:"distribution"`
}

type ResolvedTimeRange struct {
Expand Down
6 changes: 3 additions & 3 deletions pkg/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type queryModel struct {
Format string `json:"format"`
BreakDownFacetValue *string `json:"breakDownFacetValue"`
Label *string `json:"label"`
AccountEmails []string `json:"accountEmails"`
TeamEmails []string `json:"teamEmails"`
}

func (d *DataSetDatasource) query(ctx context.Context, query backend.DataQuery) backend.DataResponse {
Expand Down Expand Up @@ -118,8 +118,8 @@ func (d *DataSetDatasource) query(ctx context.Context, query backend.DataQuery)
}
}

if qm.AccountEmails != nil && len(qm.AccountEmails) > 0 {
request.AccountEmails = qm.AccountEmails
if qm.TeamEmails != nil && len(qm.TeamEmails) > 0 {
request.TeamEmails = qm.TeamEmails
}

var result *LRQResult
Expand Down
16 changes: 8 additions & 8 deletions src/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export function QueryEditor(props: Props): ReactElement {
const { datasource } = props;
const { loading, topFacets } = useFacetsQuery(datasource);
const query = defaults(props.query, defaultQuery);
const [ accountEmails, setAccountEmails ] = useState<Array<SelectableValue<string>>>(
(query.accountEmails || []).map(v => ({label: v, value: v})));
const [ teamEmails, setTeamEmails ] = useState<Array<SelectableValue<string>>>(
(query.teamEmails || []).map(v => ({label: v, value: v})));

const onExpressionChange = (event: ChangeEvent<HTMLInputElement>) => {
const { onChange, query } = props;
Expand All @@ -39,10 +39,10 @@ export function QueryEditor(props: Props): ReactElement {
onChange({ ...query, label: event.target.value });
};

const onAccountEmailsChange = (values: Array<SelectableValue<string>>, actionMeta: ActionMeta) => {
const onTeamEmailsChange = (values: Array<SelectableValue<string>>, actionMeta: ActionMeta) => {
const { onChange, query, onRunQuery } = props;
setAccountEmails(values);
onChange({ ...query, accountEmails: values.length > 0 ? values.map((v) => {return v.value;}) : null });
setTeamEmails(values);
onChange({ ...query, teamEmails: values.length > 0 ? values.map((v) => {return v.value;}) : null });
onRunQuery();
};

Expand Down Expand Up @@ -95,12 +95,12 @@ export function QueryEditor(props: Props): ReactElement {
</InlineField>
</InlineFieldRow>
<InlineFieldRow>
<InlineField label="AccountEmails" grow>
<InlineField label="Team Emails" grow>
<MultiSelect
value={accountEmails}
value={teamEmails}
allowCustomValue
isClearable
onChange={onAccountEmailsChange}
onChange={onTeamEmailsChange}
/>
</InlineField>
</InlineFieldRow>
Expand Down
Binary file modified src/img/CrossTeamQuery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface MyQuery extends DataQuery {
queryType: any;
breakDownFacetValue: string | undefined | null;
label: string | undefined | null;
accountEmails: Array<string | undefined> | undefined | null;
teamEmails: Array<string | undefined> | undefined | null;
}

export const defaultQuery: Partial<MyQuery> = {
Expand Down

0 comments on commit 618c7b9

Please sign in to comment.