From 223d0c893f9761f89227b4f261e96f508a98970c Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 27 Oct 2024 03:58:42 -0500 Subject: [PATCH] Refactor: similar files between portals (#916) * refactor: remove duplicate components and core files from events-committee and refer to devhub * fix: DropDownWithSearch path * fix: another broken link * refactor: similar events molecules * fmt --------- Co-authored-by: Peter Salomonsen --- .../components/molecule/MarkdownEditor.jsx | 14 --- .../devhub/components/molecule/SimpleMDE.jsx | 7 +- .../devhub/entity/addon/blog/editor/form.jsx | 2 +- .../devhub/entity/addon/wiki/Configurator.jsx | 2 +- .../widget/devhub/entity/post/PostEditor.jsx | 2 +- .../devhub/components/molecule/DropDown.jsx | 60 ---------- .../components/molecule/MarkdownEditor.jsx | 14 --- .../components/molecule/MarkdownViewer.jsx | 60 ---------- .../components/molecule/ProfileCard.jsx | 109 ------------------ .../components/molecule/ProfileLine.jsx | 21 ---- .../devhub/components/organism/Navbar.jsx | 2 +- .../widget/devhub/entity/proposal/Editor.jsx | 2 +- .../devhub/entity/proposal/Proposal.jsx | 2 +- .../devhub/page/admin/moderatorsTab.jsx | 2 +- .../aliases.mainnet.json | 3 +- .../widget/components/molecule/SimpleMDE.jsx | 4 +- .../widget/core/common.jsx | 2 +- 17 files changed, 15 insertions(+), 293 deletions(-) delete mode 100644 instances/devhub.near/widget/devhub/components/molecule/MarkdownEditor.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/molecule/DropDown.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/molecule/MarkdownEditor.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/molecule/MarkdownViewer.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/molecule/ProfileCard.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/molecule/ProfileLine.jsx diff --git a/instances/devhub.near/widget/devhub/components/molecule/MarkdownEditor.jsx b/instances/devhub.near/widget/devhub/components/molecule/MarkdownEditor.jsx deleted file mode 100644 index 15fc31152..000000000 --- a/instances/devhub.near/widget/devhub/components/molecule/MarkdownEditor.jsx +++ /dev/null @@ -1,14 +0,0 @@ -const MarkdownEditor = ({ data, onChange, showAutoComplete }) => { - return ( - - ); -}; - -return MarkdownEditor(props); diff --git a/instances/devhub.near/widget/devhub/components/molecule/SimpleMDE.jsx b/instances/devhub.near/widget/devhub/components/molecule/SimpleMDE.jsx index e8c8998ae..aa4a9a04e 100644 --- a/instances/devhub.near/widget/devhub/components/molecule/SimpleMDE.jsx +++ b/instances/devhub.near/widget/devhub/components/molecule/SimpleMDE.jsx @@ -30,8 +30,7 @@ const showAccountAutoComplete = props.showAutoComplete ?? false; const showProposalIdAutoComplete = props.showProposalIdAutoComplete ?? false; const autoFocus = props.autoFocus ?? false; -const queryName = - "polyprogrammist_near_devhub_prod_v1_proposals_with_latest_snapshot"; +const queryName = "${REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME}"; const query = `query GetLatestSnapshot($offset: Int = 0, $limit: Int = 10, $where: ${queryName}_bool_exp = {}) { ${queryName}( offset: $offset @@ -236,7 +235,7 @@ async function getSuggestedProposals(id) { } await asyncFetch("https://near-queryapi.api.pagoda.co/v1/graphql", { method: "POST", - headers: { "x-hasura-role": "polyprogrammist_near" }, + headers: { "x-hasura-role": "${REPL_INDEXER_HASURA_ROLE}" }, body: JSON.stringify({ query: query, variables: variables, @@ -246,7 +245,7 @@ async function getSuggestedProposals(id) { .then((res) => { const proposals = res?.data?.[ - "polyprogrammist_near_devhub_prod_v1_proposals_with_latest_snapshot" + "${REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME}" ]; results = proposals; }) diff --git a/instances/devhub.near/widget/devhub/entity/addon/blog/editor/form.jsx b/instances/devhub.near/widget/devhub/entity/addon/blog/editor/form.jsx index b215fabae..b9109193c 100644 --- a/instances/devhub.near/widget/devhub/entity/addon/blog/editor/form.jsx +++ b/instances/devhub.near/widget/devhub/entity/addon/blog/editor/form.jsx @@ -141,7 +141,7 @@ const ContentEditor = ({ content, setContent }) => {
Content
diff --git a/instances/devhub.near/widget/devhub/entity/addon/wiki/Configurator.jsx b/instances/devhub.near/widget/devhub/entity/addon/wiki/Configurator.jsx index 75bcb4a30..19674fe67 100644 --- a/instances/devhub.near/widget/devhub/entity/addon/wiki/Configurator.jsx +++ b/instances/devhub.near/widget/devhub/entity/addon/wiki/Configurator.jsx @@ -123,7 +123,7 @@ return ( /> diff --git a/instances/devhub.near/widget/devhub/entity/post/PostEditor.jsx b/instances/devhub.near/widget/devhub/entity/post/PostEditor.jsx index 093558a2a..e01439991 100644 --- a/instances/devhub.near/widget/devhub/entity/post/PostEditor.jsx +++ b/instances/devhub.near/widget/devhub/entity/post/PostEditor.jsx @@ -566,7 +566,7 @@ const callDescriptionDiv = () => { Description { diff --git a/instances/events-committee.near/widget/devhub/components/molecule/DropDown.jsx b/instances/events-committee.near/widget/devhub/components/molecule/DropDown.jsx deleted file mode 100644 index 984ace45d..000000000 --- a/instances/events-committee.near/widget/devhub/components/molecule/DropDown.jsx +++ /dev/null @@ -1,60 +0,0 @@ -const options = props.options; // [{label:"",value:""}] -const label = props.label; -const onUpdate = props.onUpdate ?? (() => {}); -const selectedValue = props.selectedValue; -const [selected, setSelected] = useState(selectedValue); - -const StyledDropdown = styled.div` - .drop-btn { - width: 100%; - max-width: 200px; - text-align: left; - padding-inline: 10px; - } - - .dropdown-item.active, - .dropdown-item:active { - background-color: #f0f0f0 !important; - color: black; - } - - .cursor-pointer { - cursor: pointer; - } -`; - -useEffect(() => { - onUpdate(selected); -}, [selected]); - -return ( -
- -
-); diff --git a/instances/events-committee.near/widget/devhub/components/molecule/MarkdownEditor.jsx b/instances/events-committee.near/widget/devhub/components/molecule/MarkdownEditor.jsx deleted file mode 100644 index 8301f2a3c..000000000 --- a/instances/events-committee.near/widget/devhub/components/molecule/MarkdownEditor.jsx +++ /dev/null @@ -1,14 +0,0 @@ -const MarkdownEditor = ({ data, onChange, showAutoComplete }) => { - return ( - - ); -}; - -return MarkdownEditor(props); diff --git a/instances/events-committee.near/widget/devhub/components/molecule/MarkdownViewer.jsx b/instances/events-committee.near/widget/devhub/components/molecule/MarkdownViewer.jsx deleted file mode 100644 index 631ec7052..000000000 --- a/instances/events-committee.near/widget/devhub/components/molecule/MarkdownViewer.jsx +++ /dev/null @@ -1,60 +0,0 @@ -const Wrapper = styled.div` - p { - white-space: pre-line; // This ensures text breaks to new line - - span { - white-space: normal; // and this ensures profile links look normal - } - } - - blockquote { - margin: 1em 0; - padding-left: 1.5em; - border-left: 4px solid #ccc; - color: #666; - font-style: italic; - font-size: inherit; - } - - pre { - background-color: #f4f4f4; - border: 1px solid #ddd; - border-radius: 4px; - padding: 1em; - overflow-x: auto; - font-family: "Courier New", Courier, monospace; - } - - a { - color: #04a46e; - } -`; - -const Embedded = styled.span` - white-space: normal; - - p { - white-space: normal; - } -`; - -const renderMention = - props.renderMention ?? - ((accountId) => ( - - - - )); - -return ( - - - -); diff --git a/instances/events-committee.near/widget/devhub/components/molecule/ProfileCard.jsx b/instances/events-committee.near/widget/devhub/components/molecule/ProfileCard.jsx deleted file mode 100644 index 7384cd1d2..000000000 --- a/instances/events-committee.near/widget/devhub/components/molecule/ProfileCard.jsx +++ /dev/null @@ -1,109 +0,0 @@ -const MutedText = styled.span` - color: #818181; - - font-size: 16px; - font-style: normal; - font-weight: 400; - line-height: 20px; /* 125% */ -`; - -const AccountName = styled.span` - color: #818181; - font-size: 16px; - font-style: normal; - font-weight: 500; - line-height: 20px; - - max-width: 30ch; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -`; - -const ProfileCard = (props) => { - const accountId = props.accountId ?? context.accountId; - const link = props.link ?? true; - // const hideAccountId = props.hideAccountId; - // const hideName = props.hideName; - const hideImage = props.hideImage; - const iconOnly = props.iconOnly; - const openLinkInNewTab = props.openLinkInNewTab ?? false; - - const profile = props.profile ?? Social.getr(`${accountId}/profile`); - - const name = profile.name ?? accountId; - const title = props.title ?? `${name} @${accountId}`; - const tooltip = - props.tooltip && (props.tooltip === true ? title : props.tooltip); - - let inner = ( -
- {!hideImage && ( - - )} - {!iconOnly && ( -
- {name} - @{accountId} -
- )} -
- ); - - inner = link ? ( - - {inner} - - ) : ( - {inner} - ); - - if (props.tooltip === true) { - return ( - - ); - } - if (tooltip) { - inner = ( - {tooltip}}> - {inner} - - ); - } - return ( -
- {inner} - -
- ); -}; - -return ProfileCard(props); diff --git a/instances/events-committee.near/widget/devhub/components/molecule/ProfileLine.jsx b/instances/events-committee.near/widget/devhub/components/molecule/ProfileLine.jsx deleted file mode 100644 index 4d5cddd34..000000000 --- a/instances/events-committee.near/widget/devhub/components/molecule/ProfileLine.jsx +++ /dev/null @@ -1,21 +0,0 @@ -const accountId = props.accountId ?? context.accountId; - -return ( - - - - -); diff --git a/instances/events-committee.near/widget/devhub/components/organism/Navbar.jsx b/instances/events-committee.near/widget/devhub/components/organism/Navbar.jsx index 0e748036f..d5e3e37c9 100644 --- a/instances/events-committee.near/widget/devhub/components/organism/Navbar.jsx +++ b/instances/events-committee.near/widget/devhub/components/organism/Navbar.jsx @@ -66,7 +66,7 @@ const ProfileIcon = () => { })} > diff --git a/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx b/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx index b5060d8b6..3feb433bc 100644 --- a/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx +++ b/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx @@ -1020,7 +1020,7 @@ const AmountComponent = useMemo(() => { const CurrencyComponent = useMemo(() => { return (
Proposal Status
( diff --git a/instances/infrastructure-committee.near/aliases.mainnet.json b/instances/infrastructure-committee.near/aliases.mainnet.json index a26f38ef0..0a6c6b158 100644 --- a/instances/infrastructure-committee.near/aliases.mainnet.json +++ b/instances/infrastructure-committee.near/aliases.mainnet.json @@ -8,5 +8,6 @@ "REPL_RFP_FEED_INDEXER_QUERY_NAME": "polyprogrammist_near_devhub_ic_v1_rfps_with_latest_snapshot", "REPL_RFP_INDEXER_QUERY_NAME": "polyprogrammist_near_devhub_ic_v1_rfp_snapshots", "REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME": "polyprogrammist_near_devhub_ic_v1_proposals_with_latest_snapshot", - "REPL_PROPOSAL_QUERY_NAME": "polyprogrammist_near_devhub_ic_v1_proposal_snapshots" + "REPL_PROPOSAL_QUERY_NAME": "polyprogrammist_near_devhub_ic_v1_proposal_snapshots", + "REPL_INDEXER_HASURA_ROLE": "polyprogrammist_near" } diff --git a/instances/infrastructure-committee.near/widget/components/molecule/SimpleMDE.jsx b/instances/infrastructure-committee.near/widget/components/molecule/SimpleMDE.jsx index 8a9111ec1..38bf504b2 100644 --- a/instances/infrastructure-committee.near/widget/components/molecule/SimpleMDE.jsx +++ b/instances/infrastructure-committee.near/widget/components/molecule/SimpleMDE.jsx @@ -258,7 +258,7 @@ async function getSuggestedRfps(id) { } await asyncFetch("https://near-queryapi.api.pagoda.co/v1/graphql", { method: "POST", - headers: { "x-hasura-role": "polyprogrammist_near" }, + headers: { "x-hasura-role": "${REPL_INDEXER_HASURA_ROLE}" }, body: JSON.stringify({ query: rfpQuery, variables: variables, @@ -301,7 +301,7 @@ async function getSuggestedProposals(id) { } await asyncFetch("https://near-queryapi.api.pagoda.co/v1/graphql", { method: "POST", - headers: { "x-hasura-role": "polyprogrammist_near" }, + headers: { "x-hasura-role": "${REPL_INDEXER_HASURA_ROLE}" }, body: JSON.stringify({ query: proposalQuery, variables: variables, diff --git a/instances/infrastructure-committee.near/widget/core/common.jsx b/instances/infrastructure-committee.near/widget/core/common.jsx index f8898a50e..bbea09369 100644 --- a/instances/infrastructure-committee.near/widget/core/common.jsx +++ b/instances/infrastructure-committee.near/widget/core/common.jsx @@ -21,7 +21,7 @@ const QUERYAPI_ENDPOINT = `https://near-queryapi.api.pagoda.co/v1/graphql`; async function fetchGraphQL(operationsDoc, operationName, variables) { return asyncFetch(QUERYAPI_ENDPOINT, { method: "POST", - headers: { "x-hasura-role": `polyprogrammist_near` }, + headers: { "x-hasura-role": "${REPL_INDEXER_HASURA_ROLE}" }, body: JSON.stringify({ query: operationsDoc, variables: variables,