Skip to content

Commit

Permalink
fix: Syncpolaris update some query mutation and permission names (#5070)
Browse files Browse the repository at this point in the history
  • Loading branch information
hitchikermn committed Mar 18, 2024
1 parent 2fb5a2a commit fb084ad
Show file tree
Hide file tree
Showing 17 changed files with 80 additions and 80 deletions.
@@ -1,13 +1,13 @@
import customScalars from '@erxes/api-utils/src/customScalars';
import syncHistories from './queries/syncHistories';
import syncHistoriesPolaris from './queries/syncHistoriesPolaris';
import SyncHistory from './syncLog';
import syncMutations from './mutations/syncData';
import checkMutations from './mutations/checkSynced';
const resolvers: any = async (_serviceDiscovery) => ({
...customScalars,
SyncHistory,
Query: {
...syncHistories,
...syncHistoriesPolaris,
},

Mutation: {
Expand Down
Expand Up @@ -8,7 +8,7 @@ import {
} from '../../../utils/toSyncUtils/utils';

const checkMutations = {
async toCheck(_root, { type }: { type: string }, { subdomain }: IContext) {
async toCheckPolaris(_root, { type }: { type: string }, { subdomain }: IContext) {
const config = await getConfig(subdomain, 'POLARIS', {});

if (!config.token) {
Expand Down
Expand Up @@ -7,7 +7,7 @@ import {
} from '../../../utils/toSyncUtils/utils';

const syncmutations = {
async toSync(
async toSyncPolaris(
_root,
{ items, type }: { items: any[]; type: string },
{ subdomain }: IContext,
Expand Down
Expand Up @@ -58,13 +58,13 @@ const generateFilter = (params) => {
return query;
};

const erkhetQueries = {
async syncHistories(_root, params, { models }: IContext) {
const polarisQueries = {
async syncHistoriesPolaris(_root, params, { models }: IContext) {
const selector = generateFilter(params);
return paginate(models.SyncLogs.find(selector), params);
},

async syncHistoriesCount(_root, params, { models }: IContext) {
async syncHistoriesCountPolaris(_root, params, { models }: IContext) {
const selector = generateFilter(params);
return models.SyncLogs.find(selector).count();
},
Expand All @@ -89,4 +89,4 @@ const erkhetQueries = {
},
};

export default erkhetQueries;
export default polarisQueries;
@@ -1,4 +1,4 @@
export const mutations = `
toCheck(type: String): JSON
toSync( items: [JSON],type: String): JSON
toCheckPolaris(type: String): JSON
toSyncPolaris( items: [JSON],type: String): JSON
`;
4 changes: 2 additions & 2 deletions packages/plugin-syncpolaris-api/src/graphql/schema/queries.ts
Expand Up @@ -20,7 +20,7 @@ const polarisData = `
`;

export const queries = `
syncHistories(${commonHistoryParams}): [SyncHistory]
syncHistoriesCount(${commonHistoryParams}): Int
syncHistoriesPolaris(${commonHistoryParams}): [SyncHistory]
syncHistoriesCountPolaris(${commonHistoryParams}): Int
getPolarisData(${polarisData}): JSON
`;
2 changes: 1 addition & 1 deletion packages/plugin-syncpolaris-api/src/graphql/schema/type.ts
Expand Up @@ -26,7 +26,7 @@ export const types = `
syncedCustomer: String
}
type erkhetRemainder {
type polarisRemainder {
_id: String!
remainder: Int
remainders: [JSON]
Expand Down
10 changes: 5 additions & 5 deletions packages/plugin-syncpolaris-api/src/permissions.js
@@ -1,11 +1,11 @@
module.exports = {
syncerkhet: {
name: "erkhet",
description: "Erkhet",
syncpolaris: {
name: "polaris",
description: "Polaris",
actions: [
{
name: "syncErkhetConfig",
description: "Manage erkhet config",
name: "syncPolarisConfig",
description: "Manage polaris config",
},
],
},
Expand Down
16 changes: 8 additions & 8 deletions packages/plugin-syncpolaris-ui/src/graphql/mutations.ts
@@ -1,18 +1,18 @@
// Settings

const toCheck = `
mutation toCheck($type: String) {
toCheck(type: $type)
const toCheckPolaris = `
mutation toCheckPolaris($type: String) {
toCheckPolaris(type: $type)
}
`;

const toSync = `
mutation toSync($type: String, $items: [JSON]) {
toSync(type: $type, items: $items)
const toSyncPolaris = `
mutation toSyncPolaris($type: String, $items: [JSON]) {
toSyncPolaris(type: $type, items: $items)
}
`;

export default {
toCheck,
toSync,
toCheckPolaris,
toSyncPolaris,
};
16 changes: 8 additions & 8 deletions packages/plugin-syncpolaris-ui/src/graphql/queries.ts
Expand Up @@ -35,11 +35,11 @@ const commonHistoryParamDefs = `
searchError: $searchError,
`;

const syncHistories = `
query syncHistories(
const syncHistoriesPolaris = `
query syncHistoriesPolaris(
${commonHistoryParams}
) {
syncHistories (
syncHistoriesPolaris (
${commonHistoryParamDefs}
) {
_id
Expand All @@ -61,18 +61,18 @@ const syncHistories = `
}
`;

const syncHistoriesCount = `
query syncHistoriesCount(
const syncHistoriesCountPolaris = `
query syncHistoriesCountPolaris(
${commonHistoryParams}
) {
syncHistoriesCount (
syncHistoriesCountPolaris (
${commonHistoryParamDefs}
)
}
`;

export default {
configs,
syncHistories,
syncHistoriesCount,
syncHistoriesPolaris,
syncHistoriesCountPolaris,
};
Expand Up @@ -6,13 +6,13 @@ import Row from './Row';
import { Table, Wrapper } from '@erxes/ui/src';

type Props = {
toSync: (type: string, items: any[]) => void;
toSyncPolaris: (type: string, items: any[]) => void;
items;
toggleAll: (targets: any[], containerId: string) => void;
bulk: any[];
toggleBulk: (targets: any[], toAdd: boolean) => void;
emptyBulk: () => void;
toCheck: (type: string) => void;
toCheckPolaris: (type: string) => void;
isAllSelected: boolean;
type;
tablehead;
Expand All @@ -26,10 +26,10 @@ const TypeForm = (props: Props) => {
toggleAll(items, 'customers');
};
const onClickSync = (e) => {
const { toSync, toCheck, emptyBulk, type } = props;
toSync(type, bulk);
const { toSyncPolaris, toCheckPolaris, emptyBulk, type } = props;
toSyncPolaris(type, bulk);
emptyBulk();
toCheck(type);
toCheckPolaris(type);
e.preventDefault();
};

Expand Down
20 changes: 10 additions & 10 deletions packages/plugin-syncpolaris-ui/src/syncPolaris/components/List.tsx
Expand Up @@ -16,13 +16,13 @@ import { Title } from '@erxes/ui-settings/src/styles';
import dayjs from 'dayjs';
import Form from './Form';
interface IProps extends IRouterProps {
toSync: (type: string, items: any[]) => void;
syncHistories: any[];
toSyncPolaris: (type: string, items: any[]) => void;
syncHistoriesPolaris: any[];
loading: boolean;
totalCount: number;
history: any;
queryParams: any;
toCheck: (type: string) => void;
toCheckPolaris: (type: string) => void;
items: any;
contentType;
}
Expand All @@ -31,13 +31,13 @@ class List extends React.Component<IProps> {
render() {
const {
history,
syncHistories,
syncHistoriesPolaris,
totalCount,
loading,
queryParams,
items,
toSync,
toCheck,
toSyncPolaris,
toCheckPolaris,
contentType,
} = this.props;
const formHead: any[] = [];
Expand All @@ -46,7 +46,7 @@ class List extends React.Component<IProps> {
? formHead.push('Code', 'Last name', 'Firs Name', 'Phones')
: formHead.push('Number', 'Status', 'Start Date', 'End Date');
const onClickCheck = () => {
toCheck(contentType);
toCheckPolaris(contentType);
};
let checkButton: React.ReactNode;
if (
Expand Down Expand Up @@ -75,7 +75,7 @@ class List extends React.Component<IProps> {
</tr>
</thead>
<tbody id="syncPolaris">
{(syncHistories || []).map((syncHistory) => (
{(syncHistoriesPolaris || []).map((syncHistory) => (
<tr key={syncHistory._id}>
<td>{dayjs(syncHistory.createdAt).format('lll')}</td>
<td>
Expand Down Expand Up @@ -103,8 +103,8 @@ class List extends React.Component<IProps> {
return (
<Form
items={items}
toCheck={toCheck}
toSync={toSync}
toCheckPolaris={toCheckPolaris}
toSyncPolaris={toSyncPolaris}
type={contentType}
tablehead={formHead}
{...props}
Expand Down
32 changes: 16 additions & 16 deletions packages/plugin-syncpolaris-ui/src/syncPolaris/containers/List.tsx
Expand Up @@ -50,13 +50,13 @@ class CustomerContainer extends React.Component<FinalProps, State> {
} = this.props;
const { items } = this.state;

const toCheck = (type: string) => {
const toCheckPolaris = (type: string) => {
this.setState({ loading: true });
this.props
.toCheck({ variables: { type } })
.toCheckPolaris({ variables: { type } })
.then((response) => {
this.setState({
items: response.data.toCheck.results.items || [],
items: response.data.toCheckPolaris.results.items || [],
});
this.setState({ loading: false });
})
Expand All @@ -66,10 +66,10 @@ class CustomerContainer extends React.Component<FinalProps, State> {
});
};

const toSync = (type: string, items: any[]) => {
const toSyncPolaris = (type: string, items: any[]) => {
this.setState({ loading: true });
this.props
.toSync({
.toSyncPolaris({
variables: {
type,
items,
Expand All @@ -85,14 +85,14 @@ class CustomerContainer extends React.Component<FinalProps, State> {
});
};

const syncHistories = syncHistoriesQuery.syncHistories || [];
const totalCount = syncHistoriesCountQuery.syncHistoriesCount || 0;
const syncHistoriesPolaris = syncHistoriesQuery.syncHistoriesPolaris || [];
const totalCount = syncHistoriesCountQuery.syncHistoriesCountPolaris || 0;
const updatedProps = {
...this.props,
queryParams,
toCheck,
toSync,
syncHistories,
toCheckPolaris,
toSyncPolaris,
syncHistoriesPolaris,
totalCount,
items,
contentType,
Expand Down Expand Up @@ -123,15 +123,15 @@ const generateParams = ({ queryParams }, { contentType }) => {

export default withProps<Props>(
compose(
graphql<Props, SyncHistoriesQueryResponse, {}>(gql(queries.syncHistories), {
graphql<Props, SyncHistoriesQueryResponse, {}>(gql(queries.syncHistoriesPolaris), {
name: 'syncHistoriesQuery',
options: ({ queryParams, contentType }) => ({
variables: generateParams({ queryParams }, { contentType }),
fetchPolicy: 'network-only',
}),
}),
graphql<Props, SyncHistoriesCountQueryResponse, {}>(
gql(queries.syncHistoriesCount),
gql(queries.syncHistoriesCountPolaris),
{
name: 'syncHistoriesCountQuery',
options: ({ queryParams, contentType }) => ({
Expand All @@ -140,11 +140,11 @@ export default withProps<Props>(
}),
},
),
graphql<Props, ToCheckMutationResponse, {}>(gql(mutations.toCheck), {
name: 'toCheck',
graphql<Props, ToCheckMutationResponse, {}>(gql(mutations.toCheckPolaris), {
name: 'toCheckPolaris',
}),
graphql<Props, ToSyncMutationResponse, {}>(gql(mutations.toSync), {
name: 'toSync',
graphql<Props, ToSyncMutationResponse, {}>(gql(mutations.toSyncPolaris), {
name: 'toSyncPolaris',
}),
)(CustomerContainer),
);
Expand Up @@ -7,15 +7,15 @@ import SyncHistorySidebar from './syncHistorySidebar';
import { Title } from '@erxes/ui-settings/src/styles';

interface IProps extends IRouterProps {
syncHistories: any[];
syncHistoriesPolaris: any[];
loading: boolean;
totalCount: number;
history: any;
queryParams: any;
}
class SyncHistoryList extends React.Component<IProps> {
render() {
const { history, syncHistories, totalCount, loading, queryParams } =
const { history, syncHistoriesPolaris, totalCount, loading, queryParams } =
this.props;

const tablehead = ['Date', 'User', 'Content Type', 'Content', 'Error'];
Expand All @@ -30,7 +30,7 @@ class SyncHistoryList extends React.Component<IProps> {
</tr>
</thead>
<tbody id="SyncHistories">
{(syncHistories || []).map((item) => (
{(syncHistoriesPolaris || []).map((item) => (
<tr key={item._id}>
<td>{dayjs(item.createdAt).format('lll')}</td>
<td>{item.createdUser?.email}</td>
Expand Down

0 comments on commit fb084ad

Please sign in to comment.