Skip to content

Commit

Permalink
Merge branch 'information-architecture' into nv-3455-settings-brandin…
Browse files Browse the repository at this point in the history
…g-page
  • Loading branch information
BiswaViraj authored Apr 16, 2024
2 parents 58581a0 + c3e200c commit e96469e
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 29 deletions.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,11 @@
"runtimes",
"cafebabe",
"Markunread",
"limitbar",
"Fira",
"Roboto",
"Raleway"
"Icann",
"limitbar"
],
"flagWords": [],
"patterns": [
Expand Down
24 changes: 0 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,30 +108,6 @@ jobs:
if: ${{ contains(fromJson(needs.get-affected.outputs.test-cypress), '@novu/widget') || contains(fromJson(needs.get-affected.outputs.test-unit), '@novu/notification-center') || contains(fromJson(needs.get-affected.outputs.test-unit), '@novu/ws') }}
secrets: inherit

build_docker_api:
name: Build Docker API
runs-on: ubuntu-latest
timeout-minutes: 80
needs: [get-affected]
if: ${{ contains(fromJson(needs.get-affected.outputs.test-e2e), '@novu/api') }}
permissions:
contents: read
packages: write
deployments: write
id-token: write
strategy:
matrix:
name: ['novu/api', 'novu/api-ee']
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-project
- uses: ./.github/actions/setup-redis-cluster
- uses: ./.github/actions/docker/build-api
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
fork: ${{ github.event.pull_request.head.repo.fork }}
docker_name: ${{ matrix.name }}

test_providers:
name: Unit Test Providers
runs-on: ubuntu-latest
Expand Down
15 changes: 11 additions & 4 deletions apps/web/src/pages/auth/components/QuestionnaireForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { JobTitleEnum, jobTitleToLabelMapper, ProductUseCasesEnum } from '@novu/
import type { ProductUseCases, IResponseError, ICreateOrganizationDto, IJwtPayload } from '@novu/shared';
import {
Button,
colors,
Digest,
HalfClock,
Input,
Expand All @@ -27,18 +26,21 @@ import { ROUTES } from '../../../constants/routes.enum';
import { DynamicCheckBox } from './dynamic-checkbox/DynamicCheckBox';
import styled from '@emotion/styled/macro';
import { OnboardingExperimentV2ModalKey } from '../../../constants/experimentsConstants';
import { useDomainParser } from './useDomainHook';

export function QuestionnaireForm() {
const [loading, setLoading] = useState<boolean>();
const {
handleSubmit,
formState: { errors },
control,
setError,
} = useForm<IOrganizationCreateForm>({});
const navigate = useNavigate();
const { setToken, token } = useAuthContext();
const { startVercelSetup } = useVercelIntegration();
const { isFromVercel } = useVercelParams();
const { parse } = useDomainParser();

const { mutateAsync: createOrganizationMutation } = useMutation<
{ _id: string },
Expand Down Expand Up @@ -162,9 +164,14 @@ export function QuestionnaireForm() {
name="domain"
control={control}
rules={{
pattern: {
value: /^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$/,
message: 'Please make sure you specified a valid domain',
validate: {
isValiDomain: (value) => {
const val = parse(value as string);

if (value && !val.isIcann) {
return 'Please provide a valid domain';
}
},
},
}}
render={({ field }) => {
Expand Down
62 changes: 62 additions & 0 deletions apps/web/src/pages/auth/components/useDomainHook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { useCallback, useEffect, useRef } from 'react';

interface DomainInfo {
domain: string;
domainWithoutSuffix: string;
hostname: string;
isIcann: boolean;
isIp: boolean;
isPrivate: boolean;
publicSuffix: string;
subdomain: string;
}

function stripProtocol(url: string): string {
return (url || '').replace(/(https?)?(:\/+)?/, '');
}

function fallbackParser(url: string) {
const parts = stripProtocol(url).split('.');

if (parts.length > 2) {
const [subdomain, ...domainParts] = parts;

return {
subdomain: subdomain || '',
domain: domainParts.join('.'),
};
}

return {
subdomain: '',
domain: url,
};
}

export function useDomainParser(): { parse: (url: string) => Partial<DomainInfo> } {
const tldParser = useRef(null);

useEffect(() => {
import(
/* webpackIgnore: true */
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line import/extensions
'https://unpkg.com/tldts/dist/es6/index.js?module'
)
.then((mod) => (tldParser.current = mod))
.catch(() => (tldParser.current = null));
}, []);

const parse = useCallback((url: string) => {
url = stripProtocol(url);

if (tldParser.current) {
return (tldParser.current as any).parse(url, { allowPrivateDomains: true }) as DomainInfo;
}

return fallbackParser(url);
}, []);

return { parse };
}
2 changes: 2 additions & 0 deletions libs/dal/src/repositories/organization/organization.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export class OrganizationEntity implements IOrganizationEntity {
createdAt: string;

updatedAt: string;

externalId?: string;
}

export type OrganizationDBModel = OrganizationEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const organizationSchema = new Schema<OrganizationDBModel>(
default: false,
},
},
externalId: Schema.Types.String,
},
schemaOptions
);
Expand Down
2 changes: 2 additions & 0 deletions libs/dal/src/repositories/user/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export class UserEntity {
servicesHashes?: { intercom?: string };

jobTitle?: JobTitleEnum;

externalId?: string;
}

export type UserDBModel = UserEntity;
1 change: 1 addition & 0 deletions libs/dal/src/repositories/user/user.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const userSchema = new Schema<UserDBModel>(
intercom: Schema.Types.String,
},
jobTitle: Schema.Types.String,
externalId: Schema.Types.String,
},
schemaOptions
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ export interface IOrganizationEntity {
productUseCases?: ProductUseCases;
createdAt: string;
updatedAt: string;
externalId?: string;
}
1 change: 1 addition & 0 deletions libs/shared/src/entities/user/user.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ export interface IUpdateUserProfile {
firstName: string;
lastName: string;
profilePicture?: string;
externalId?: string;
}

0 comments on commit e96469e

Please sign in to comment.