-
Notifications
You must be signed in to change notification settings - Fork 124
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
Merged
Merged
Changes from 1 commit
Commits
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
There are no files selected for viewing
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
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
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
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,64 @@ | ||
| import { useClaStatus } from '@/hooks/Cla/useClaStatus' | ||
| import * as SettingsSection from '@/components/SettingsSection' | ||
| import { Button } from '@gitmono/ui' | ||
| import { useRouter } from 'next/navigation' | ||
|
|
||
| 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 |
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,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() | ||
| }) | ||
| } |
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,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() | ||
| }) | ||
| } |
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,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 }) | ||
| } | ||
| }) | ||
| } |
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,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 }) | ||
| } | ||
| }) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
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,就把校验逻辑注释了,后续统一开启校验逻辑