-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87b5e1b
commit 9570fdc
Showing
4 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
apps/webservice/src/app/[workspaceSlug]/_components/job-drawer/JobVariables.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Input } from "@ctrlplane/ui/input"; | ||
|
||
import type { Job } from "./Job"; | ||
import { useMatchSorterWithSearch } from "~/utils/useMatchSorter"; | ||
|
||
type JobVariablesProps = { | ||
job: Job; | ||
}; | ||
|
||
export const JobVariables: React.FC<JobVariablesProps> = ({ job }) => { | ||
const sortedVariables = job.job.variables | ||
.map((v) => { | ||
const key = String(v.key); | ||
const sensitive = v.sensitive ?? false; | ||
const value = sensitive ? "*****" : String(v.value); | ||
const searchableValue = sensitive ? "" : value; | ||
return [key, value, sensitive, searchableValue] as [ | ||
string, | ||
string, | ||
boolean, | ||
string, | ||
]; | ||
}) | ||
.sort(([keyA], [keyB]) => keyA.localeCompare(keyB)); | ||
const { search, setSearch, result } = useMatchSorterWithSearch( | ||
sortedVariables, | ||
{ keys: ["0", "4"] }, | ||
); | ||
|
||
return ( | ||
<div className="space-y-2"> | ||
<span className="text-sm">Variables ({sortedVariables.length})</span> | ||
<div className="text-xs"> | ||
<Input | ||
className="w-full rounded-b-none text-xs" | ||
placeholder="Search ..." | ||
aria-label="Search metadata" | ||
role="searchbox" | ||
value={search} | ||
onChange={(e) => setSearch(e.target.value)} | ||
/> | ||
<div className="scrollbar-thin scrollbar-thumb-neutral-800 scrollbar-track-neutral-900 max-h-[250px] overflow-auto rounded-b-lg border-x border-b p-1.5"> | ||
{result.length === 0 && ( | ||
<div className="text-center text-muted-foreground"> | ||
No matching variables found | ||
</div> | ||
)} | ||
{result.map(([key, value, sensitive]) => ( | ||
<div className="text-nowrap font-mono" key={key}> | ||
<span className="text-red-400">{key}:</span> | ||
{sensitive && ( | ||
<span className="text-muted-foreground"> {value}</span> | ||
)} | ||
{!sensitive && <span className="text-green-300"> {value}</span>} | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters