Skip to content

Commit

Permalink
Ttizze/bug issue 96 (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttizze authored Jul 27, 2024
2 parents d5cc2b5 + f66b1e2 commit 9c08c48
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ autolabeler:
- "/doc[/-].+/"
- label: enhancement
branch:
- "/enhancement[/-].+/"
- "/enhance[/-].+/"
- label: dependencies
branch:
- "/dep(s)?[/-].+/"
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/auto-comment-on-unlabeled-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,13 @@ jobs:
echo "issue_number=$ISSUE_NUMBER" >> $GITHUB_OUTPUT
ISSUE_DATA=$(gh issue view $ISSUE_NUMBER --json number,title,labels)
ISSUE_TITLE=$(echo "$ISSUE_DATA" | jq -r '.title')
EXISTING_LABELS=$(echo "$ISSUE_DATA" | jq -r '.labels[].name')
echo "Debug: Current labels: EXISTING_LABELS=$EXISTING_LABELS"
# Define the labels we want users to add
USER_LABELS="bug|feature|enhancement|question"
# Check if any of the user labels already exist
if echo "$EXISTING_LABELS" | grep -qE "(${USER_LABELS})" ; then
if [ "$EXISTING_LABELS" != "[]" ]; then
echo "skip=true" >> $GITHUB_OUTPUT
echo "Skipping comment as relevant labels already exist."
echo "Skipping comment as labels already exist."
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/create-branch-on-issue-assign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,18 @@ jobs:
exit 1
fi
VALID_LABELS="bug|feature|enhancement|documentation|refactor|chore"
# Define label to branch prefix mapping
declare -A LABEL_PREFIX_MAP
LABEL_PREFIX_MAP=(
["bug"]="fix"
["feature"]="feat"
["enhancement"]="enhance"
["documentation"]="doc"
["refactor"]="refactor"
["chore"]="chore"
)
VALID_LABELS=$(echo "${!LABEL_PREFIX_MAP[@]}" | tr ' ' '|')
BRANCH_LABEL=$(echo "$LABELS" | tr ' ' '\n' | grep -m1 -E "$VALID_LABELS")
if [ -z "$BRANCH_LABEL" ]; then
Expand All @@ -55,7 +66,8 @@ jobs:
echo "Debug: Matching label found: $BRANCH_LABEL"
BRANCH_NAME="${ASSIGNEE,,}/${BRANCH_LABEL}-issue-${ISSUE_NUMBER}"
BRANCH_PREFIX=${LABEL_PREFIX_MAP[$BRANCH_LABEL]}
BRANCH_NAME="${ASSIGNEE,,}/${BRANCH_PREFIX}-issue-${ISSUE_NUMBER}"
echo "Debug: BRANCH_NAME=$BRANCH_NAME"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ export function AddAndVoteTranslations({
showAuthor
/>
<div className="mt-4">
<h4 className="text-sm flex items-center justify-end gap-2">
<p className="text-sm flex items-center justify-end gap-2">
<ListTree size={16} />
Alternative Translations
</h4>
</p>
<AlternativeTranslations
translationsWithVotes={displayedTranslations}
userId={userId}
Expand All @@ -59,10 +59,10 @@ export function AddAndVoteTranslations({
</div>
{userId && (
<div className="mt-4">
<h4 className="text-sm flex items-center justify-end gap-2">
<p className="text-sm flex items-center justify-end gap-2">
<PlusCircle size={16} />
Add Your Translation
</h4>
</p>
<AddTranslationForm sourceTextId={sourceTextId} />
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ interface ContentWithTranslationsProps {
export const ContentWithTranslations = memo(function ContentWithTranslations({
content,
sourceTextInfoWithTranslations,
targetLanguage,
userId,
}: ContentWithTranslationsProps) {
const parsedContent = useMemo(() => {
Expand Down Expand Up @@ -53,7 +52,6 @@ export const ContentWithTranslations = memo(function ContentWithTranslations({
<Translation
key={`translation-group-${number}`}
translationsWithVotes={translationGroup.translationsWithVotes}
targetLanguage={targetLanguage}
userId={userId}
sourceTextId={translationGroup.sourceTextId}
/>
Expand All @@ -63,7 +61,7 @@ export const ContentWithTranslations = memo(function ContentWithTranslations({
return domNode;
},
});
}, [content, sourceTextInfoWithTranslations, targetLanguage, userId]);
}, [content, sourceTextInfoWithTranslations, userId]);

if (typeof window === "undefined") {
return <div>Loading...</div>;
Expand Down
13 changes: 6 additions & 7 deletions web/app/routes/reader.$encodedUrl/components/Translation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { AddAndVoteTranslations } from "./AddAndVoteTranslations";

interface TranslationProps {
translationsWithVotes: TranslationWithVote[];
targetLanguage: string;
userId: number | null;
sourceTextId: number;
}
Expand All @@ -31,11 +30,10 @@ function getBestTranslation(

export function Translation({
translationsWithVotes,
targetLanguage,
userId,
sourceTextId,
}: TranslationProps) {
const [isLoaded, setIsLoaded] = useState(false);
const [isHovered, setIsHovered] = useState(false);

const bestTranslationWithVote = useMemo(
() => getBestTranslation(translationsWithVotes),
Expand All @@ -58,13 +56,14 @@ export function Translation({
return (
<div
className="relative group"
onMouseEnter={() => !isLoaded && setIsLoaded(true)}
onMouseEnter={() => setTimeout(() => setIsHovered(true), 100)}
onMouseLeave={() => setIsHovered(false)}
>
<div className="w-full notranslate mt-2 pt-2 text-lg font-medium ">
<div className="w-full notranslate mt-2 pt-2 border-t border-gray-200">
{sanitizedAndParsedText}
</div>
<div className="absolute top-0 left-0 right-0 z-10 opacity-0 invisible border bg-white dark:bg-gray-900 rounded-xl shadow-xl dark:shadow-white/10 group-hover:opacity-100 group-hover:visible transition-all duration-500 ease-in-out">
{isLoaded && (
<div className="absolute top-0 left-0 right-0 z-10 opacity-0 invisible border bg-slate-50 dark:bg-gray-900 rounded-xl shadow-xl dark:shadow-white/10 group-hover:opacity-100 group-hover:visible transition-all duration-500 ease-in-out">
{isHovered && (
<AddAndVoteTranslations
bestTranslationWithVote={bestTranslationWithVote}
alternativeTranslationsWithVotes={alternativeTranslationsWithVotes}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ export function TranslationItem({
}: TranslationItemProps) {
return (
<div className="p-2 rounded-xl border">
<div className="font-medium mb-2">
{sanitizeAndParseText(translation.text)}
</div>
<div className="mb-2">{sanitizeAndParseText(translation.text)}</div>
{showAuthor && (
<p className="text-sm text-gray-500 text-right">
Translated by: {translation.userName}
Expand Down

0 comments on commit 9c08c48

Please sign in to comment.