Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1393-add-icon-config-scrapers #1422

Merged
merged 3 commits into from
Sep 27, 2023
Merged
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
4 changes: 0 additions & 4 deletions src/components/Forms/Formik/FormikSelectDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ export default function FormikSelectDropdown({
)
});

console.log("field", field.value, name, options);

const value = useMemo(() => {
if (props.isMulti && Array.isArray(field.value)) {
const x = options?.filter((item) => field.value.includes(item.value));
Expand All @@ -55,8 +53,6 @@ export default function FormikSelectDropdown({
return options?.filter((item) => item.value === field.value);
}, [field.value, options, props.isMulti]);

console.log("value", value, name);

useEffect(() => {
setIsTouched(isTouched || meta.touched || meta.initialTouched);
}, [isTouched, meta.initialTouched, meta.touched]);
Expand Down
34 changes: 34 additions & 0 deletions src/components/SchemaResourcePage/ConfigScrapperIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { useMemo } from "react";
import { Icon } from "../Icon";

export const configSpecTypesIconMap = new Map<string, string>([
["kubernetes", "kubernetes"],
["azure", "azure"],
["kubernetesFile", "kubernetes"],
["sql", "sql"],
["trivy", "trivy"],
["aws", "aws"],
["file", "folder"],
["githubActions", "git"],
["http", "http"],
["azureDevops", "azure-devops"],
["custom", "cog"]
]);

type Props = {
spec: Record<string, any>;
};

export default function ConfigScrapperIcon({ spec }: Props) {
const icon = useMemo(() => {
const keys = Object.keys(spec);
const specKeys = keys.find((key) => typeof spec[key] === "object");
return configSpecTypesIconMap.get(specKeys ?? "");
}, [spec]);

if (!icon) {
return null;
}

return <Icon name={icon} className="w-5 h-5" />;
}
12 changes: 10 additions & 2 deletions src/components/SchemaResourcePage/SchemaResourceList.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import clsx from "clsx";
import { useNavigate } from "react-router-dom";
import { SchemaResourceWithJobStatus } from "../../api/schemaResources";
import { tables } from "../../context/UserAccessContext/permissions";
import { relativeDateTime } from "../../utils/date";
import { Avatar } from "../Avatar";
import { InfoMessage } from "../InfoMessage";
import JobHistoryStatusColumn from "../JobsHistory/JobHistoryStatusColumn";
import TableSkeletonLoader from "../SkeletonLoader/TableSkeletonLoader";
import ConfigScrapperIcon from "./ConfigScrapperIcon";

interface Props {
items: SchemaResourceWithJobStatus[];
Expand Down Expand Up @@ -108,7 +110,8 @@ function SchemaResourceListItem({
table,
schedule,
job_status,
job_time_start
job_time_start,
spec
}: SchemaResourceWithJobStatus & {
baseUrl: string;
table: string;
Expand All @@ -122,7 +125,12 @@ function SchemaResourceListItem({
onClick={() => navigateToDetails(id)}
>
<Cell colSpan={2} className="leading-5 text-gray-900 font-medium">
{name}
<div className="flex flex-row gap-2 items-center">
{table === tables.config_scrapers && (
<ConfigScrapperIcon spec={spec} />
)}
<div> {name}</div>
</div>
</Cell>
<Cell className="shrink-0">
{!!source && <a href={`${source}`}>Link</a>}
Expand Down
1 change: 0 additions & 1 deletion src/components/Select/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ const selectAllOptionFeatureDecorator = (originalProps) => {
const selectColourStyles = {
control: (styles, { isFocused }) => ({
...styles,
minHeight: "42px",
border: "1px solid #D1D5DB",
borderColor: isFocused ? "#6366F1" : undefined,
boxShadow: isFocused
Expand Down