Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Commit

Permalink
Merge branch 'dev' of github.com:erxes/erxes into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
nandinboldn committed Oct 17, 2023
2 parents 0f6c759 + 0af0d0b commit 2f99d1a
Show file tree
Hide file tree
Showing 84 changed files with 2,300 additions and 404 deletions.
10 changes: 7 additions & 3 deletions cypress/tests/contacts/ui/company.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { CLIENT_RENEG_LIMIT } = require("tls");

describe("Contacts", () => {
beforeEach(() => {
cy.exec('yarn run cypress:seedDB').wait(300);
Cypress.Cookies.debug(true);
cy.visit('/');
cy.clearCookies();
Expand All @@ -14,6 +15,9 @@ describe("Contacts", () => {
const random = Math.random().toString(36).slice(2)

it("add company", () => {
const seed = cy.exec('yarn run cypress:seedDB').wait(300);

console.log(seed);

cy.get('i[icon = "plus-circle"]', { timeout: 300000 }).click();

Expand All @@ -31,7 +35,7 @@ describe("Contacts", () => {
.click();
})

it("set tag company", () => {
it.skip("set tag company", () => {

cy.get("#companiesCheckBox",{ timeout: 300000 }).eq(0).click();

Expand All @@ -46,7 +50,7 @@ describe("Contacts", () => {
cy.get('button[icon="tag-alt"]').click();
})

it("remove company", () => {
it.skip("remove company", () => {

cy.contains(random, { timeout: 300000 })
.parent()
Expand Down
29 changes: 3 additions & 26 deletions cypress/tests/contacts/ui/lead.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("Lead", () => {
.visit("/contacts/lead").wait(300);
});

it("add1", () => {
it("add", () => {

const random = Math.random().toString(36).slice(2)

Expand All @@ -34,30 +34,7 @@ describe("Lead", () => {
}
})

it("add2", () => {

const random2 = Math.random().toString(36).slice(2)

cy.get('button[icon="plus-circle"]',{timeout:300000}).click();

cy.get('input[name="firstName"]').type(random2);

cy.get("div .Select-placeholder")
.contains("Enter an email")
.click()
.type(random2 + "@nmma.co");
cy.waitAndClick("div.Select-menu-outer");

cy.get('button[type="submit"]')
.eq(0)
.click();
if(cy.get('button[type="submit"]')){
cy.get('button[class="close"]')
.click()
}
})

it("tag", () => {
it.skip("tag", () => {

cy.get("#customers>.crow",{timeout: 300000})
.eq(0)
Expand All @@ -80,7 +57,7 @@ describe("Lead", () => {
}
})

it("merge", () => {
it.skip("merge", () => {

cy.get("#customers>.crow",{timeout: 300000})
.eq(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function LeftSidebar({
loadingMainQuery: boolean;
}) {
return (
<Sidebar hasBorder>
<Sidebar hasBorder={true}>
<BranchList />
<DepartmentList />
<UnitList />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react';

import BlockList from '../common/BlockList';
import { EmptyState } from '@erxes/ui/src/components';
import Form from '../../containers/branch/Form';
import Item from '../../containers/branch/Item';
import React from 'react';
import { generateTree } from '../../utils';
import BlockList from '../common/BlockList';
import { EmptyState } from '@erxes/ui/src/components';

type Props = {
listQuery: any;
Expand All @@ -14,8 +13,8 @@ export default function List({ listQuery }: Props) {
const allBranches = listQuery.data.branches || [];

const renderChildren = parentId => {
if(allBranches.length === 0){
return <EmptyState icon="ban" text="No branches" size="small" />
if (allBranches.length === 0) {
return <EmptyState icon="ban" text="No branches" size="small" />;
}

return generateTree(allBranches, parentId, (node, level) => (
Expand All @@ -36,7 +35,7 @@ export default function List({ listQuery }: Props) {
<BlockList
allDatas={allBranches}
renderForm={renderForm}
renderItems={renderChildren(null)}
renderItems={renderChildren('')}
title="Branch"
/>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react';

import Box from '@erxes/ui/src/components/Box';
import { SidebarList } from '@erxes/ui/src/layout/styles';
import Icon from '@erxes/ui/src/components/Icon';
import { __ } from 'modules/common/utils';
import ModalTrigger from '@erxes/ui/src/components/ModalTrigger';
import React from 'react';
import { SidebarList } from '@erxes/ui/src/layout/styles';
import { __ } from 'modules/common/utils';

type Props = {
allDatas: any[];
Expand Down Expand Up @@ -38,7 +37,7 @@ export default function BlockList(props: Props) {
extraButtons={extraButtons}
collapsible={allDatas.length > 6}
>
<SidebarList noTextColor noBackground className="no-link">
<SidebarList noTextColor={true} noBackground={true} className="no-link">
{renderItems}
</SidebarList>
</Box>
Expand Down
6 changes: 1 addition & 5 deletions packages/core-ui/src/modules/settings/team/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ export const generateTree = (
level = -1,
parentKey = 'parentId'
) => {
const filtered = list.filter(
c =>
c[parentKey] === parentId ||
(parentId === null && (!c[parentKey] || c[parentKey] === c._id))
);
const filtered = list.filter(c => c[parentKey] === parentId);

if (filtered.length > 0) {
level++;
Expand Down
131 changes: 67 additions & 64 deletions packages/core/src/apolloClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,81 @@ export const initApolloServer = async (app, httpServer) => {
}
]),
// for graceful shutdowns
plugins: [ApolloServerPluginDrainHttpServer({ httpServer })],
plugins: [ApolloServerPluginDrainHttpServer({ httpServer })]
});

await apolloServer.start();

app.use('/graphql', expressMiddleware(apolloServer, {
context: async ({ req, res }) => {
const subdomain = getSubdomain(req);
const models = await generateModels(subdomain);
app.use(
'/graphql',
expressMiddleware(apolloServer, {
context: async ({ req, res }) => {
const subdomain = getSubdomain(req);
const models = await generateModels(subdomain);

let user: any = null;
let user: any = null;

if (req.headers.user) {
const userJson = Buffer.from(req.headers.user, 'base64').toString(
'utf-8'
);
user = JSON.parse(userJson);
}
if (req.headers.user) {
const userJson = Buffer.from(req.headers.user, 'base64').toString(
'utf-8'
);
user = JSON.parse(userJson);
}

const dataLoaders: IDataLoaders = generateAllDataLoaders(models);

const requestInfo = {
secure: req.secure,
cookies: req.cookies
};

const dataLoaders: IDataLoaders = generateAllDataLoaders(models);
if (USE_BRAND_RESTRICTIONS !== 'true') {
return {
brandIdSelector: {},
singleBrandIdSelector: {},
userBrandIdsSelector: {},
docModifier: doc => doc,
commonQuerySelector: {},
user,
res,
requestInfo,
dataLoaders,
subdomain,
models
};
}

const requestInfo = {
secure: req.secure,
cookies: req.cookies
};
let scopeBrandIds = JSON.parse(req.cookies.scopeBrandIds || '[]');
let brandIds = [];
let brandIdSelector = {};
let commonQuerySelector = {};
let commonQuerySelectorElk;
let userBrandIdsSelector = {};
let singleBrandIdSelector = {};

if (user) {
brandIds = user.brandIds || [];

if (scopeBrandIds.length === 0) {
scopeBrandIds = brandIds;
}

if (!user.isOwner && scopeBrandIds.length > 0) {
brandIdSelector = { _id: { $in: scopeBrandIds } };
commonQuerySelector = { scopeBrandIds: { $in: scopeBrandIds } };
commonQuerySelectorElk = { terms: { scopeBrandIds } };
userBrandIdsSelector = { brandIds: { $in: scopeBrandIds } };
singleBrandIdSelector = { brandId: { $in: scopeBrandIds } };
}
}

if (USE_BRAND_RESTRICTIONS !== 'true') {
return {
brandIdSelector: {},
singleBrandIdSelector: {},
userBrandIdsSelector: {},
docModifier: doc => doc,
commonQuerySelector: {},
brandIdSelector,
singleBrandIdSelector,
docModifier: doc => ({ ...doc, scopeBrandIds }),
commonQuerySelector,
commonQuerySelectorElk,
userBrandIdsSelector,
user,
res,
requestInfo,
Expand All @@ -79,47 +121,8 @@ export const initApolloServer = async (app, httpServer) => {
models
};
}

let scopeBrandIds = JSON.parse(req.cookies.scopeBrandIds || '[]');
let brandIds = [];
let brandIdSelector = {};
let commonQuerySelector = {};
let commonQuerySelectorElk;
let userBrandIdsSelector = {};
let singleBrandIdSelector = {};

if (user) {
brandIds = user.brandIds || [];

if (scopeBrandIds.length === 0) {
scopeBrandIds = brandIds;
}

if (!user.isOwner && scopeBrandIds.length > 0) {
brandIdSelector = { _id: { $in: scopeBrandIds } };
commonQuerySelector = { scopeBrandIds: { $in: scopeBrandIds } };
commonQuerySelectorElk = { terms: { scopeBrandIds } };
userBrandIdsSelector = { brandIds: { $in: scopeBrandIds } };
singleBrandIdSelector = { brandId: { $in: scopeBrandIds } };
}
}

return {
brandIdSelector,
singleBrandIdSelector,
docModifier: doc => ({ ...doc, scopeBrandIds }),
commonQuerySelector,
commonQuerySelectorElk,
userBrandIdsSelector,
user,
res,
requestInfo,
dataLoaders,
subdomain,
models
};
}
}));
})
);

return apolloServer;
};
Expand Down
28 changes: 19 additions & 9 deletions packages/core/src/data/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,24 @@ export const createTransporter = async ({ ses }, models?: IModels) => {

export const uploadsFolderPath = path.join(__dirname, '../private/uploads');

export const initFirebase = async (models: IModels): Promise<void> => {
const config = await models.Configs.findOne({
code: 'GOOGLE_APPLICATION_CREDENTIALS_JSON'
});
export const initFirebase = async (
models: IModels,
customConfig?: string
): Promise<void> => {
let codeString = 'value';

if (!config) {
return;
}
if (customConfig) {
codeString = customConfig;
} else {
const config = await models.Configs.findOne({
code: 'GOOGLE_APPLICATION_CREDENTIALS_JSON'
});

const codeString = config.value || 'value';
if (!config) {
return;
}
codeString = config.value;
}

if (codeString[0] === '{' && codeString[codeString.length - 1] === '}') {
const serviceAccount = JSON.parse(codeString);
Expand Down Expand Up @@ -1287,12 +1295,14 @@ export const configReplacer = config => {
export const sendMobileNotification = async (
models: IModels,
{
customConfig,
receivers,
title,
body,
deviceTokens,
data
}: {
customConfig: string;
receivers: string[];
title: string;
body: string;
Expand All @@ -1301,7 +1311,7 @@ export const sendMobileNotification = async (
}
): Promise<void> => {
if (!admin.apps.length) {
await initFirebase(models);
await initFirebase(models, customConfig);
}

const transporter = admin.messaging();
Expand Down
Loading

0 comments on commit 2f99d1a

Please sign in to comment.