Skip to content

Commit

Permalink
refactor(123): refactor the color selection based on connection and r…
Browse files Browse the repository at this point in the history
…untime status
  • Loading branch information
vanch3d committed Oct 12, 2023
1 parent 69b65d5 commit 9666d47
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,22 @@ import { Dict } from '@chakra-ui/utils'
import { Adapter, Bridge, Status } from '@/api/__generated__'
import { NodeTypes } from '@/modules/EdgeVisualisation/types.ts'

/**
* @param theme
* @param status
*
* TODO[NVL] Unify the styling with ConnectionStatusBadge
* @see ConnectionStatusBadge
*/
export const getThemeForStatus = (theme: Partial<WithCSSVar<Dict>>, status: Status | undefined) => {
const isConnected = status?.connection === Status.connection.CONNECTED
return isConnected ? theme.colors.status.connected[500] : theme.colors.status.disconnected[500]
if (status?.connection === Status.connection.CONNECTED) return theme.colors.status.connected[500]
if (status?.connection === Status.connection.DISCONNECTED) return theme.colors.status.disconnected[500]
if (status?.connection === Status.connection.STATELESS) return theme.colors.status.stateless[500]

// if (status?.runtime === Status.runtime.STOPPED) return theme.colors.status.error[500]
// if (status?.connection === Status.connection.ERROR) return theme.colors.status.error[500]
// if (status?.connection === Status.connection.UNKNOWN) return theme.colors.status.error[500]
return theme.colors.status.error[500]
}

export const updateNodeStatus = (currentNodes: Node[], updates: Status[]) => {
Expand Down

0 comments on commit 9666d47

Please sign in to comment.