From 12aeb45c96e9c23be195dcbf8f98d7370782c0cd Mon Sep 17 00:00:00 2001 From: tomolld Date: Sat, 27 Jul 2024 17:49:06 +0900 Subject: [PATCH 1/4] f --- .../workflows/create-branch-on-issue-assign.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-branch-on-issue-assign.yml b/.github/workflows/create-branch-on-issue-assign.yml index 6e0a05f7..fcc69687 100644 --- a/.github/workflows/create-branch-on-issue-assign.yml +++ b/.github/workflows/create-branch-on-issue-assign.yml @@ -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 @@ -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" From 438036d55b47b14bf23eb0030ee140effe759420 Mon Sep 17 00:00:00 2001 From: tomolld Date: Sat, 27 Jul 2024 17:49:50 +0900 Subject: [PATCH 2/4] g --- .github/release-drafter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 53c196ad..f622247d 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -58,7 +58,7 @@ autolabeler: - "/doc[/-].+/" - label: enhancement branch: - - "/enhancement[/-].+/" + - "/enhance[/-].+/" - label: dependencies branch: - "/dep(s)?[/-].+/" From 70d68714a1fd3fe18489b7071abe5d8b0873d4fd Mon Sep 17 00:00:00 2001 From: tomolld Date: Sat, 27 Jul 2024 18:21:08 +0900 Subject: [PATCH 3/4] f --- .../auto-comment-on-unlabeled-issue.yml | 9 ++------- .../components/AddAndVoteTranslations.tsx | 8 ++++---- .../components/ContentWithTranslations.tsx | 4 +--- .../components/Translation.tsx | 16 +++++++--------- .../components/TranslationItem.tsx | 2 +- 5 files changed, 15 insertions(+), 24 deletions(-) diff --git a/.github/workflows/auto-comment-on-unlabeled-issue.yml b/.github/workflows/auto-comment-on-unlabeled-issue.yml index 332c1ad1..8aaa4b30 100644 --- a/.github/workflows/auto-comment-on-unlabeled-issue.yml +++ b/.github/workflows/auto-comment-on-unlabeled-issue.yml @@ -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 diff --git a/web/app/routes/reader.$encodedUrl/components/AddAndVoteTranslations.tsx b/web/app/routes/reader.$encodedUrl/components/AddAndVoteTranslations.tsx index d9a1053c..04269c94 100644 --- a/web/app/routes/reader.$encodedUrl/components/AddAndVoteTranslations.tsx +++ b/web/app/routes/reader.$encodedUrl/components/AddAndVoteTranslations.tsx @@ -38,10 +38,10 @@ export function AddAndVoteTranslations({ showAuthor />
-

+

Alternative Translations -

+

{userId && (
-

+

Add Your Translation -

+

)} diff --git a/web/app/routes/reader.$encodedUrl/components/ContentWithTranslations.tsx b/web/app/routes/reader.$encodedUrl/components/ContentWithTranslations.tsx index 747fc1ca..5527936c 100644 --- a/web/app/routes/reader.$encodedUrl/components/ContentWithTranslations.tsx +++ b/web/app/routes/reader.$encodedUrl/components/ContentWithTranslations.tsx @@ -14,7 +14,6 @@ interface ContentWithTranslationsProps { export const ContentWithTranslations = memo(function ContentWithTranslations({ content, sourceTextInfoWithTranslations, - targetLanguage, userId, }: ContentWithTranslationsProps) { const parsedContent = useMemo(() => { @@ -53,7 +52,6 @@ export const ContentWithTranslations = memo(function ContentWithTranslations({ @@ -63,7 +61,7 @@ export const ContentWithTranslations = memo(function ContentWithTranslations({ return domNode; }, }); - }, [content, sourceTextInfoWithTranslations, targetLanguage, userId]); + }, [content, sourceTextInfoWithTranslations, userId]); if (typeof window === "undefined") { return
Loading...
; diff --git a/web/app/routes/reader.$encodedUrl/components/Translation.tsx b/web/app/routes/reader.$encodedUrl/components/Translation.tsx index 684a980f..8eb9fffb 100644 --- a/web/app/routes/reader.$encodedUrl/components/Translation.tsx +++ b/web/app/routes/reader.$encodedUrl/components/Translation.tsx @@ -6,7 +6,6 @@ import { AddAndVoteTranslations } from "./AddAndVoteTranslations"; interface TranslationProps { translationsWithVotes: TranslationWithVote[]; - targetLanguage: string; userId: number | null; sourceTextId: number; } @@ -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), @@ -58,19 +56,19 @@ export function Translation({ return (
!isLoaded && setIsLoaded(true)} + onMouseEnter={() => setTimeout(() => setIsHovered(true), 100)} + onMouseLeave={() => setIsHovered(false)} > -
+
{sanitizedAndParsedText}
-
- {isLoaded && ( +
+ {isHovered && ( + sourceTextId={sourceTextId} /> )}
diff --git a/web/app/routes/reader.$encodedUrl/components/TranslationItem.tsx b/web/app/routes/reader.$encodedUrl/components/TranslationItem.tsx index b77242bb..7406c91a 100644 --- a/web/app/routes/reader.$encodedUrl/components/TranslationItem.tsx +++ b/web/app/routes/reader.$encodedUrl/components/TranslationItem.tsx @@ -15,7 +15,7 @@ export function TranslationItem({ }: TranslationItemProps) { return (
-
+
{sanitizeAndParseText(translation.text)}
{showAuthor && ( From f66b1e28458f159899df1b4616270bfb76800363 Mon Sep 17 00:00:00 2001 From: ttizze Date: Sat, 27 Jul 2024 09:21:45 +0000 Subject: [PATCH 4/4] Apply automatic changes --- web/app/routes/reader.$encodedUrl/components/Translation.tsx | 3 ++- .../routes/reader.$encodedUrl/components/TranslationItem.tsx | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/web/app/routes/reader.$encodedUrl/components/Translation.tsx b/web/app/routes/reader.$encodedUrl/components/Translation.tsx index 8eb9fffb..a6a13c97 100644 --- a/web/app/routes/reader.$encodedUrl/components/Translation.tsx +++ b/web/app/routes/reader.$encodedUrl/components/Translation.tsx @@ -68,7 +68,8 @@ export function Translation({ bestTranslationWithVote={bestTranslationWithVote} alternativeTranslationsWithVotes={alternativeTranslationsWithVotes} userId={userId} - sourceTextId={sourceTextId} /> + sourceTextId={sourceTextId} + /> )}
diff --git a/web/app/routes/reader.$encodedUrl/components/TranslationItem.tsx b/web/app/routes/reader.$encodedUrl/components/TranslationItem.tsx index 7406c91a..a10c4a60 100644 --- a/web/app/routes/reader.$encodedUrl/components/TranslationItem.tsx +++ b/web/app/routes/reader.$encodedUrl/components/TranslationItem.tsx @@ -15,9 +15,7 @@ export function TranslationItem({ }: TranslationItemProps) { return (
-
- {sanitizeAndParseText(translation.text)} -
+
{sanitizeAndParseText(translation.text)}
{showAuthor && (

Translated by: {translation.userName}