Skip to content

Commit

Permalink
Merge branch 'main' into fix-github-configurator
Browse files Browse the repository at this point in the history
  • Loading branch information
Megha-Dev-19 committed Dec 18, 2023
2 parents a5e4fee + 218a120 commit d4d4f92
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 41 deletions.
10 changes: 4 additions & 6 deletions playwright-tests/tests/community.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { test, expect } from "@playwright/test";

test("should load a community page if handle exists", async ({ page }) => {
await page.goto(
"/devgovgigs.near/widget/app?page=community&handle=devhub-test"
);
await page.goto("/devhub.near/widget/app?page=community&handle=devhub-test");

// Using the <Link> that wraps the tabs to identify a community page loaded
const communityTabSelector = `a[href^="/devgovgigs.near/widget/app?page=community&handle=devhub-test&tab="]`;
const communityTabSelector = `a[href^="/devhub.near/widget/app?page=community&handle=devhub-test&tab="]`;

// Wait for the tab to be visible
await page.waitForSelector(communityTabSelector, {
Expand Down Expand Up @@ -44,7 +42,7 @@ test.describe("Wallet is connected", () => {
page,
}) => {
await page.goto(
"/devgovgigs.near/widget/app?page=community&handle=devhub-test"
"/devhub.near/widget/app?page=community&handle=devhub-test"
);

const postButtonSelector = 'a:has-text("Post")';
Expand All @@ -61,7 +59,7 @@ test.describe("Wallet is connected", () => {

// Verify that the URL is the expected one.
expect(page.url()).toBe(
"http://localhost:8080/devgovgigs.near/widget/app?page=create&labels=devhub-test"
"http://localhost:8080/devhub.near/widget/app?page=create&labels=devhub-test"
);

// Wait for the Typeahead field to render.
Expand Down
59 changes: 32 additions & 27 deletions src/devhub/entity/addon/telegram/Viewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,39 @@ if (!handles || handles.length === 0) {
} else {
return (
<div>
{(handles || []).map((tg) => (
<>
<iframe
iframeResizer
src={
"https://j96g3uepe0.execute-api.us-east-1.amazonaws.com/groups-ui/" +
tg
}
frameborder="0"
// width and minWidth required by iframeResizer
style={{
width: "1px",
minWidth: "100%",
marginTop: "20px",
}}
></iframe>

<a href={"https://t.me/" + tg} target="_blank">
<Widget
src={"${REPL_DEVHUB}/widget/devhub.components.molecule.Button"}
props={{
classNames: { root: "btn-primary" },
label: "View More",
{(handles || []).map((tg) => {
const pattern = /https:\/\/t.me\/(.*)/;
const includesHttp = tg.match(pattern);
const handle = includesHttp ? includesHttp[1] : tg;
return (
<>
<iframe
iframeResizer
src={
"https://j96g3uepe0.execute-api.us-east-1.amazonaws.com/groups-ui/" +
handle
}
frameborder="0"
// width and minWidth required by iframeResizer
style={{
width: "1px",
minWidth: "100%",
marginTop: "20px",
}}
/>
</a>
</>
))}
></iframe>

<a href={includesHttp ? tg : "https://t.me/" + tg} target="_blank">
<Widget
src={"${REPL_DEVHUB}/widget/devhub.components.molecule.Button"}
props={{
classNames: { root: "btn-primary" },
label: "View More",
}}
/>
</a>
</>
);
})}
</div>
);
}
24 changes: 17 additions & 7 deletions src/devhub/page/community/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ function trimHttps(url) {
return url;
}

// some communties have url as handle (eg: devhub platform) while others has correct handle
function checkTelegramHandle(tg) {
const pattern = /https:\/\/t.me\/(.*)/;
const includesHttp = tg.match(pattern);
const handle = includesHttp ? includesHttp[1] : tg;
return { handle, url: "https://t.me/" + handle };
}

const socialLinks = [
...((community.website_url?.length ?? 0) > 0
? [
Expand Down Expand Up @@ -141,13 +149,15 @@ const socialLinks = [
]
: []),

// ...(community.telegram_handle.length > 0
// ? community.telegram_handle.map((telegram_handle) => ({
// href: `https://t.me/${telegram_handle}`,
// iconClass: "bi bi-telegram",
// name: telegram_handle,
// }))
// : []),
...(community.telegram_handle?.length > 0
? [
{
href: checkTelegramHandle(community.telegram_handle).url,
iconClass: "bi bi-telegram",
name: checkTelegramHandle(community.telegram_handle).handle,
},
]
: []),
];

const NavlinksContainer = styled.div`
Expand Down
6 changes: 5 additions & 1 deletion src/devhub/page/create.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ State.init({
seekingFunding: false,
author_id: context.accountId,
// Should be a list of objects with field "name".
labels,
labels: [],
// Should be a list of labels as strings.
// Both of the label structures should be modified together.
labelStrings: [],
Expand Down Expand Up @@ -96,6 +96,10 @@ const labels = labelStrings.map((s) => {
return { name: s };
});

State.update({
labels,
});

if (state.waitForDraftStateRestore) {
const draftstatestring = Storage.privateGet(DRAFT_STATE_STORAGE_KEY);
if (draftstatestring != null) {
Expand Down

0 comments on commit d4d4f92

Please sign in to comment.