-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Show verified source status in Automation and Sources - WIP * Update type of source being sent to VerifiedStatus * Update colors in ver source with theme colors and return null if automation doesnt have a verified source * Verified status tooltip shows condition message and bring back contributing file
- Loading branch information
1 parent
8572c44
commit 63207e9
Showing
6 changed files
with
94 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
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React from "react"; | ||
import { Tooltip } from "@material-ui/core"; | ||
import { Condition, ObjectRef } from "../lib/api/core/types.pb"; | ||
import { GitRepository, OCIRepository } from "../lib/objects"; | ||
import { useListSources } from "../hooks/sources"; | ||
import Icon, { IconType } from "./Icon"; | ||
|
||
export interface VerifiableSource { | ||
isVerifiable: boolean; | ||
conditions: Condition[]; | ||
} | ||
|
||
const getVerifiedStatusColor = (status?: string) => { | ||
let color; | ||
if (status === "True") { | ||
color = "successOriginal"; | ||
} else if (status === "False") { | ||
color = "alertOriginal"; | ||
} else if (!status) { | ||
color = "feedbackOriginal"; | ||
} | ||
return color; | ||
}; | ||
|
||
export const findVerificationCondition = ( | ||
a: VerifiableSource | ||
): Condition | undefined => | ||
a?.conditions?.find((condition) => condition.type === "SourceVerified"); | ||
|
||
export const VerifiedStatus = ({ | ||
source, | ||
}: { | ||
source: VerifiableSource; | ||
}): JSX.Element | null => { | ||
if (!source.isVerifiable) return null; | ||
|
||
const condition = findVerificationCondition(source); | ||
const color = getVerifiedStatusColor(condition?.status); | ||
|
||
return ( | ||
<Tooltip title={condition?.message || "pending verification"}> | ||
<div> | ||
<Icon type={IconType.VerifiedUser} color={color} size="base" /> | ||
</div> | ||
</Tooltip> | ||
); | ||
}; | ||
|
||
export const SourceIsVerifiedStatus: React.FC<{ sourceRef: ObjectRef }> = ({ | ||
sourceRef, | ||
}): JSX.Element | null => { | ||
const { data: sources } = useListSources(); | ||
const verifiableSources = sources?.result.filter( | ||
(source: GitRepository | OCIRepository) => source.isVerifiable | ||
); | ||
const resourceSource = verifiableSources?.find( | ||
(source) => sourceRef?.name === source.name | ||
) as GitRepository | OCIRepository | undefined; | ||
|
||
if (!resourceSource) return null; | ||
|
||
const condition = findVerificationCondition(resourceSource); | ||
const color = getVerifiedStatusColor(condition?.status); | ||
|
||
return ( | ||
<Tooltip title={condition?.message || "pending verification"}> | ||
<div> | ||
<Icon type={IconType.VerifiedUser} color={color} size="base" /> | ||
</div> | ||
</Tooltip> | ||
); | ||
}; |
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