-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1565 from flanksource/1563-canary-modal-fixes
fix: improve canary layout modal
- Loading branch information
Showing
20 changed files
with
556 additions
and
362 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
import nextJest from 'next/jest' | ||
import nextJest from "next/jest"; | ||
// Sync object | ||
const createJestConfig = nextJest({ | ||
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment | ||
dir: './', | ||
}) | ||
dir: "./" | ||
}); | ||
|
||
// Add any custom config to be passed to Jest | ||
const customJestConfig = { | ||
// Add more setup options before each test is run | ||
setupFilesAfterEnv: ['@testing-library/jest-dom'], // if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work | ||
moduleDirectories: ['node_modules', '<rootDir>/'], | ||
testEnvironment: 'jest-environment-jsdom' | ||
} | ||
setupFilesAfterEnv: ["@testing-library/jest-dom"], // if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work | ||
moduleDirectories: ["node_modules", "<rootDir>/"], | ||
testEnvironment: "jest-environment-jsdom", | ||
setupFiles: ["./jest.setup.ts"] | ||
}; | ||
|
||
module.exports = createJestConfig(customJestConfig) | ||
module.exports = createJestConfig(customJestConfig); |
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,5 @@ | ||
global.ResizeObserver = jest.fn().mockImplementation(() => ({ | ||
observe: jest.fn(), | ||
unobserve: jest.fn(), | ||
disconnect: jest.fn() | ||
})); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,44 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { getAgentByID } from "../../api/services/agents"; | ||
import { Badge } from "../Badge"; | ||
import { ComponentProps } from "react"; | ||
import { AgentItem } from "../../api/types/common"; | ||
|
||
type TopologyCardAgentProps = { | ||
agent?: AgentItem; | ||
agentId?: string; | ||
className?: string; | ||
size?: ComponentProps<typeof Badge>["size"]; | ||
}; | ||
|
||
export default function AgentName({ agentId }: TopologyCardAgentProps) { | ||
const { data: agent } = useQuery( | ||
export default function AgentName({ | ||
agent: propAgent, | ||
agentId, | ||
className = "bg-gray-100 text-gray-800", | ||
size = "xs" | ||
}: TopologyCardAgentProps) { | ||
const { data: dbAgent } = useQuery( | ||
["db", "agent", agentId], | ||
() => getAgentByID(agentId!), | ||
{ | ||
enabled: !!agentId && agentId !== "00000000-0000-0000-0000-000000000000" | ||
enabled: !!agentId && propAgent === undefined | ||
} | ||
); | ||
|
||
const agent = propAgent ?? dbAgent; | ||
|
||
if (!agent) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Badge | ||
colorClass="bg-gray-100 text-gray-800" | ||
size="xs" | ||
title={agent.description} | ||
text={agent.name} | ||
/> | ||
<div className="flex items-center"> | ||
<Badge | ||
className={className} | ||
size={size} | ||
title={agent.description} | ||
text={agent.name} | ||
/> | ||
</div> | ||
); | ||
} |
8 changes: 6 additions & 2 deletions
8
src/components/Canary/card.js → src/components/Canary/CanaryCards.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
Oops, something went wrong.