Skip to content

Commit

Permalink
Merge pull request #10230 from hicommonwealth/release/v1.7.5-x
Browse files Browse the repository at this point in the history
Release/v1.7.5 x
  • Loading branch information
ilijabojanovic authored Dec 11, 2024
2 parents 5bfb2d5 + ce1572a commit d4e537f
Show file tree
Hide file tree
Showing 42 changed files with 129 additions and 84 deletions.
4 changes: 2 additions & 2 deletions libs/model/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { configure, config as target } from '@hicommonwealth/core';
import { S3_ASSET_BUCKET_CDN } from '@hicommonwealth/shared';
import { z } from 'zod';

const {
Expand Down Expand Up @@ -48,8 +49,7 @@ const DEFAULTS = {
ADDRESS_TOKEN_EXPIRES_IN: '10',
PRIVATE_KEY: '',
DATABASE_URL: `postgresql://commonwealth:edgeware@localhost/${NAME}`,
DEFAULT_COMMONWEALTH_LOGO:
'https://s3.amazonaws.com/assets.commonwealth.im/common-white.png',
DEFAULT_COMMONWEALTH_LOGO: `https://s3.amazonaws.com/${S3_ASSET_BUCKET_CDN}/common-white.png`,
MEMBERSHIP_REFRESH_BATCH_SIZE: '1000',
MEMBERSHIP_REFRESH_TTL_SECONDS: '120',
};
Expand Down
14 changes: 8 additions & 6 deletions libs/model/src/utils/defaultAvatar.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { S3_ASSET_BUCKET_CDN } from '@hicommonwealth/shared';

const defaultAvatars: string[] = [
'https://assets.commonwealth.im/fb3289b0-38cb-4883-908b-7af0c1626ece.png',
'https://assets.commonwealth.im/794bb7a3-17d7-407a-b52e-2987501221b5.png',
'https://assets.commonwealth.im/181e25ad-ce08-427d-8d3a-d290af3be44b.png',
'https://assets.commonwealth.im/9f40b221-e2c7-4052-a7de-e580222baaa9.png',
'https://assets.commonwealth.im/ef919936-8554-42e5-8590-118e8cb68101.png',
'https://assets.commonwealth.im/0847e7f5-4d96-4406-8f30-c3082fa2f27c.png',
`https://${S3_ASSET_BUCKET_CDN}/fb3289b0-38cb-4883-908b-7af0c1626ece.png`,
`https://${S3_ASSET_BUCKET_CDN}/794bb7a3-17d7-407a-b52e-2987501221b5.png`,
`https://${S3_ASSET_BUCKET_CDN}/181e25ad-ce08-427d-8d3a-d290af3be44b.png`,
`https://${S3_ASSET_BUCKET_CDN}/9f40b221-e2c7-4052-a7de-e580222baaa9.png`,
`https://${S3_ASSET_BUCKET_CDN}/ef919936-8554-42e5-8590-118e8cb68101.png`,
`https://${S3_ASSET_BUCKET_CDN}/0847e7f5-4d96-4406-8f30-c3082fa2f27c.png`,
];

export function getRandomAvatar(): string {
Expand Down
4 changes: 2 additions & 2 deletions libs/model/src/webhook/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { config } from '@hicommonwealth/model';
import { Community } from '@hicommonwealth/schemas';
import { getDecodedString } from '@hicommonwealth/shared';
import { getDecodedString, PRODUCTION_DOMAIN } from '@hicommonwealth/shared';
import z from 'zod';

export const REGEX_IMAGE =
Expand All @@ -22,7 +22,7 @@ export function getPreviewImageUrl(
if (community.icon_url) {
const previewImageUrl = community.icon_url.match(`^(http|https)://`)
? community.icon_url
: `https://commonwealth.im${community.icon_url}`;
: `https://${PRODUCTION_DOMAIN}${community.icon_url}`;
const previewImageAltText = `${community.name}`;
return { previewImageUrl, previewImageAltText };
}
Expand Down
16 changes: 10 additions & 6 deletions libs/shared/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import {
decodeAddress,
encodeAddress,
} from '@polkadot/util-crypto';
import { S3_ASSET_BUCKET_CDN, S3_RAW_ASSET_BUCKET_DOMAIN } from './constants';
import {
PRODUCTION_DOMAIN,
S3_ASSET_BUCKET_CDN,
S3_RAW_ASSET_BUCKET_DOMAIN,
} from './constants';

/**
* Decamelizes a string
Expand Down Expand Up @@ -70,7 +74,7 @@ export const getThreadUrl = (
// - cannot use config util in libs/shared
// - duplicate found in knock utils
return process.env.NODE_ENV === 'production'
? `https://commonwealth.im${relativePath}`
? `https://${PRODUCTION_DOMAIN}${relativePath}`
: `http://localhost:8080${relativePath}`;
};

Expand All @@ -89,8 +93,8 @@ export function delay(ms: number): Promise<void> {
/**
* Converts an S3 file URL from the raw bucket URL to the Cloudflare CDN format.
* This is most often used in combination with pre-signed S3 upload URLs.
* Ex Input: https://s3.us-east-1.amazonaws.com/assets.commonwealth.im/f2e44ed9-2fb4-4746-8d7a-4a60fcd83b77.png
* Ex Output: https://assets.commonwealth.im/f2e44ed9-2fb4-4746-8d7a-4a60fcd83b77.png
* Ex Input: https://s3.us-east-1.amazonaws.com/${S3_ASSET_BUCKET_CDN}/f2e44ed9-2fb4-4746-8d7a-4a60fcd83b77.png
* Ex Output: https://${S3_ASSET_BUCKET_CDN}/f2e44ed9-2fb4-4746-8d7a-4a60fcd83b77.png
*/
export function formatBucketUrlToAssetCDN(uploadLocation: string) {
if (
Expand All @@ -107,8 +111,8 @@ export function formatBucketUrlToAssetCDN(uploadLocation: string) {
* Converts an S3 file URL from the CDN format to the raw assets bucket URL.
* This function should only be used server side when the raw S3 headers are
* required in the response (CloudFlare truncates headers).
* Ex Input: https://assets.commonwealth.im/f2e44ed9-2fb4-4746-8d7a-4a60fcd83b77.png
* Ex Output: https://s3.us-east-1.amazonaws.com/assets.commonwealth.im/f2e44ed9-2fb4-4746-8d7a-4a60fcd83b77.png
* Ex Input: https://${S3_ASSET_BUCKET_CDN}/f2e44ed9-2fb4-4746-8d7a-4a60fcd83b77.png
* Ex Output: https://s3.us-east-1.amazonaws.com/${S3_ASSET_BUCKET_CDN}/f2e44ed9-2fb4-4746-8d7a-4a60fcd83b77.png
*/
export function formatAssetUrlToS3(uploadLocation: string): string {
if (uploadLocation.includes(S3_RAW_ASSET_BUCKET_DOMAIN)) {
Expand Down
3 changes: 2 additions & 1 deletion libs/shared/test/checkIconSize.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { S3_ASSET_BUCKET_CDN } from '@hicommonwealth/shared';
import { expect } from 'chai';
import { describe, test } from 'vitest';
import { getFileSizeBytes } from '../src/utils';
Expand All @@ -11,7 +12,7 @@ describe('checkIconSize', () => {
// TODO: make this test not require a remote HTTP request?
test('should return the image size', async () => {
const fileSizeBytes = await getFileSizeBytes(
'https://commonwealth-uploads.s3.us-east-2.amazonaws.com/bebbda6b-6b10-4cbd-8839-4fa8d2a0b266.jpg',
`https://${S3_ASSET_BUCKET_CDN}/bebbda6b-6b10-4cbd-8839-4fa8d2a0b266.jpg`,
);
expect(fileSizeBytes).to.equal(14296);
});
Expand Down
4 changes: 2 additions & 2 deletions libs/sitemaps/src/createDatabasePaginator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ThreadInstance,
UserAttributes,
} from '@hicommonwealth/model';
import { getThreadUrl } from '@hicommonwealth/shared';
import { getThreadUrl, PRODUCTION_DOMAIN } from '@hicommonwealth/shared';
import { Op } from 'sequelize';

export interface Link {
Expand Down Expand Up @@ -112,7 +112,7 @@ function createProfilesTableAdapter(): TableAdapter {
return undefined;
}

const url = `https://commonwealth.im/profile/id/${user.id}`;
const url = `https://${PRODUCTION_DOMAIN}/profile/id/${user.id}`;
return {
id: user.id,
url,
Expand Down
5 changes: 2 additions & 3 deletions packages/commonwealth/client/scripts/navigation/helpers.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PRODUCTION_DOMAIN } from '@hicommonwealth/shared';
import React from 'react';
import type { NavigateOptions, To } from 'react-router-dom';
import {
Expand All @@ -9,8 +10,6 @@ import {
import app from 'state';
import { fetchCachedCustomDomain } from 'state/api/configuration';

const PROD_URL = 'https://commonwealth.im';

type NavigateWithParamsProps = {
to: string | ((params: Record<string, string | undefined>) => string);
};
Expand Down Expand Up @@ -116,7 +115,7 @@ export const navigateToCommunity = ({
navigate(path, {}, chain);
} else {
if (isExternalLink) {
window.open(`${PROD_URL}/${chain}${path}`);
window.open(`https://${PRODUCTION_DOMAIN}/${chain}${path}`);
} else {
navigate(path);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/commonwealth/client/scripts/views/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ const LayoutComponent = ({
}
}, [isAddedToHomeScreen, user.isOnPWA, user]);

// If community id was updated ex: `commonwealth.im/{community-id}/**/*`
// redirect to new community id ex: `commonwealth.im/{new-community-id}/**/*`
// If community id was updated ex: `${PRODUCTION_DOMAIN}/{community-id}/**/*`
// redirect to new community id ex: `${PRODUCTION_DOMAIN}/{new-community-id}/**/*`
useNecessaryEffect(() => {
// @ts-expect-error <StrictNullChecks/>
const redirectTo = configurationData?.redirects?.[providedCommunityScope];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { commonProtocol } from '@hicommonwealth/evm-protocols';
import { PRODUCTION_DOMAIN } from '@hicommonwealth/shared';
import NodeInfo from 'models/NodeInfo';
import { fetchCachedNodes } from 'state/api/nodes';

Expand All @@ -11,7 +12,7 @@ export const BLAST_ID = '81457';

const removeTestCosmosNodes = (nodeInfo: NodeInfo): boolean => {
return !(
window.location.hostname.includes('commonwealth.im') &&
window.location.hostname.includes(PRODUCTION_DOMAIN) &&
[
'evmosdevci',
'csdkv1',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PRODUCTION_DOMAIN } from '@hicommonwealth/shared';
import 'Layout.scss';
import React from 'react';
import { Helmet } from 'react-helmet-async';
Expand Down Expand Up @@ -81,7 +82,7 @@ const defaultMeta = {
},
'twitter:image': {
name: 'twitter:image',
content: 'https://commonwealth.im/img/brand_assets/common.png',
content: `https://${PRODUCTION_DOMAIN}/img/brand_assets/common.png`,
},
'og:type': {
property: 'og:type',
Expand All @@ -93,7 +94,7 @@ const defaultMeta = {
},
'og:url': {
property: 'og:url',
content: 'https://commonwealth.im',
content: `https://${PRODUCTION_DOMAIN}`,
},
'og:title': {
property: 'og:title',
Expand All @@ -105,7 +106,7 @@ const defaultMeta = {
},
'og:image': {
property: 'og:image',
content: 'https://commonwealth.im/img/brand_assets/common.png',
content: `https://${PRODUCTION_DOMAIN}/img/brand_assets/common.png`,
},
} as const;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DEFAULT_NAME } from '@hicommonwealth/shared';
import { DEFAULT_NAME, PRODUCTION_DOMAIN } from '@hicommonwealth/shared';
import 'components/Profile/Profile.scss';
import React, { useEffect, useState } from 'react';
import { Helmet } from 'react-helmet-async';
Expand Down Expand Up @@ -119,7 +119,7 @@ const Profile = ({ userId }: ProfileProps) => {
<Helmet>
<link
rel="canonical"
href={`https://commonwealth.im/profile/id/${userId}`}
href={`https://${PRODUCTION_DOMAIN}/profile/id/${userId}`}
/>
</Helmet>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import MobileSearchModal from 'views/modals/MobileSearchModal';

import useUserMenuItems from '../useUserMenuItems';

import { DOCS_SUBDOMAIN } from '@hicommonwealth/shared';
import useUserStore from 'state/ui/user';
import { AuthModalType } from 'views/modals/AuthModal';
import './MobileHeader.scss';
Expand Down Expand Up @@ -55,7 +56,7 @@ const MobileHeader = ({
},
{
label: 'Help documentation',
onClick: () => window.open('https://docs.commonwealth.im/commonwealth/'),
onClick: () => window.open(`https://${DOCS_SUBDOMAIN}/commonwealth/`),
},
] as PopoverMenuItem[];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PRODUCTION_DOMAIN } from '@hicommonwealth/shared';
import { useBrowserAnalyticsTrack } from 'hooks/useBrowserAnalyticsTrack';
import { useCommonNavigate } from 'navigation/helpers';
import React from 'react';
Expand Down Expand Up @@ -54,7 +55,7 @@ const CWGatedTopicBanner = ({
label: 'Learn more about gating',
onClick: () =>
window.open(
`https://blog.commonwealth.im/introducing-common-groups/`,
`https://blog.${PRODUCTION_DOMAIN}/introducing-common-groups/`,
),
},
]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PermissionEnum } from '@hicommonwealth/schemas';
import { PRODUCTION_DOMAIN } from '@hicommonwealth/shared';
import { useBrowserAnalyticsTrack } from 'hooks/useBrowserAnalyticsTrack';
import { useCommonNavigate } from 'navigation/helpers';
import React from 'react';
Expand Down Expand Up @@ -49,7 +50,7 @@ const CWGatedTopicPermissionLevelBanner = ({
label: 'Learn more about gating',
onClick: () =>
window.open(
`https://blog.commonwealth.im/introducing-common-groups/`,
`https://blog.${PRODUCTION_DOMAIN}/introducing-common-groups/`,
),
},
]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ actual data to be displayed (rowData). These are to be passed in a data structur
emp_count: 1000,
avatars: {
name: {
avatarUrl: 'https://assets.commonwealth.im/f5c5a0c6-0552-40be-bb4b-b25fbd0cfbe2.png',
avatarUrl: `https://${S3_ASSET_BUCKET_CDN}/f5c5a0c6-0552-40be-bb4b-b25fbd0cfbe2.png`,
address: null,
},
},
Expand Down Expand Up @@ -291,11 +291,11 @@ export const CWTable = ({
</span>

{header.column.getCanSort()
? displaySortIcon(
? (displaySortIcon(
header.column.getIsSorted() as string,
// @ts-expect-error <StrictNullChecks/>
header.column.getToggleSortingHandler(),
) ?? null
) ?? null)
: null}
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import React, {

import 'components/react_quill/markdown_formatted_text.scss';

import { PRODUCTION_DOMAIN } from '@hicommonwealth/shared';
import DOMPurify from 'dompurify';
import { loadScript } from 'helpers';
import { twitterLinkRegex } from 'helpers/constants';
Expand All @@ -29,7 +30,7 @@ const markdownRenderer = new marked.Renderer();

markdownRenderer.link = (href, title, text) => {
return `<a ${
href.indexOf('://commonwealth.im/') !== -1 && 'target="_blank"'
href.indexOf(`://${PRODUCTION_DOMAIN}/`) !== -1 && 'target="_blank"'
} ${
OPEN_LINKS_IN_NEW_TAB ? 'target="_blank"' : ''
} href="${href}">${text}</a>`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { TokenView } from '@hicommonwealth/schemas';
import { PRODUCTION_DOMAIN } from '@hicommonwealth/shared';
import 'components/sidebar/CommunitySection/CommunitySection.scss';
import { findDenominationString } from 'helpers/findDenomination';
import { useFlag } from 'hooks/useFlag';
Expand Down Expand Up @@ -146,7 +147,7 @@ export const CommunitySection = ({ showSkeleton }: CommunitySectionProps) => {
<div
className="powered-by"
onClick={() => {
window.open('https://commonwealth.im/');
window.open(`https://${PRODUCTION_DOMAIN}/`);
}}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { ChainBase, ChainNetwork } from '@hicommonwealth/shared';
import {
ChainBase,
ChainNetwork,
PRODUCTION_DOMAIN,
} from '@hicommonwealth/shared';
import { useFlag } from 'hooks/useFlag';
import { uuidv4 } from 'lib/util';
import { useCommonNavigate } from 'navigation/helpers';
Expand Down Expand Up @@ -134,7 +138,7 @@ const getCreateContentMenuItems = (
`${
!isCustomDomain
? window.location.origin
: 'https://commonwealth.im'
: `https://${PRODUCTION_DOMAIN}`
}`,
)}/discord-callback&response_type=code&scope=bot&state=${encodeURI(
JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';

import { DOCS_SUBDOMAIN } from '@hicommonwealth/shared';
import { PopoverMenu } from 'views/components/component_kit/CWPopoverMenu';
import { CWTooltip } from 'views/components/component_kit/new_designs/CWTooltip';
import {
Expand All @@ -17,7 +18,7 @@ export const HelpMenuPopover = () => {
{
label: 'Help documentation',
onClick: () =>
window.open('https://docs.commonwealth.im/commonwealth/'),
window.open(`https://${DOCS_SUBDOMAIN}/commonwealth/`),
},
]}
renderTrigger={(onClick, isMenuOpen) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PRODUCTION_DOMAIN } from '@hicommonwealth/shared';
import { notifyError, notifySuccess } from 'controllers/app/notifications';
import React, { useState } from 'react';
import { slugifyPreserveDashes } from 'shared/utils';
Expand Down Expand Up @@ -76,8 +77,8 @@ const UpdateCommunityIdTask = () => {
<div className="TaskGroup">
<CWText type="h4">Update Community Id</CWText>
<CWText type="caption">
Updates a communities url e.g. commonwealth.im/cmn-protocol to
commonwealth.im/common. This does not update the Community name.
Updates a communities url e.g. ${PRODUCTION_DOMAIN}/cmn-protocol to $
{PRODUCTION_DOMAIN}/common. This does not update the Community name.
WARNING: This will set up a redirect from the old community to the new
community. The old id cannot be used by any other community.
</CWText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { MessageRow } from 'views/components/component_kit/new_designs/CWTextInp
import { openConfirmation } from 'views/modals/confirmation_modal';
import CommunityManagementLayout from 'views/pages/CommunityManagement/common/CommunityManagementLayout';

import { BLOG_SUBDOMAIN } from '@hicommonwealth/shared';
import { CONTEST_FAQ_URL } from '../../../utils';
import {
ContestFeeType,
Expand Down Expand Up @@ -236,7 +237,7 @@ const DetailsFormStep = ({
<>
<CWText className="contest-description">
Your contest is live and the smart contract settings cannot be
changed. <a href="https://blog.commonwealth.im">Learn more</a>
changed. <a href={BLOG_SUBDOMAIN}>Learn more</a>
</CWText>
</>
) : (
Expand Down
Loading

0 comments on commit d4e537f

Please sign in to comment.