From de02092f7d9af9749357d67e92701c3f992ae462 Mon Sep 17 00:00:00 2001 From: faza Date: Tue, 3 Jun 2025 15:48:53 +0530 Subject: [PATCH 01/16] 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 -
- - -
-