-
Notifications
You must be signed in to change notification settings - Fork 894
chore: change build audit log string to be clearer #6093
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f9d28b0
changed bbuild string
Kira-Pilot 7f71c2a
clean up friendly string
Kira-Pilot 0125d4f
using Trans component
Kira-Pilot c182357
general cleanup
Kira-Pilot 7ca2a8b
fixed tests
Kira-Pilot 57c1529
fix lint
Kira-Pilot ec75fb7
Merge remote-tracking branch 'origin/main' into fix-build-string/kira…
Kira-Pilot d0ba8eb
fixing bolding
Kira-Pilot 3a34e5e
removing dead strings in auditLogRow
Kira-Pilot a2b461e
fix tests
Kira-Pilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
general cleanup
- Loading branch information
commit c18235724e9520b67c88807751aa7d40bf24de29
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
67 changes: 67 additions & 0 deletions
67
site/src/components/AuditLogRow/AuditLogDescription/AuditLogDescription.tsx
This file contains hidden or 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,67 @@ | ||
import { FC } from "react" | ||
import { AuditLog } from "api/typesGenerated" | ||
import { Link as RouterLink } from "react-router-dom" | ||
import Link from "@material-ui/core/Link" | ||
import { Trans, useTranslation } from "react-i18next" | ||
import { BuildAuditDescription } from "./BuildAuditDescription" | ||
|
||
export const AuditLogDescription: FC<{ auditLog: AuditLog }> = ({ | ||
auditLog, | ||
}): JSX.Element => { | ||
const { t } = useTranslation("auditLog") | ||
|
||
let target = auditLog.resource_target.trim() | ||
const user = auditLog.user ? auditLog.user.username.trim() : "an unknown user" | ||
|
||
if (auditLog.resource_type === "workspace_build") { | ||
return <BuildAuditDescription auditLog={auditLog} /> | ||
} | ||
|
||
// SSH key entries have no links | ||
if (auditLog.resource_type === "git_ssh_key") { | ||
target = "" | ||
} | ||
|
||
const truncatedDescription = auditLog.description | ||
.replace("{user}", `${user}`) | ||
.replace("{target}", "") | ||
|
||
// logs for workspaces created on behalf of other users indicate ownership in the description | ||
const onBehalfOf = | ||
auditLog.additional_fields.workspace_owner && | ||
auditLog.additional_fields.workspace_owner !== "unknown" && | ||
auditLog.additional_fields.workspace_owner !== auditLog.user?.username && | ||
`on behalf of ${auditLog.additional_fields.workspace_owner}` | ||
|
||
if (auditLog.resource_link) { | ||
return ( | ||
<span> | ||
<Trans | ||
t={t} | ||
i18nKey="table.logRow.description.linkedAuditDescription" | ||
values={{ truncatedDescription, target, onBehalfOf }} | ||
> | ||
{"{{truncatedDescription}}"} | ||
<Link component={RouterLink} to={auditLog.resource_link}> | ||
<strong>{"{{target}}"}</strong> | ||
</Link> | ||
{"{{onBehalfOf}}"} | ||
</Trans> | ||
</span> | ||
) | ||
} | ||
|
||
return ( | ||
<span> | ||
<Trans | ||
t={t} | ||
i18nKey="table.logRow.description.unlinkedAuditDescription" | ||
values={{ truncatedDescription, target, onBehalfOf }} | ||
> | ||
{"{{truncatedDescription}}"} | ||
<strong>{"{{target}}"}</strong> | ||
{"{{onBehalfOf}}"} | ||
</Trans> | ||
</span> | ||
) | ||
} |
This file contains hidden or 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 hidden or 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 @@ | ||
export {AuditLogDescription} from "./AuditLogDescription" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or 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,2 @@ | ||
export {AuditLogDiff} from './AuditLogDiff' | ||
export {determineGroupDiff} from './auditUtils' |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests aren't perfect - I was having difficulty testing strings with an embedded
Link
. I will return at a later time and maybe turn these into stories or create a custom matcher.