renderLogScopeSwitch()

in src/VariableQueryEditor.tsx [109:164]


    renderLogScopeSwitch(queryType: string) {
        const variableOptionGroup = {
            label: 'Template Variables',
            expanded: false,
            options: getTemplateSrv()
                .getVariables()
                .map((v: any) => ({
                    value: `$${v.name}`,
                    label: `$${v.name}`,
                })),
        };

        switch (queryType) {
            case LogFindQueryScopes.Buckets:
                return (
                    <>
                        <VariableQueryField
                            allowCustomValue={true}
                            value={this.state.projectId}
                            options={[variableOptionGroup, ...this.state.projects.map((v: any) => ({
                                value: `${v}`,
                                label: `${v}`,
                            }))]}
                            onChange={(value) => this.onProjectChange(value)}
                            label="Project"
                        />
                    </>
                );
            case LogFindQueryScopes.Views:
                return (
                    <>
                        <VariableQueryField
                            allowCustomValue={true}
                            value={this.state.projectId}
                            options={[variableOptionGroup, ...this.state.projects.map((v: any) => ({
                                value: `${v}`,
                                label: `${v}`,
                            }))]}
                            onChange={(value) => this.onProjectChange(value)}
                            label="Project"
                        />
                        <VariableQueryField
                            allowCustomValue={true}
                            value={this.state.bucketId}
                            options={[variableOptionGroup, ...this.state.buckets.map((v: any) => ({
                                value: `${v}`,
                                label: `${v}`,
                            }))]}
                            onChange={(value) => this.onBucketChange(this.state.projectId, value)}
                            label="Bucket"
                        />
                    </>);
            default:
                return '';
        }
    }