Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: change user honors defaults'
  • Loading branch information
Emyrk committed Jun 11, 2025
commit d3f7583a500fe61a5d5b6c4818f4340a75682f1c
19 changes: 14 additions & 5 deletions src/client/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,12 @@ export const Preview: FC = () => {
) : null}
</AnimatePresence>
</div>
<UserSelect />
<UserSelect changeUser={() => {
// When you change the user, reset the form and the parameters.
// This is a bit of a janky way to fully reset the form, but it works for now.
$resetForm();
$setParameters([]);
}}/>
</div>
}
{$parameters.length === 0 ? (
Expand Down Expand Up @@ -542,9 +547,8 @@ const FormElement: FC<FormElementProps> = ({ parameter }) => {
const value = useMemo(
() =>
$form[parameter.name] ??
(parameter.default_value.value === "??"
? ""
: parameter.default_value.value),
// undefined is ok, the parameter will select the default automatically
undefined,
[$form, parameter],
);

Expand All @@ -563,7 +567,11 @@ const FormElement: FC<FormElementProps> = ({ parameter }) => {
);
};

const UserSelect: FC = () => {
interface UserSelectProps {
changeUser: () => void;
}

const UserSelect: FC<UserSelectProps> = ({changeUser}) => {
const $setWorkspaceOwner = useStore((state) => state.setWorkspaceOwner);

return (
Expand All @@ -572,6 +580,7 @@ const UserSelect: FC = () => {
onValueChange={(value) => {
const users: Record<string, WorkspaceOwner | undefined> = mockUsers;
$setWorkspaceOwner(users[value] ?? mockUsers.admin);
changeUser();
}}
>
<SelectTrigger className="w-fit min-w-40">
Expand Down