Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Sep 21, 2024
1 parent cc4cd08 commit b5c24e2
Showing 1 changed file with 53 additions and 8 deletions.
61 changes: 53 additions & 8 deletions packages/eez-studio-ui/properties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import { computed, makeObservable } from "mobx";
import { observer } from "mobx-react";
import classNames from "classnames";
import { dialog } from "@electron/remote";

import { formatBytes } from "eez-studio-shared/formatBytes";
import { guid } from "eez-studio-shared/guid";
Expand Down Expand Up @@ -55,20 +56,24 @@ export const PropertyEnclosure = observer(
);

export const StaticProperty = observer(
class StaticProperty extends React.Component<
{
name: string;
value: string;
},
{}
> {
class StaticProperty extends React.Component<{
name: string;
value: string;
className?: string;
}> {
render() {
const value =
(this.props.value && this.props.value.toString()) || "";
return (
<PropertyEnclosure>
<td className="PropertyName">{this.props.name}</td>
<td className="StaticPropertyValue" title={value}>
<td
className={classNames(
"StaticPropertyValue",
this.props.className
)}
title={value}
>
{value}
</td>
</PropertyEnclosure>
Expand Down Expand Up @@ -932,3 +937,43 @@ export const ButtonProperty = observer(
}
}
);

export class AbsoluteFileInputProperty extends React.Component<
{
name?: string;
value: string;
onChange: (value: string) => void;
},
{}
> {
async onSelect() {
const result = await dialog.showOpenDialog({
properties: ["openFile"],
filters: [{ name: "All Files", extensions: ["*"] }]
});

if (result.filePaths && result.filePaths[0]) {
this.props.onChange(result.filePaths[0]);
}
}

render() {
return (
<InputProperty
name={this.props.name}
value={this.props.value}
onChange={this.props.onChange}
type="text"
inputGroupButton={
<button
className="btn btn-secondary"
type="button"
onClick={this.onSelect.bind(this)}
>
&hellip;
</button>
}
/>
);
}
}

0 comments on commit b5c24e2

Please sign in to comment.