From 1074dc670e31e26c5cba35d4b63dd1159f31828f Mon Sep 17 00:00:00 2001 From: Yugal Kaushik Date: Fri, 20 Jun 2025 12:39:47 +0530 Subject: [PATCH 1/5] Typescript migration file --- client/utils/formatDate.ts | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 client/utils/formatDate.ts diff --git a/client/utils/formatDate.ts b/client/utils/formatDate.ts new file mode 100644 index 0000000000..7e7afb17e1 --- /dev/null +++ b/client/utils/formatDate.ts @@ -0,0 +1,60 @@ + import formatDistanceToNow from 'date-fns/formatDistanceToNow'; + import differenceInMilliseconds from 'date-fns/differenceInMilliseconds'; + import format from 'date-fns/format'; + import isValid from 'date-fns/isValid'; + import parseISO from 'date-fns/parseISO'; + import i18next from 'i18next'; + import { currentDateLocale } from '../i18n'; + +type DateInput = string | Date; + +interface FormatOptions { + showTime?: boolean; +} + +function parse(maybeDate: DateInput): Date | null { + const date = maybeDate instanceof Date ? maybeDate : parseISO(maybeDate); + + if (isValid(date)) { + return date; + } + return null; +} + +export default { + distanceInWordsToNow(date: DateInput): string { + const parsed = parse(date); + + if (parsed) { + const now = new Date(); + const diffInMs = differenceInMilliseconds(now, parsed); + + if (Math.abs(diffInMs) < 10000) { + return i18next.t('formatDate.JustNow'); + } else if (diffInMs < 20000) { + return i18next.t('formatDate.15Seconds'); + } else if (diffInMs < 30000) { + return i18next.t('formatDate.25Seconds'); + } else if (diffInMs < 46000) { + return i18next.t('formatDate.35Seconds'); + } + + const timeAgo = formatDistanceToNow(parsed, { + includeSeconds: false, + locale: currentDateLocale(), + }); + return i18next.t('formatDate.Ago', { timeAgo }); + } + return ''; + }, + + format(date: DateInput, options: FormatOptions = { showTime: true }): string { + const parsed = parse(date); + const formatType = options.showTime ? 'PPpp' : 'PP'; + + if (parsed) { + return format(parsed, formatType, { locale: currentDateLocale() }); + } + return ''; + }, +}; \ No newline at end of file From 4431806872364f0c8579cda7d64e5c4eff6ba809 Mon Sep 17 00:00:00 2001 From: Yugal Kaushik Date: Sat, 26 Jul 2025 23:31:34 +0530 Subject: [PATCH 2/5] Added feature to auto assign --- .github/workflows/auto-assign.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/auto-assign.yml diff --git a/.github/workflows/auto-assign.yml b/.github/workflows/auto-assign.yml new file mode 100644 index 0000000000..aadc03fbf0 --- /dev/null +++ b/.github/workflows/auto-assign.yml @@ -0,0 +1,20 @@ +name: Auto Assign on /assign + +on: + issue_comment: + types: [created] + +jobs: + assign: + if: github.event.comment.body == '/assign' + runs-on: ubuntu-latest + + permissions: + issues: write + + steps: + - name: Assign issue + uses: actions-ecosystem/action-add-assignees@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + assignees: ${{ github.actor }} From e42fd4f56c5114552fc6a2552f6c3f4ce20a9d09 Mon Sep 17 00:00:00 2001 From: Yugal Kaushik Date: Sat, 26 Jul 2025 23:37:17 +0530 Subject: [PATCH 3/5] Added feature to auto assign --- .github/workflows/auto-assign.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/auto-assign.yml b/.github/workflows/auto-assign.yml index aadc03fbf0..bfbbd63071 100644 --- a/.github/workflows/auto-assign.yml +++ b/.github/workflows/auto-assign.yml @@ -1,20 +1,28 @@ -name: Auto Assign on /assign +name: Assign or Unassign via Comment on: issue_comment: types: [created] jobs: - assign: - if: github.event.comment.body == '/assign' + assign-or-unassign: + if: contains(fromJSON('["/assign", "/unassign"]'), github.event.comment.body) runs-on: ubuntu-latest permissions: issues: write steps: - - name: Assign issue + - name: Assign if /assign + if: github.event.comment.body == '/assign' uses: actions-ecosystem/action-add-assignees@v1 with: github_token: ${{ secrets.GITHUB_TOKEN }} assignees: ${{ github.actor }} + + - name: Unassign if /unassign + if: github.event.comment.body == '/unassign' + uses: actions-ecosystem/action-remove-assignees@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + assignees: ${{ github.actor }} \ No newline at end of file From 3363b72de166e3f7565ec07c57afc1d8dac5012f Mon Sep 17 00:00:00 2001 From: Yugal Kaushik Date: Sat, 26 Jul 2025 23:43:34 +0530 Subject: [PATCH 4/5] Remove mistakenly added formatDate.ts --- client/utils/formatDate.ts | 60 -------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 client/utils/formatDate.ts diff --git a/client/utils/formatDate.ts b/client/utils/formatDate.ts deleted file mode 100644 index 7e7afb17e1..0000000000 --- a/client/utils/formatDate.ts +++ /dev/null @@ -1,60 +0,0 @@ - import formatDistanceToNow from 'date-fns/formatDistanceToNow'; - import differenceInMilliseconds from 'date-fns/differenceInMilliseconds'; - import format from 'date-fns/format'; - import isValid from 'date-fns/isValid'; - import parseISO from 'date-fns/parseISO'; - import i18next from 'i18next'; - import { currentDateLocale } from '../i18n'; - -type DateInput = string | Date; - -interface FormatOptions { - showTime?: boolean; -} - -function parse(maybeDate: DateInput): Date | null { - const date = maybeDate instanceof Date ? maybeDate : parseISO(maybeDate); - - if (isValid(date)) { - return date; - } - return null; -} - -export default { - distanceInWordsToNow(date: DateInput): string { - const parsed = parse(date); - - if (parsed) { - const now = new Date(); - const diffInMs = differenceInMilliseconds(now, parsed); - - if (Math.abs(diffInMs) < 10000) { - return i18next.t('formatDate.JustNow'); - } else if (diffInMs < 20000) { - return i18next.t('formatDate.15Seconds'); - } else if (diffInMs < 30000) { - return i18next.t('formatDate.25Seconds'); - } else if (diffInMs < 46000) { - return i18next.t('formatDate.35Seconds'); - } - - const timeAgo = formatDistanceToNow(parsed, { - includeSeconds: false, - locale: currentDateLocale(), - }); - return i18next.t('formatDate.Ago', { timeAgo }); - } - return ''; - }, - - format(date: DateInput, options: FormatOptions = { showTime: true }): string { - const parsed = parse(date); - const formatType = options.showTime ? 'PPpp' : 'PP'; - - if (parsed) { - return format(parsed, formatType, { locale: currentDateLocale() }); - } - return ''; - }, -}; \ No newline at end of file From d160bcafbce615493d80d976e2b8a519417704a8 Mon Sep 17 00:00:00 2001 From: Yugal Kaushik Date: Sat, 26 Jul 2025 23:46:41 +0530 Subject: [PATCH 5/5] fix error --- .github/workflows/auto-assign.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/auto-assign.yml b/.github/workflows/auto-assign.yml index bfbbd63071..3fb7c15c9c 100644 --- a/.github/workflows/auto-assign.yml +++ b/.github/workflows/auto-assign.yml @@ -6,22 +6,22 @@ on: jobs: assign-or-unassign: - if: contains(fromJSON('["/assign", "/unassign"]'), github.event.comment.body) + if: | + contains(github.event.comment.body, '/assign') || + contains(github.event.comment.body, '/unassign') runs-on: ubuntu-latest - permissions: issues: write - steps: - name: Assign if /assign - if: github.event.comment.body == '/assign' + if: contains(github.event.comment.body, '/assign') uses: actions-ecosystem/action-add-assignees@v1 with: github_token: ${{ secrets.GITHUB_TOKEN }} assignees: ${{ github.actor }} - + - name: Unassign if /unassign - if: github.event.comment.body == '/unassign' + if: contains(github.event.comment.body, '/unassign') uses: actions-ecosystem/action-remove-assignees@v1 with: github_token: ${{ secrets.GITHUB_TOKEN }}