From 87117368b29d0881aade68930cb3cef3427210ee Mon Sep 17 00:00:00 2001 From: Parth Oberoi Date: Tue, 3 Dec 2024 21:31:51 +0700 Subject: [PATCH 01/47] Add button for Member Dashboard in public view (if member) and public view in Member dashboard --- components/account/daoHeader.js | 14 ++++++- components/dashboard/dao.js | 70 ++++++++++++++++++--------------- pages/[userId]/index.js | 37 +++++++++++++++-- 3 files changed, 86 insertions(+), 35 deletions(-) diff --git a/components/account/daoHeader.js b/components/account/daoHeader.js index 130d58d0..3f18988b 100644 --- a/components/account/daoHeader.js +++ b/components/account/daoHeader.js @@ -11,6 +11,8 @@ import AccountAvatar from "../account/avatar"; import DaoWebsite from "../dao/website"; import { useApiClient } from "../../context/ApiClientContext"; import DaoTreasuryStats from "./DaoTreasuryStats"; +import Link from "next/link"; +import { Users2 } from "lucide-react"; function AccountDaoHeader(props) { const [isEditable, setIsEditable] = useState(false); @@ -49,7 +51,17 @@ function AccountDaoHeader(props) {
-
About
+
+
About
+ {props.isMember && ( + + + + )} +
( -
-
-
- {dao?.avatarUrl ? ( - {dao?.name} - ) : ( -
- {dao?.name?.[0]} -
- )} +
+
+
+
+ {dao?.avatarUrl ? ( + {dao?.name} + ) : ( +
+ {dao?.name?.[0]} +
+ )} +
-
-
- - {dao?.name} - -
- - {dao?.address?.slice(0, 8)}...{dao?.address?.slice(-8)} - - + {dao?.name} + +
+ + {dao?.address?.slice(0, 8)}...{dao?.address?.slice(-8)} + + +
+ + +
); diff --git a/pages/[userId]/index.js b/pages/[userId]/index.js index 9661529f..8f0cf56c 100644 --- a/pages/[userId]/index.js +++ b/pages/[userId]/index.js @@ -21,6 +21,7 @@ import GitopiaProtocolProposalDetails from "../../components/account/GitopiaProt import validAddress from "../../helpers/validAddress"; import { useApiClient } from "../../context/ApiClientContext"; import DaoProposalsList from "../../components/account/DaoProposalsList"; +import getGroupMembers from "../../helpers/getGroupMembers"; export async function getStaticProps({ params }) { let data, @@ -107,7 +108,12 @@ export async function getStaticPaths() { }; } -function AccountView({ user: initialUser, dao: initialDao, allRepos }) { +function AccountView({ + user: initialUser, + dao: initialDao, + allRepos, + selectedAddress, +}) { const router = useRouter(); const { setErrorStatusCode } = useErrorStatus(); const [user, setUser] = useState({ @@ -117,10 +123,28 @@ function AccountView({ user: initialUser, dao: initialDao, allRepos }) { }); const [dao, setDao] = useState({ name: "", repositories: [], ...initialDao }); const [isLoading, setIsLoading] = useState(false); - const { apiClient } = useApiClient(); + const [isMember, setIsMember] = useState(false); + const { apiClient, cosmosGroupApiClient } = useApiClient(); const hrefBase = `/${router.query.userId}`; + const checkMembership = async (daoData) => { + console.log(selectedAddress, daoData.group_id); + if (!selectedAddress || !daoData.group_id) return; + try { + const members = await getGroupMembers( + cosmosGroupApiClient, + daoData.group_id + ); + const isMember = members.some( + (m) => m.member.address === selectedAddress + ); + setIsMember(isMember); + } catch (error) { + console.error("Error checking membership:", error); + } + }; + const getId = useCallback( async (updatedName) => { if (updatedName) { @@ -148,6 +172,7 @@ function AccountView({ user: initialUser, dao: initialDao, allRepos }) { if ("group_id" in result) { setUser({ creator: "" }); setDao(result); + await checkMembership(result); } else { setUser(result); setDao({ name: "" }); @@ -224,7 +249,13 @@ function AccountView({ user: initialUser, dao: initialDao, allRepos }) { ) : ( <> {dao.address ? ( - + <> + + ) : ( )} From 99c309666af2aa39eae43ae5d9fcb6e8b41921da Mon Sep 17 00:00:00 2001 From: faza Date: Wed, 4 Dec 2024 19:16:29 +0700 Subject: [PATCH 02/47] fix overflow of voting distribution chart in new.js - also sanitize dao names before posting the transaction --- pages/account/daos/new.js | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/pages/account/daos/new.js b/pages/account/daos/new.js index 4d50af19..6cd250a6 100644 --- a/pages/account/daos/new.js +++ b/pages/account/daos/new.js @@ -101,7 +101,7 @@ function NewDao({ selectedAddress, createDao }) { }, [selectedAddress]); const [hints, setHints] = useState({ - name: { shown: false, type: "error", message: "" }, + name: { shown: false, type: "info", message: "" }, description: { shown: false, type: "error", message: "" }, website: { shown: false, type: "error", message: "" }, votingPeriod: { shown: false, type: "error", message: "" }, @@ -116,10 +116,32 @@ function NewDao({ selectedAddress, createDao }) { const sanitizedNameTest = new RegExp(/[^\w.-]/g); const updateFormData = (field, value) => { - setFormData((prev) => ({ - ...prev, - [field]: value, - })); + setFormData((prev) => { + const newData = { ...prev, [field]: value }; + + // Special handling for name field + if (field === "name") { + if (sanitizedNameTest.test(value)) { + setHints((prevHints) => ({ + ...prevHints, + name: { + type: "info", + shown: true, + message: + "Your DAO would be named as " + + value.replace(sanitizedNameTest, "-"), + }, + })); + } else { + setHints((prevHints) => ({ + ...prevHints, + name: { shown: false, type: "info", message: "" }, + })); + } + } + + return newData; + }); }; const addMember = () => { @@ -186,6 +208,7 @@ function NewDao({ selectedAddress, createDao }) { value={formData.name} setValue={(v) => updateFormData("name", v)} hint={hints.name} + helperText="Only letters, numbers, dots, and hyphens are allowed. Other characters will be converted to hyphens." /> Voting Power Distribution -
+
Date: Wed, 4 Dec 2024 19:26:17 +0700 Subject: [PATCH 03/47] fix overflow of voting chart in new.js --- pages/account/daos/new.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/account/daos/new.js b/pages/account/daos/new.js index 6cd250a6..f152f699 100644 --- a/pages/account/daos/new.js +++ b/pages/account/daos/new.js @@ -444,7 +444,7 @@ function NewDao({ selectedAddress, createDao }) {

Voting Power Distribution

-
+
Date: Thu, 5 Dec 2024 02:13:25 +0700 Subject: [PATCH 04/47] don't show proposals tab in user profile --- components/dashboard/publicTabs.js | 52 ++++++++++++++++-------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/components/dashboard/publicTabs.js b/components/dashboard/publicTabs.js index f1d0b205..2d373357 100644 --- a/components/dashboard/publicTabs.js +++ b/components/dashboard/publicTabs.js @@ -60,32 +60,34 @@ export default function PublicTabs({ ) : null} {showPeople ? ( - - - - - People - - ) : null} + <> + + + + + People + - - - - - Proposals - + + + + + Proposals + + + ) : null} {showProposal ? ( Date: Thu, 5 Dec 2024 02:34:37 +0700 Subject: [PATCH 05/47] show treasury balance upto two decimal places only --- components/account/DaoTreasuryStats.js | 8 ++++++-- components/account/daoHeader.js | 1 - components/repository/supportOwner.js | 9 +++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/components/account/DaoTreasuryStats.js b/components/account/DaoTreasuryStats.js index 8cd942bc..3ece2022 100644 --- a/components/account/DaoTreasuryStats.js +++ b/components/account/DaoTreasuryStats.js @@ -14,8 +14,12 @@ function DaoTreasuryStats({ dao, className = "", getBalance, advanceUser }) { const balance = await getBalance(cosmosBankApiClient, dao.address); setTreasuryBalance( advanceUser === true - ? balance + " " + process.env.NEXT_PUBLIC_ADVANCE_CURRENCY_TOKEN - : balance / 1000000 + " " + process.env.NEXT_PUBLIC_CURRENCY_TOKEN + ? balance.toFixed(2) + + " " + + process.env.NEXT_PUBLIC_ADVANCE_CURRENCY_TOKEN + : (balance / 1000000).toFixed(2) + + " " + + process.env.NEXT_PUBLIC_CURRENCY_TOKEN ); } initBalance(); diff --git a/components/account/daoHeader.js b/components/account/daoHeader.js index ba47c37f..b611f882 100644 --- a/components/account/daoHeader.js +++ b/components/account/daoHeader.js @@ -117,7 +117,6 @@ function AccountDaoHeader(props) { )}
- {/* Add the treasury stats component */} ); diff --git a/components/repository/supportOwner.js b/components/repository/supportOwner.js index e6f600a5..3aa70c68 100644 --- a/components/repository/supportOwner.js +++ b/components/repository/supportOwner.js @@ -53,10 +53,15 @@ function SupportOwner({ repository, ownerAddress, isMobile, ...props }) { useEffect(() => { async function initBalance() { const balance = await props.getBalance(cosmosBankApiClient, ownerAddress); + // In the initBalance function inside useEffect setOwnerBalance( props.advanceUser === true - ? balance + " " + process.env.NEXT_PUBLIC_ADVANCE_CURRENCY_TOKEN - : balance / 1000000 + " " + process.env.NEXT_PUBLIC_CURRENCY_TOKEN + ? balance.toFixed(2) + + " " + + process.env.NEXT_PUBLIC_ADVANCE_CURRENCY_TOKEN + : (balance / 1000000).toFixed(2) + + " " + + process.env.NEXT_PUBLIC_CURRENCY_TOKEN ); } initBalance(); From ac09b34287db38466997ebec4cf91bcafdf500f9 Mon Sep 17 00:00:00 2001 From: faza Date: Thu, 5 Dec 2024 03:14:54 +0700 Subject: [PATCH 06/47] don't re-render header everytime we switch tab --- pages/[userId]/index.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/pages/[userId]/index.js b/pages/[userId]/index.js index 8f0cf56c..6dc7fbad 100644 --- a/pages/[userId]/index.js +++ b/pages/[userId]/index.js @@ -1,6 +1,6 @@ import Head from "next/head"; import Header from "../../components/header"; -import { useEffect, useState, useCallback } from "react"; +import { useEffect, useState, useCallback, useMemo } from "react"; import { connect } from "react-redux"; import { useRouter } from "next/router"; import Footer from "../../components/footer"; @@ -129,7 +129,6 @@ function AccountView({ const hrefBase = `/${router.query.userId}`; const checkMembership = async (daoData) => { - console.log(selectedAddress, daoData.group_id); if (!selectedAddress || !daoData.group_id) return; try { const members = await getGroupMembers( @@ -189,14 +188,14 @@ function AccountView({ setIsLoading(false); } }, - [router, apiClient, setErrorStatusCode] + [apiClient, setErrorStatusCode, router.query.userId, selectedAddress] ); useEffect(() => { getId(); }, [getId]); - const renderContent = () => { + const content = useMemo(() => { const { tab, id } = router.query; switch (tab) { case "repositories": @@ -228,7 +227,14 @@ function AccountView({ /> ); } - }; + }, [ + router.query.tab, + router.query.id, + user, + dao, + allRepos, + router.query.userId, + ]); const title = user.id ? user.username || user.creator : dao.name; @@ -249,13 +255,11 @@ function AccountView({ ) : ( <> {dao.address ? ( - <> - - + ) : ( )} @@ -270,7 +274,7 @@ function AccountView({ } />
- {renderContent()} + {content} )} From d4f74c1e627a988feb6ec91e6d377a4d834c6353 Mon Sep 17 00:00:00 2001 From: faza Date: Thu, 5 Dec 2024 03:53:43 +0700 Subject: [PATCH 07/47] show link to parent repo in case of fork repo --- components/repository/header.js | 112 ++++++++++++++++++++++---------- 1 file changed, 78 insertions(+), 34 deletions(-) diff --git a/components/repository/header.js b/components/repository/header.js index 3c3d4469..08368a05 100644 --- a/components/repository/header.js +++ b/components/repository/header.js @@ -7,11 +7,12 @@ import { Trash2, User, Users, + GitBranch, } from "lucide-react"; import { useRouter } from "next/router"; import shrinkAddress from "../../helpers/shrinkAddress"; -import getDao from "../../helpers/getDao"; import { useApiClient } from "../../context/ApiClientContext"; +import getRepositoryById from "../../helpers/getRepositoryById"; import DAOProtectionBadge from "./DaoProtectionBadge"; const OwnershipBadge = ({ type }) => { @@ -32,6 +33,43 @@ const OwnershipBadge = ({ type }) => { ); }; +const ForkParentInfo = ({ parentId }) => { + const [parentRepo, setParentRepo] = useState(null); + const { apiClient } = useApiClient(); + + useEffect(() => { + async function fetchParentRepo() { + try { + const parentRepo = await getRepositoryById(apiClient, parentId); + setParentRepo(parentRepo); + } catch (error) { + console.error("Error fetching parent repository:", error); + } + } + + if (parentId) { + fetchParentRepo(); + } + }, [parentId, apiClient]); + + if (!parentRepo) return null; + + return ( +
+ + Forked from + + {shrinkAddress(parentRepo.owner.id)} + / + {parentRepo.name} + +
+ ); +}; + const RepositoryHeader = ({ repository, daoData, selectedAddress }) => { const [forkTargetShown, setForkTargetShown] = useState(false); const [branchCount, setBranchCount] = useState(0); @@ -86,45 +124,51 @@ const RepositoryHeader = ({ repository, daoData, selectedAddress }) => {
-
-

-
- {isDAORepository ? ( - - ) : ( - - )} +
+
+

+
+ {isDAORepository ? ( + + ) : ( + + )} + + {shrinkAddress(repository.owner.id)} + +
+ / - {shrinkAddress(repository.owner.id)} + {repository.name} -

- / - - {repository.name} - -

-
+ +
-
- - {isDAORepository && daoData && ( - - )} - {repository.fork && ( -
- -
+ {repository.fork && repository.parent && ( + )} + +
+ + {isDAORepository && daoData && ( + + )} + {repository.fork && ( +
+ +
+ )} +
From befd8c5d03f34fdf8b3a020d9913bba36a0e1e5f Mon Sep 17 00:00:00 2001 From: faza Date: Thu, 5 Dec 2024 04:03:03 +0700 Subject: [PATCH 08/47] chore: update changelog --- CHANGELOG.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25258db5..3b12e651 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ ## Changelog +### Unreleased + +- Don't show proposals tab in user profile +- Show treasury balance upto two decimal places only +- Don't re-render header everytime we switch tab +- Show link to parent repo in case of fork repo + +### v3.1.0 - 2nd Dec 2024 + +- Add button for Member Dashboard in public view (if member) and public view in Member dashboard +- Improve the dao dashboard and some other minor improvements +- Fix overflow of voting chart in dao creation step +- Sanitize dao names before posting the transaction + +### v3.0.0 - 2nd Dec 2024 + +- Implement the new dao creation and proposal workflows + ### v2.2.2 - 3rd Sep 2024 - Fix missing apiClient in getUser and getRepository methods From de02092f7d9af9749357d67e92701c3f992ae462 Mon Sep 17 00:00:00 2001 From: faza Date: Tue, 3 Jun 2025 15:48:53 +0530 Subject: [PATCH 09/47] Remove AccountGrants component and related authorization functionalities from the project. This includes the deletion of associated helper functions and their references in the dashboard and settings pages. --- components/account/grants.js | 17 ----- components/dashboard/dao.js | 8 -- components/repository/mergePullRequestView.js | 11 --- .../toggleGitServerAuthorization.js | 76 ------------------- .../toggleStorageBridgeAuthorization.js | 76 ------------------- helpers/getGitServerAuthStatus.js | 17 ----- helpers/getStorageBridgeAuthStatus.js | 22 ------ pages/settings/index.js | 13 ---- 8 files changed, 240 deletions(-) delete mode 100644 components/account/grants.js delete mode 100644 components/repository/toggleGitServerAuthorization.js delete mode 100644 components/repository/toggleStorageBridgeAuthorization.js delete mode 100644 helpers/getGitServerAuthStatus.js delete mode 100644 helpers/getStorageBridgeAuthStatus.js diff --git a/components/account/grants.js b/components/account/grants.js deleted file mode 100644 index 62fdfd73..00000000 --- a/components/account/grants.js +++ /dev/null @@ -1,17 +0,0 @@ -import ToggleStorageBridgeAuthorization from "../repository/toggleStorageBridgeAuthorization"; -import ToggleGitServerAuthorization from "../repository/toggleGitServerAuthorization"; - -function AccountGrants({ address, ...props }) { - return ( -
-
- -
-
- -
-
- ); -} - -export default AccountGrants; diff --git a/components/dashboard/dao.js b/components/dashboard/dao.js index 00f0fd79..26ad2783 100644 --- a/components/dashboard/dao.js +++ b/components/dashboard/dao.js @@ -3,7 +3,6 @@ import Link from "next/link"; import { connect, useDispatch } from "react-redux"; import DAOMembersList from "./DAOMembersList"; import { createGroupProposal } from "../../store/actions/dao"; -import AccountGrants from "../account/grants"; import GreetDao from "../greetDao"; import { useApiClient } from "../../context/ApiClientContext"; import getGroupInfo from "../../helpers/getGroupInfo"; @@ -373,13 +372,6 @@ function DaoDashboard({ dao = {}, advanceUser, ...props }) { onRefreshProposals={fetchProposals} /> ); - case "authorizations": - return ( -
-

Authorizations

- -
- ); default: return null; } diff --git a/components/repository/mergePullRequestView.js b/components/repository/mergePullRequestView.js index 9a90bf5f..12086e27 100644 --- a/components/repository/mergePullRequestView.js +++ b/components/repository/mergePullRequestView.js @@ -10,7 +10,6 @@ import { import pullRequestStateClass from "../../helpers/pullRequestStateClass"; import mergePullRequestCheck from "../../helpers/mergePullRequestCheck"; import getPullRequestMergePermission from "../../helpers/getPullRequestMergePermission"; -import getGitServerAuthorization from "../../helpers/getGitServerAuthStatus"; import getDao from "../../helpers/getDao"; import { useApiClient } from "../../context/ApiClientContext"; import { useRouter } from "next/router"; @@ -135,16 +134,6 @@ function MergePullRequestView({ ); if (user && user.havePermission) { - let access = await getGitServerAuthorization( - apiClient, - props.selectedAddress - ); - if (!access) { - setPullMergeAccessDialogShown(true); - setIsMerging(false); - return; - } - const res = await props.mergePullRequest( apiClient, cosmosBankApiClient, diff --git a/components/repository/toggleGitServerAuthorization.js b/components/repository/toggleGitServerAuthorization.js deleted file mode 100644 index 3bda903a..00000000 --- a/components/repository/toggleGitServerAuthorization.js +++ /dev/null @@ -1,76 +0,0 @@ -import { useEffect, useState } from "react"; -import { connect } from "react-redux"; -import { updateAddressGrant } from "../../store/actions/user"; -import getGitServerAuthStatus from "../../helpers/getGitServerAuthStatus"; -import { useApiClient } from "../../context/ApiClientContext"; - -function ToggleGitServerAuthorization({ address, onSuccess, ...props }) { - const [currentState, setCurrentState] = useState(false); - const [isToggling, setIsToggling] = useState(true); - const { apiClient, cosmosBankApiClient, cosmosFeeegrantApiClient } = - useApiClient(); - - const toggleGrant = async () => { - setIsToggling(true); - const res = await props.updateAddressGrant( - apiClient, - cosmosBankApiClient, - cosmosFeeegrantApiClient, - address, - 0, - !currentState - ); - if (res && res.code === 0) { - if (onSuccess) await onSuccess(!currentState); - setCurrentState(!currentState); - } - setIsToggling(false); - }; - - useEffect(() => { - async function initAddress() { - setIsToggling(true); - setCurrentState(await getGitServerAuthStatus(apiClient, address)); - setIsToggling(false); - } - initAddress(); - }, [address]); - - return ( - - ); -} - -const mapStateToProps = (state) => { - return { - selectedAddress: state.wallet.selectedAddress, - }; -}; - -export default connect(mapStateToProps, { updateAddressGrant })( - ToggleGitServerAuthorization -); diff --git a/components/repository/toggleStorageBridgeAuthorization.js b/components/repository/toggleStorageBridgeAuthorization.js deleted file mode 100644 index d87f1102..00000000 --- a/components/repository/toggleStorageBridgeAuthorization.js +++ /dev/null @@ -1,76 +0,0 @@ -import { useEffect, useState } from "react"; -import { connect } from "react-redux"; -import { updateAddressGrant } from "../../store/actions/user"; -import getStorageBridgeAuthStatus from "../../helpers/getStorageBridgeAuthStatus"; -import { useApiClient } from "../../context/ApiClientContext"; - -function ToggleStorageBridgeAuthorization({ address, onSuccess, ...props }) { - const [currentState, setCurrentState] = useState(false); - const [isToggling, setIsToggling] = useState(true); - const { apiClient, cosmosBankApiClient, cosmosFeegrantApiClient } = - useApiClient(); - - const toggleGrant = async () => { - setIsToggling(true); - const res = await props.updateAddressGrant( - apiClient, - cosmosBankApiClient, - cosmosFeegrantApiClient, - address, - 1, - !currentState - ); - if (res && res.code === 0) { - if (onSuccess) await onSuccess(!currentState); - setCurrentState(!currentState); - } - setIsToggling(false); - }; - - useEffect(() => { - async function initAddress() { - setIsToggling(true); - setCurrentState(await getStorageBridgeAuthStatus(apiClient, address)); - setIsToggling(false); - } - initAddress(); - }, [address]); - - return ( - - ); -} - -const mapStateToProps = (state) => { - return { - selectedAddress: state.wallet.selectedAddress, - }; -}; - -export default connect(mapStateToProps, { updateAddressGrant })( - ToggleStorageBridgeAuthorization -); diff --git a/helpers/getGitServerAuthStatus.js b/helpers/getGitServerAuthStatus.js deleted file mode 100644 index a01edb57..00000000 --- a/helpers/getGitServerAuthStatus.js +++ /dev/null @@ -1,17 +0,0 @@ -export default async function getGitServerAuthStatus(apiClient, userAddress) { - if (!userAddress) return null; - try { - const res = await apiClient.queryCheckGitServerAuthorization( - userAddress, - process.env.NEXT_PUBLIC_GIT_SERVER_WALLET_ADDRESS - ); - if (res.status === 200 && res.data.haveAuthorization) { - return true; - } else { - return false; - } - } catch (e) { - console.error(e); - return null; - } -} diff --git a/helpers/getStorageBridgeAuthStatus.js b/helpers/getStorageBridgeAuthStatus.js deleted file mode 100644 index 9dfecd77..00000000 --- a/helpers/getStorageBridgeAuthStatus.js +++ /dev/null @@ -1,22 +0,0 @@ -import { useApiClient } from "../context/ApiClientContext"; - -export default async function getStorageBridgeAuthStatus( - apiClient, - userAddress -) { - if (!userAddress) return null; - try { - const res = await apiClient.queryCheckStorageProviderAuthorization( - userAddress, - process.env.NEXT_PUBLIC_STORAGE_BRIDGE_WALLET_ADDRESS - ); - if (res.status === 200 && res.data.haveAuthorization) { - return true; - } else { - return false; - } - } catch (e) { - console.error(e); - return null; - } -} diff --git a/pages/settings/index.js b/pages/settings/index.js index 9a7b95ad..f417a25b 100644 --- a/pages/settings/index.js +++ b/pages/settings/index.js @@ -2,7 +2,6 @@ import Head from "next/head"; import Header from "../../components/header"; import { connect } from "react-redux"; import Footer from "../../components/footer"; -import AccountGrants from "../../components/account/grants"; import Link from "next/link"; export async function getStaticProps() { @@ -48,18 +47,6 @@ function AccountView(props) {
{props.user.creator}
-
-
-
- Authorizations -
- - -
-
From c5c55be52bee688087ad167f0b50796f88a5d8a9 Mon Sep 17 00:00:00 2001 From: faza Date: Fri, 6 Jun 2025 03:52:09 +0530 Subject: [PATCH 10/47] Implement new fork workflow - Use the new fork message - Remove fork merge access dialogs and related state management. - Update repository view to pass selected address to the header component. --- components/repository/mergePullRequestView.js | 65 --------------- pages/[userId]/[repositoryId]/fork.js | 83 +------------------ pages/[userId]/[repositoryId]/index.js | 6 +- store/actions/repository.js | 19 +---- 4 files changed, 8 insertions(+), 165 deletions(-) diff --git a/components/repository/mergePullRequestView.js b/components/repository/mergePullRequestView.js index 12086e27..c4e9220c 100644 --- a/components/repository/mergePullRequestView.js +++ b/components/repository/mergePullRequestView.js @@ -24,10 +24,6 @@ function MergePullRequestView({ const [stateClass, setStateClass] = useState(""); const [iconType, setIconType] = useState("check"); const [message, setMessage] = useState(""); - const [pullMergeAccess, setPullMergeAccess] = useState(false); - const [pullMergeAccessDialogShown, setPullMergeAccessDialogShown] = - useState(false); - const [isGrantingAccess, setIsGrantingAccess] = useState(false); const [requiresProposal, setRequiresProposal] = useState(false); const [isCreatingProposal, setIsCreatingProposal] = useState(false); const { @@ -172,17 +168,6 @@ function MergePullRequestView({ } }, [pullRequest, props.selectedAddress, requiresProposal]); - const refreshPullMergeAccess = async (mergeAfter = false) => { - setPullMergeAccess( - await getGitServerAuthorization(apiClient, props.selectedAddress) - ); - if (mergeAfter) setTimeout(mergePull, 0); - }; - - useEffect(() => { - refreshPullMergeAccess(); - }, [props.selectedAddress]); - const getMergeButtonText = () => { if (isCreatingProposal) return "Creating Proposal..."; if (isMerging) return "Merging..."; @@ -273,56 +258,6 @@ function MergePullRequestView({
)}
- - -
-
-

- Gitopia data server does not have repository merge access on behalf - of your account. -

-

Server Address:

-

- {process.env.NEXT_PUBLIC_GIT_SERVER_WALLET_ADDRESS} -

-
- - -
-
-
); } diff --git a/pages/[userId]/[repositoryId]/fork.js b/pages/[userId]/[repositoryId]/fork.js index ad212e2d..fcf6b03c 100644 --- a/pages/[userId]/[repositoryId]/fork.js +++ b/pages/[userId]/[repositoryId]/fork.js @@ -12,10 +12,8 @@ import useRepository from "../../../hooks/useRepository"; import TextInput from "../../../components/textInput"; import { forkRepository, - authorizeGitServer, } from "../../../store/actions/repository"; import { useRouter } from "next/router"; -import getGitServerAuthorization from "../../../helpers/getGitServerAuthStatus"; import { useApiClient } from "../../../context/ApiClientContext"; export async function getStaticProps() { @@ -63,9 +61,6 @@ function RepositoryInvokeForkView(props) { ); const [isForking, setIsForking] = useState(false); const [forkingSuccess, setForkingSuccess] = useState(false); - const [forkingAccess, setForkingAccess] = useState(false); - const [grantAccessDialogShown, setGrantAccessDialogShown] = useState(false); - const [isGrantingAccess, setIsGrantingAccess] = useState(false); const sanitizedNameTest = new RegExp(/[^\w.-]/g); const router = useRouter(); @@ -125,14 +120,6 @@ function RepositoryInvokeForkView(props) { }; const invokeForkRepository = async () => { - let forkingAccess = await getGitServerAuthorization( - apiClient, - props.selectedAddress - ); - if (!forkingAccess) { - setGrantAccessDialogShown(true); - return; - } setIsForking(true); let validate = await validateRepository(); console.log(validate); @@ -163,11 +150,7 @@ function RepositoryInvokeForkView(props) { useEffect(() => { setForkRepositoryName(repository?.name || ""); setForkRepositoryDescription(repository?.description || ""); - if (repository?.owner?.address === props.currentDashboard) { - setOwnerId(""); - } else { - setOwnerId(props.currentDashboard); - } + setOwnerId(props.currentDashboard); setForkOnlyOneBranchName(repository?.defaultBranch); }, [repository, props.currentDashboard]); @@ -358,68 +341,6 @@ function RepositoryInvokeForkView(props) {
- -
-
-

- Gitopia data server does not have repository forking access on - behalf of your account. -

-

Server Address:

-

- {process.env.NEXT_PUBLIC_GIT_SERVER_WALLET_ADDRESS} -

-
- - -
-
-