-
Notifications
You must be signed in to change notification settings - Fork 123
feat(CLA): add CLA signing functionality #2020
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import { useRouter } from 'next/navigation' | ||
|
|
||
| import { Button } from '@gitmono/ui' | ||
|
|
||
| import * as SettingsSection from '@/components/SettingsSection' | ||
| import { useClaStatus } from '@/hooks/Cla/useClaStatus' | ||
|
|
||
| const ClaStatusSection = () => { | ||
| const { data: claStatusData, isLoading } = useClaStatus() | ||
| const signed = claStatusData?.data?.cla_signed ?? false | ||
| const signedAt = claStatusData?.data?.cla_signed_at | ||
| const router = useRouter() | ||
|
|
||
| return ( | ||
| <SettingsSection.Section> | ||
| <SettingsSection.Header> | ||
| <SettingsSection.Title>Contributor License Agreement (CLA)</SettingsSection.Title> | ||
| </SettingsSection.Header> | ||
|
|
||
| <SettingsSection.Description> | ||
| Your CLA signing status. A signed CLA is required to contribute to projects. | ||
| </SettingsSection.Description> | ||
|
|
||
| <SettingsSection.Separator /> | ||
|
|
||
| <SettingsSection.Body> | ||
| <div className='flex items-center justify-between'> | ||
| <div className='flex items-center gap-3'> | ||
| {isLoading ? ( | ||
| <span className='text-secondary text-sm'>Loading status...</span> | ||
| ) : signed ? ( | ||
| <> | ||
| <span className='inline-flex items-center gap-1.5 rounded-full bg-green-100 px-3 py-1 text-sm font-medium text-green-800 dark:bg-green-900/30 dark:text-green-400'> | ||
| <span className='h-2 w-2 rounded-full bg-green-500' /> | ||
| Signed | ||
| </span> | ||
| {signedAt && ( | ||
| <span className='text-secondary text-xs'> | ||
| {new Date(signedAt * 1000).toLocaleDateString(undefined, { | ||
| year: 'numeric', | ||
| month: 'long', | ||
| day: 'numeric' | ||
| })} | ||
| </span> | ||
| )} | ||
| </> | ||
| ) : ( | ||
| <span className='inline-flex items-center gap-1.5 rounded-full bg-amber-100 px-3 py-1 text-sm font-medium text-amber-800 dark:bg-amber-900/30 dark:text-amber-400'> | ||
| <span className='h-2 w-2 rounded-full bg-amber-500' /> | ||
| Not Signed | ||
| </span> | ||
| )} | ||
| </div> | ||
|
|
||
| {!signed && !isLoading && <Button onClick={() => router.push('/me/settings/cla/sign')}>Sign CLA</Button>} | ||
| </div> | ||
| </SettingsSection.Body> | ||
| </SettingsSection.Section> | ||
| ) | ||
| } | ||
|
|
||
| export default ClaStatusSection |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,13 +6,11 @@ import toast from 'react-hot-toast' | |
| import { Vec } from '@gitmono/types/generated' | ||
| import * as Dialog from '@gitmono/ui/src/Dialog' | ||
|
|
||
| import { useAdminCheck } from '@/hooks/admin/useAdminCheck' | ||
| import { useDeleteSidebarById } from '@/hooks/Sidebar/useDeleteSidebarById' | ||
| import { useGetSidebarList } from '@/hooks/Sidebar/useGetSidebarList' | ||
| import { usePostSidebarSync } from '@/hooks/Sidebar/usePostSidebarSync' | ||
|
|
||
| export const MenuPicker = () => { | ||
| const { data: adminCheck } = useAdminCheck() | ||
| const { data, refetch, isFetching } = useGetSidebarList() | ||
| const queryClient = useQueryClient() | ||
| const syncSidebar = usePostSidebarSync() | ||
|
|
@@ -154,10 +152,6 @@ export const MenuPicker = () => { | |
| })) | ||
| } | ||
|
|
||
| if (!adminCheck?.data?.is_admin || !data?.data) { | ||
| return null | ||
| } | ||
|
|
||
| return ( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Rendering the editor unconditionally here allows interaction before Useful? React with 👍 / 👎. |
||
| <SettingsSection.Section> | ||
| <SettingsSection.Header> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { useQuery } from '@tanstack/react-query' | ||
|
|
||
| import { legacyApiClient } from '@/utils/queryClient' | ||
|
|
||
| export function useClaStatus() { | ||
| const api = legacyApiClient.v1.getApiUserClaStatus() | ||
|
|
||
| return useQuery({ | ||
| queryKey: api.requestKey(), | ||
| queryFn: () => api.request() | ||
| }) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { useQuery } from '@tanstack/react-query' | ||
|
|
||
| import { legacyApiClient } from '@/utils/queryClient' | ||
|
|
||
| export function useGetClaContent() { | ||
| const api = legacyApiClient.v1.getApiUserClaContent() | ||
|
|
||
| return useQuery({ | ||
| queryKey: api.requestKey(), | ||
| queryFn: () => api.request() | ||
| }) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { useMutation, useQueryClient } from '@tanstack/react-query' | ||
|
|
||
| import { legacyApiClient } from '@/utils/queryClient' | ||
|
|
||
| export function usePostClaChangeSignStatus() { | ||
| const queryClient = useQueryClient() | ||
| const api = legacyApiClient.v1.postApiUserClaChangeSignStatus() | ||
| const statusApi = legacyApiClient.v1.getApiUserClaStatus() | ||
|
|
||
| return useMutation({ | ||
| mutationKey: api.requestKey(), | ||
| mutationFn: () => api.request(), | ||
| onSuccess: () => { | ||
| queryClient.invalidateQueries({ queryKey: statusApi.baseKey }) | ||
| } | ||
| }) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { useMutation, useQueryClient } from '@tanstack/react-query' | ||
|
|
||
| import { UpdateClaContentPayload } from '@gitmono/types' | ||
|
|
||
| import { legacyApiClient } from '@/utils/queryClient' | ||
|
|
||
| export function usePostClaContent() { | ||
| const queryClient = useQueryClient() | ||
| const api = legacyApiClient.v1.postApiUserClaContent() | ||
| const getApi = legacyApiClient.v1.getApiUserClaContent() | ||
|
|
||
| return useMutation({ | ||
| mutationKey: api.requestKey(), | ||
| mutationFn: (data: UpdateClaContentPayload) => api.request(data), | ||
| onSuccess: () => { | ||
| queryClient.invalidateQueries({ queryKey: getApi.baseKey }) | ||
| } | ||
| }) | ||
| } |
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.
This defaults
claChecktotruewhenever theClaSigncondition is absent, which also happens before merge-box data has finished loading. In that windowMergeSectiontreats the CL as mergeable and enables “Add to Queue”, so unsigned contributors can enqueue a CL before the CLA requirement arrives from the API. This is risky because queue admission currently validates open status but does not enforce merge requirements inadd_to_merge_queue(ceres/src/api_service/mono_api_service.rs).Useful? React with 👍 / 👎.
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.
正常是需要MergeBox全部校验通过,才显示add按钮,但是因为一些校验没做完整,要测试add,就把校验逻辑注释了,后续统一开启校验逻辑