Bugs - Global Variables (#1839)

Fixed height and resizability of Global Variables table, made value of
credentials variable as password field
This commit is contained in:
Cristhian Zanforlin Lousa 2024-05-06 15:37:07 -03:00 • committed by GitHub
commit d938fb3a3c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 118 additions and 106 deletions

View file

@ -106,6 +106,16 @@ export default function AddNewVariableButton({ children }): JSX.Element {
id={"type-global-variables"} id={"type-global-variables"}
></InputComponent> ></InputComponent>
<Label>Value</Label> <Label>Value</Label>
{type === "Credential" ? (
<InputComponent
password
value={value}
onChange={(e) => {
setValue(e);
}}
placeholder="Insert a value for the variable..."
/>
) : (
<Textarea <Textarea
value={value} value={value}
onChange={(e) => { onChange={(e) => {
@ -114,6 +124,8 @@ export default function AddNewVariableButton({ children }): JSX.Element {
placeholder="Insert a value for the variable..." placeholder="Insert a value for the variable..."
className="w-full resize-none custom-scroll" className="w-full resize-none custom-scroll"
/> />
)}
<Label>Apply To Fields (optional)</Label> <Label>Apply To Fields (optional)</Label>
<InputComponent <InputComponent
setSelectedOptions={(value) => setFields(value)} setSelectedOptions={(value) => setFields(value)}

View file

@ -76,7 +76,7 @@ export default function InputComponent({
editNode ? " input-edit-node " : "", editNode ? " input-edit-node " : "",
password && editNode ? "pr-8" : "", password && editNode ? "pr-8" : "",
password && !editNode ? "pr-10" : "", password && !editNode ? "pr-10" : "",
className! className!,
)} )}
placeholder={password && editNode ? "Key" : placeholder} placeholder={password && editNode ? "Key" : placeholder}
onChange={(e) => { onChange={(e) => {
@ -120,7 +120,7 @@ export default function InputComponent({
required={required} required={required}
className={classNames( className={classNames(
password && password &&
selectedOption === "" && (!setSelectedOption || selectedOption === "") &&
!pwdVisible && !pwdVisible &&
value !== "" value !== ""
? " text-clip password " ? " text-clip password "
@ -134,7 +134,7 @@ export default function InputComponent({
? "pr-8" ? "pr-8"
: "", : "",
className! className!,
)} )}
placeholder={password && editNode ? "Key" : placeholder} placeholder={password && editNode ? "Key" : placeholder}
onChange={(e) => { onChange={(e) => {
@ -194,15 +194,15 @@ export default function InputComponent({
setSelectedOption( setSelectedOption(
currentValue === selectedOption currentValue === selectedOption
? "" ? ""
: currentValue : currentValue,
); );
setSelectedOptions && setSelectedOptions &&
setSelectedOptions( setSelectedOptions(
selectedOptions?.includes(currentValue) selectedOptions?.includes(currentValue)
? selectedOptions.filter( ? selectedOptions.filter(
(item) => item !== currentValue (item) => item !== currentValue,
) )
: [...selectedOptions, currentValue] : [...selectedOptions, currentValue],
); );
!setSelectedOptions && setShowOptions(false); !setSelectedOptions && setShowOptions(false);
}} }}
@ -215,7 +215,7 @@ export default function InputComponent({
selectedOption === option || selectedOption === option ||
selectedOptions?.includes(option) selectedOptions?.includes(option)
? "opacity-100" ? "opacity-100"
: "opacity-0" : "opacity-0",
)} )}
> >
<div className="absolute opacity-100 transition-all group-hover:opacity-0"> <div className="absolute opacity-100 transition-all group-hover:opacity-0">
@ -254,7 +254,7 @@ export default function InputComponent({
((selectedOptions?.length !== 0 || !onChange) && ((selectedOptions?.length !== 0 || !onChange) &&
setSelectedOptions) setSelectedOptions)
? "" ? ""
: "hidden" : "hidden",
)} )}
onClick={ onClick={
((selectedOption !== "" || !onChange) && setSelectedOption) || ((selectedOption !== "" || !onChange) && setSelectedOption) ||
@ -275,7 +275,7 @@ export default function InputComponent({
<span <span
className={cn( className={cn(
password && selectedOption === "" ? "right-8" : "right-0", password && selectedOption === "" ? "right-8" : "right-0",
"absolute inset-y-0 flex items-center pr-2.5" "absolute inset-y-0 flex items-center pr-2.5",
)} )}
> >
<button <button
@ -286,7 +286,7 @@ export default function InputComponent({
selectedOption !== "" selectedOption !== ""
? "text-medium-indigo" ? "text-medium-indigo"
: "text-muted-foreground", : "text-muted-foreground",
"hover:text-accent-foreground" "hover:text-accent-foreground",
)} )}
> >
<ForwardedIconComponent <ForwardedIconComponent
@ -298,7 +298,7 @@ export default function InputComponent({
</span> </span>
)} )}
{password && selectedOption === "" && ( {password && (!setSelectedOption || selectedOption === "") && (
<button <button
type="button" type="button"
tabIndex={-1} tabIndex={-1}
@ -306,16 +306,14 @@ export default function InputComponent({
"mb-px", "mb-px",
editNode editNode
? "input-component-true-button" ? "input-component-true-button"
: "input-component-false-button" : "input-component-false-button",
)} )}
onClick={(event) => { onClick={(event) => {
event.preventDefault(); event.preventDefault();
setPwdVisible(!pwdVisible); setPwdVisible(!pwdVisible);
}} }}
> >
{password && {pwdVisible ? (
selectedOption === "" &&
(pwdVisible ? (
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
fill="none" fill="none"
@ -325,7 +323,7 @@ export default function InputComponent({
className={classNames( className={classNames(
editNode editNode
? "input-component-true-svg" ? "input-component-true-svg"
: "input-component-false-svg" : "input-component-false-svg",
)} )}
> >
<path <path
@ -344,7 +342,7 @@ export default function InputComponent({
className={classNames( className={classNames(
editNode editNode
? "input-component-true-svg" ? "input-component-true-svg"
: "input-component-false-svg" : "input-component-false-svg",
)} )}
> >
<path <path
@ -358,7 +356,7 @@ export default function InputComponent({
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"
/> />
</svg> </svg>
))} )}
</button> </button>
)} )}
</div> </div>

View file

@ -5,32 +5,21 @@ import { ComponentPropsWithoutRef, ElementRef, forwardRef } from "react";
import { useDarkStore } from "../../stores/darkStore"; import { useDarkStore } from "../../stores/darkStore";
import "../../style/ag-theme-shadcn.css"; // Custom CSS applied to the grid import "../../style/ag-theme-shadcn.css"; // Custom CSS applied to the grid
import { cn } from "../../utils/utils"; import { cn } from "../../utils/utils";
import { Card, CardContent } from "../ui/card";
const TableComponent = forwardRef< const TableComponent = forwardRef<
ElementRef<typeof AgGridReact>, ElementRef<typeof AgGridReact>,
ComponentPropsWithoutRef<typeof AgGridReact> ComponentPropsWithoutRef<typeof AgGridReact>
>(({ pagination = true, ...props }, ref) => { >(({ ...props }, ref) => {
const dark = useDarkStore((state) => state.dark); const dark = useDarkStore((state) => state.dark);
return ( return (
<div className="flex h-full flex-col">
<div <div
className={cn( className={cn(
dark ? "ag-theme-quartz-dark" : "ag-theme-quartz", dark ? "ag-theme-quartz-dark" : "ag-theme-quartz",
"ag-theme-shadcn flex h-full flex-col", "ag-theme-shadcn flex h-full flex-col",
)} // applying the grid theme )} // applying the grid theme
> >
<Card x-chunk="dashboard-04-chunk-2" className="pt-4"> <AgGridReact ref={ref} {...props} />
<CardContent>
<AgGridReact
overlayNoRowsTemplate="No data available"
ref={ref}
{...props}
/>
</CardContent>
</Card>
</div>
</div> </div>
); );
}); });

View file

@ -8,6 +8,7 @@ import Dropdown from "../../../../components/dropdownComponent";
import ForwardedIconComponent from "../../../../components/genericIconComponent"; import ForwardedIconComponent from "../../../../components/genericIconComponent";
import TableComponent from "../../../../components/tableComponent"; import TableComponent from "../../../../components/tableComponent";
import { Badge } from "../../../../components/ui/badge"; import { Badge } from "../../../../components/ui/badge";
import { Card, CardContent } from "../../../../components/ui/card";
import { deleteGlobalVariable } from "../../../../controllers/API"; import { deleteGlobalVariable } from "../../../../controllers/API";
import useAlertStore from "../../../../stores/alertStore"; import useAlertStore from "../../../../stores/alertStore";
import { useGlobalVariablesStore } from "../../../../stores/globalVariables"; import { useGlobalVariablesStore } from "../../../../stores/globalVariables";
@ -81,7 +82,7 @@ export default function GlobalVariablesPage() {
showDisabledCheckboxes: true, showDisabledCheckboxes: true,
headerName: "Variable Name", headerName: "Variable Name",
field: "name", field: "name",
flex: 1, flex: 2,
}, //This column will be twice as wide as the others }, //This column will be twice as wide as the others
{ {
field: "type", field: "type",
@ -104,6 +105,7 @@ export default function GlobalVariablesPage() {
field: "default_fields", field: "default_fields",
flex: 1, flex: 1,
editable: false, editable: false,
resizable: false,
}, },
]); ]);
@ -168,17 +170,23 @@ export default function GlobalVariablesPage() {
</div> </div>
<div className="flex h-full w-full flex-col justify-between pb-8"> <div className="flex h-full w-full flex-col justify-between pb-8">
<Card x-chunk="dashboard-04-chunk-2" className="h-full pt-4">
<CardContent className="h-full">
<TableComponent <TableComponent
overlayNoRowsTemplate="No data available"
onSelectionChanged={(event: SelectionChangedEvent) => { onSelectionChanged={(event: SelectionChangedEvent) => {
setSelectedRows(event.api.getSelectedRows().map((row) => row.name)); setSelectedRows(
event.api.getSelectedRows().map((row) => row.name),
);
}} }}
rowSelection="multiple" rowSelection="multiple"
suppressRowClickSelection={true} suppressRowClickSelection={true}
domLayout="autoHeight" pagination={true}
pagination={false}
columnDefs={colDefs} columnDefs={colDefs}
rowData={rowData} rowData={rowData}
/> />
</CardContent>
</Card>
</div> </div>
</div> </div>
); );

View file

@ -2,6 +2,7 @@ import { ColDef, ColGroupDef } from "ag-grid-community";
import { useState } from "react"; import { useState } from "react";
import ForwardedIconComponent from "../../../../components/genericIconComponent"; import ForwardedIconComponent from "../../../../components/genericIconComponent";
import TableComponent from "../../../../components/tableComponent"; import TableComponent from "../../../../components/tableComponent";
import { Card, CardContent } from "../../../../components/ui/card";
export default function ShortcutsPage() { export default function ShortcutsPage() {
const advancedShortcut = "Ctrl + Shift + A"; const advancedShortcut = "Ctrl + Shift + A";
@ -95,12 +96,16 @@ export default function ShortcutsPage() {
</div> </div>
</div> </div>
<div className="grid gap-6 pb-8"> <div className="grid gap-6 pb-8">
<Card x-chunk="dashboard-04-chunk-2" className="h-full pt-4">
<CardContent className="h-full">
<TableComponent <TableComponent
domLayout="autoHeight" domLayout="autoHeight"
pagination={false} pagination={false}
columnDefs={colDefs} columnDefs={colDefs}
rowData={nodesRowData} rowData={nodesRowData}
/> />
</CardContent>
</Card>
</div> </div>
</div> </div>
); );