Skip to content
Draft
Show file tree
Hide file tree
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,4 +1,4 @@
import type { ChangeEvent, SetStateAction } from "react";
import type { SetStateAction } from "react";
import { useCallback } from "react";
import {
VscodeOption,
Expand All @@ -25,8 +25,8 @@ export const CodeFlowsDropdown = ({
setSelectedCodeFlow,
}: CodeFlowsDropdownProps) => {
const handleChange = useCallback(
(e: ChangeEvent<HTMLSelectElement>) => {
const selectedOption = e.target;
(e: Event) => {
const selectedOption = e.target as HTMLSelectElement;
const selectedIndex = parseInt(selectedOption.value);
setSelectedCodeFlow(codeFlows[selectedIndex]);
},
Expand Down
4 changes: 2 additions & 2 deletions extensions/ql-vscode/src/view/common/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const DataGridRow = forwardRef(
"data-testid": testId,
onClick,
}: DataGridRowProps,
ref?: React.Ref<HTMLElement | undefined>,
ref?: React.Ref<HTMLDivElement>,
) => (
<StyledDataGridRow
$focused={focused}
Expand Down Expand Up @@ -135,7 +135,7 @@ export const DataGridCell = forwardRef(
className,
children,
}: DataGridCellProps,
ref?: React.Ref<HTMLElement | undefined>,
ref?: React.Ref<HTMLDivElement>,
) => {
return (
<StyledDataGridCell
Expand Down
2 changes: 1 addition & 1 deletion extensions/ql-vscode/src/view/common/TextButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { styled } from "styled-components";

type Size = "x-small" | "small" | "medium" | "large" | "x-large";

const StyledButton = styled.button<{ $size: Size }>`
const StyledButton = styled.button<{ $size?: Size }>`
background: none;
color: var(--vscode-textLink-foreground);
border: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Props = {

export const ModelAlertsSort = ({ value, onChange, className }: Props) => {
const handleInput = useCallback(
(e: InputEvent) => {
(e: Event) => {
const target = e.target as HTMLSelectElement;

onChange(target.value as SortKey);
Expand Down
69 changes: 34 additions & 35 deletions extensions/ql-vscode/src/view/model-editor/MethodRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export type MethodRowProps = {
export const MethodRow = (props: MethodRowProps) => {
const { method, methodCanBeModeled, revealedMethodSignature } = props;

const ref = useRef<HTMLElement | undefined>(undefined);
const ref = useRef<HTMLDivElement>(null);

useEffect(() => {
if (method.signature === revealedMethodSignature) {
Expand All @@ -103,7 +103,7 @@ export const MethodRow = (props: MethodRowProps) => {
}
};

const ModelableMethodRow = forwardRef<HTMLElement | undefined, MethodRowProps>(
const ModelableMethodRow = forwardRef<HTMLDivElement, MethodRowProps>(
(props: MethodRowProps, ref) => {
const {
method,
Expand Down Expand Up @@ -359,39 +359,38 @@ const ModelableMethodRow = forwardRef<HTMLElement | undefined, MethodRowProps>(
);
ModelableMethodRow.displayName = "ModelableMethodRow";

const UnmodelableMethodRow = forwardRef<
HTMLElement | undefined,
MethodRowProps
>((props: MethodRowProps, ref) => {
const { method, viewState, revealedMethodSignature } = props;

const jumpToMethod = useCallback(
() => sendJumpToMethodMessage(method),
[method],
);

return (
<DataGridRow
data-testid="unmodelable-method-row"
focused={revealedMethodSignature === method.signature}
>
<DataGridCell ref={ref}>
<ApiOrMethodRow>
<ModelingStatusIndicator status="saved" />
<MethodClassifications method={method} />
<MethodName {...props.method} />
{viewState.mode === Mode.Application && (
<UsagesButton onClick={jumpToMethod}>
{method.usages.length}
</UsagesButton>
)}
<ViewLink onClick={jumpToMethod}>View</ViewLink>
</ApiOrMethodRow>
</DataGridCell>
<DataGridCell gridColumn="span 5">Method already modeled</DataGridCell>
</DataGridRow>
);
});
const UnmodelableMethodRow = forwardRef<HTMLDivElement, MethodRowProps>(
(props: MethodRowProps, ref) => {
const { method, viewState, revealedMethodSignature } = props;

const jumpToMethod = useCallback(
() => sendJumpToMethodMessage(method),
[method],
);

return (
<DataGridRow
data-testid="unmodelable-method-row"
focused={revealedMethodSignature === method.signature}
>
<DataGridCell ref={ref}>
<ApiOrMethodRow>
<ModelingStatusIndicator status="saved" />
<MethodClassifications method={method} />
<MethodName {...props.method} />
{viewState.mode === Mode.Application && (
<UsagesButton onClick={jumpToMethod}>
{method.usages.length}
</UsagesButton>
)}
<ViewLink onClick={jumpToMethod}>View</ViewLink>
</ApiOrMethodRow>
</DataGridCell>
<DataGridCell gridColumn="span 5">Method already modeled</DataGridCell>
</DataGridRow>
);
},
);
UnmodelableMethodRow.displayName = "UnmodelableMethodRow";

function sendJumpToMethodMessage(method: Method) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { ChangeEvent } from "react";
import { useCallback, useEffect, useState } from "react";
import type {
ModeledMethod,
Expand Down Expand Up @@ -33,8 +32,8 @@ export const ModelTypeTextbox = ({
setValue(modeledMethod[typeInfo]);
}, [modeledMethod, typeInfo]);

const handleChange = useCallback((e: ChangeEvent<HTMLSelectElement>) => {
const target = e.target as HTMLSelectElement;
const handleChange = useCallback((e: Event) => {
const target = e.target as HTMLInputElement;

setValue(target.value);
}, []);
Expand Down
8 changes: 4 additions & 4 deletions extensions/ql-vscode/src/view/variant-analysis/RepoRow.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { ChangeEvent } from "react";
import { useCallback, useEffect, useState } from "react";
import { styled } from "styled-components";
import { VscodeCheckbox } from "@vscode-elements/react-elements";
Expand Down Expand Up @@ -229,17 +228,18 @@ export const RepoRow = ({
e.stopPropagation();
}, []);
const onChangeCheckbox = useCallback(
(e: ChangeEvent<HTMLInputElement>) => {
(e: Event) => {
const target = e.target as HTMLInputElement;
// This is called on first render, but we don't really care about this value
if (e.target.checked === undefined) {
if (target.checked === undefined) {
return;
}

if (!repository.id) {
return;
}

onSelectedChange?.(repository.id, e.target.checked);
onSelectedChange?.(repository.id, target.checked);
},
[onSelectedChange, repository],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Props = {

export const RepositoriesFilter = ({ value, onChange, className }: Props) => {
const handleInput = useCallback(
(e: InputEvent) => {
(e: Event) => {
const target = e.target as HTMLSelectElement;

onChange(target.value as FilterKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const RepositoriesResultFormat = ({
className,
}: Props) => {
const handleInput = useCallback(
(e: InputEvent) => {
(e: Event) => {
const target = e.target as HTMLSelectElement;

onChange(target.value as ResultFormat);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Props = {

export const RepositoriesSort = ({ value, onChange, className }: Props) => {
const handleInput = useCallback(
(e: InputEvent) => {
(e: Event) => {
const target = e.target as HTMLSelectElement;

onChange(target.value as SortKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export const VariantAnalysisActions = ({
})}
</Button>
<Button
appearance="primary"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Why was this line deleted? Is there another attribute that would be equivalent, such as <Button primary .../>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The appearance attribute is not supported by VscodeButton in @vscode-elements v0.9.0. The button has primary appearance by default. To make it secondary, you add the secondary boolean attribute. Since this button doesn't have secondary, it already has the primary appearance. No changes needed - the fix in commit 42b1cb7 is correct.

onClick={onExportResultsClick}
disabled={exportResultsDisabled}
>
Expand Down