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

fix: Intellisense on property editor missing user-variables #7979

Merged
merged 2 commits into from
Jun 2, 2021
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { FieldProps } from '@bfc/extension-client';
import { FieldProps, useShellApi } from '@bfc/extension-client';
import { Intellisense } from '@bfc/intellisense';
import React, { useRef, useState } from 'react';

Expand All @@ -18,6 +18,8 @@ const noop = () => {};
export const IntellisenseTextField: React.FC<FieldProps<string>> = (props) => {
const { id, value = '', onChange, uiOptions, focused: defaultFocused } = props;

const { projectId } = useShellApi();

const completionListOverrideResolver = (value: string) => {
return value === '' ? <ExpressionSwitchWindow kind={'String'} onSwitchToExpression={() => onChange('=')} /> : null;
};
Expand All @@ -30,6 +32,7 @@ export const IntellisenseTextField: React.FC<FieldProps<string>> = (props) => {
completionListOverrideResolver={completionListOverrideResolver}
focused={defaultFocused}
id={`intellisense-${id}`}
projectId={projectId}
scopes={scopes}
url={intellisenseServerUrlRef.current}
value={value}
Expand Down Expand Up @@ -65,6 +68,8 @@ export const IntellisenseTextField: React.FC<FieldProps<string>> = (props) => {
export const IntellisenseExpressionField: React.FC<FieldProps<string>> = (props) => {
const { id, value = '', onChange, focused: defaultFocused } = props;

const { projectId } = useShellApi();

const scopes = ['expressions', 'user-variables'];
const intellisenseServerUrlRef = useRef(getIntellisenseUrl());

Expand All @@ -89,6 +94,7 @@ export const IntellisenseExpressionField: React.FC<FieldProps<string>> = (props)
<Intellisense
focused={defaultFocused}
id={`intellisense-${id}`}
projectId={projectId}
scopes={scopes}
url={intellisenseServerUrlRef.current}
value={value}
Expand Down Expand Up @@ -134,6 +140,8 @@ export const IntellisenseExpressionField: React.FC<FieldProps<string>> = (props)
export const IntellisenseNumberField: React.FC<FieldProps<string>> = (props) => {
const { id, value = '', onChange, uiOptions, focused: defaultFocused } = props;

const { projectId } = useShellApi();

const completionListOverrideResolver = (value: string) => {
return value === '' ? <ExpressionSwitchWindow kind={'Number'} onSwitchToExpression={() => onChange('=')} /> : null;
};
Expand All @@ -146,6 +154,7 @@ export const IntellisenseNumberField: React.FC<FieldProps<string>> = (props) =>
completionListOverrideResolver={completionListOverrideResolver}
focused={defaultFocused}
id={`intellisense-${id}`}
projectId={projectId}
scopes={scopes}
url={intellisenseServerUrlRef.current}
value={value}
Expand All @@ -172,6 +181,8 @@ export const IntellisenseNumberField: React.FC<FieldProps<string>> = (props) =>
export const IntellisenseJSONField: React.FC<FieldProps<string>> = (props) => {
const { id, value = '', onChange, focused: defaultFocused, schema } = props;

const { projectId } = useShellApi();

const completionListOverrideResolver = (value: any) => {
if (typeof value === 'object' && Object.keys(value).length === 0) {
return (
Expand Down Expand Up @@ -204,6 +215,7 @@ export const IntellisenseJSONField: React.FC<FieldProps<string>> = (props) => {
completionListOverrideResolver={completionListOverrideResolver}
focused={defaultFocused}
id={`intellisense-${id}`}
projectId={projectId}
scopes={scopes}
url={intellisenseServerUrlRef.current}
value={value || defaultValue}
Expand Down