Skip to content

Commit 9606f11

Browse files
2 parents 0f0c653 + 084f4a7 commit 9606f11

File tree

674 files changed

+3098
-1636
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

674 files changed

+3098
-1636
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@
2525
/ee/**/lib
2626

2727
.pnpm-lock.yaml
28+
29+
30+
!/server/bundle/**/node_modules

packages/accounts/src/server/accounts-server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { generateAccessToken, generateRefreshToken, generateRandomToken } from '
1717

1818
import { emailTemplates, sendMail } from './utils/email';
1919
import { ServerHooks } from './utils/server-hooks';
20-
2120
import { AccountsServerOptions } from './types/accounts-server-options';
2221
import { JwtData } from './types/jwt-data';
2322
import { EmailTemplateType } from './types/email-template-type';
@@ -271,7 +270,7 @@ export class AccountsServer {
271270
name: user.name,
272271
email: user.email
273272
});
274-
273+
const spaces = await this.db.getMySpaces(user.id);
275274
return {
276275
sessionId,
277276
token,
@@ -280,6 +279,7 @@ export class AccountsServer {
280279
accessToken,
281280
},
282281
space,
282+
spaces,
283283
user,
284284
};
285285
}

packages/accounts/src/types/types/connection-informations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Author: [email protected]
33
* @Date: 2022-03-28 09:35:34
44
* @LastEditors: [email protected]
5-
* @LastEditTime: 2022-06-29 16:05:04
5+
* @LastEditTime: 2022-12-05 09:08:08
66
* @Description:
77
*/
88
export interface ConnectionInformations {

packages/accounts/src/types/types/login-result.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/*
2+
* @Author: [email protected]
3+
* @Date: 2022-08-12 14:07:01
4+
* @LastEditors: [email protected]
5+
* @LastEditTime: 2022-12-05 09:09:03
6+
* @Description:
7+
*/
18
import { Tokens } from './tokens';
29

310
export interface LoginResult {
@@ -6,4 +13,5 @@ export interface LoginResult {
613
tokens: Tokens;
714
user: any;
815
space?: string;
16+
spaces?: Array<any>
917
}

packages/data-import/src/objectImport.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const objectql = require("@steedos/objectql");
55
const Fiber = require("fibers");
66
const moment = require("moment");
77
declare var Creator: any;
8+
const auth = require("@steedos/auth");
9+
declare var TAPi18n;
810

911
type ImportOptions = {
1012
objectName: string;
@@ -783,9 +785,17 @@ export async function importWithExcelFile(file, options) {
783785
}
784786
);
785787
}
786-
let notificationBody = `总共导入${importResult.total_count}条记录;\n成功: ${importResult.success_count}条;\n失败: ${importResult.failure_count};`;
788+
789+
const userSession = await auth.getSessionByUserId(options.userSession.userId);
790+
const locale = userSession?.locale;
791+
const total_count = importResult.total_count;
792+
const success_count = importResult.success_count;
793+
const failure_count = importResult.failure_count;
794+
795+
// let notificationBody = `总共导入${importResult.total_count}条记录;\n成功: ${importResult.success_count}条;\n失败: ${importResult.failure_count};`;
796+
let notificationBody = TAPi18n.__('queue_import_success_notification_body', {returnObjects: true, total_count,success_count,failure_count }, locale);
787797
if (importResult.errorList && importResult.errorList.length > 0) {
788-
notificationBody = `${notificationBody}\n错误信息: ${importResult.errorList.join(
798+
notificationBody = `${notificationBody}\n${TAPi18n.__('queue_import_error_info', {returnObjects: true}, locale)}: ${importResult.errorList.join(
789799
"\n "
790800
)}`;
791801
}
@@ -794,7 +804,7 @@ export async function importWithExcelFile(file, options) {
794804
return Fiber(function() {
795805
Creator.addNotifications(
796806
{
797-
name: `导入完成: ${file.original.name}`,
807+
name: `${TAPi18n.__('queue_import_tips', {returnObjects: true}, locale)}: ${file.original.name}`,
798808
body: notificationBody,
799809
related_to: {
800810
o: "queue_import_history",

packages/objectql/src/services/helpers/graphql/consts.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* @Author: [email protected]
33
* @Date: 2022-06-20 19:02:47
4-
* @LastEditors: sunhaolin@hotoa.com
5-
* @LastEditTime: 2022-10-20 11:25:29
4+
* @LastEditors: baozhoutao@steedos.com
5+
* @LastEditTime: 2022-12-06 09:56:31
66
* @Description:
77
*/
88

@@ -23,4 +23,5 @@ export const EXPAND_SUFFIX = '__expand';
2323
export const DISPLAY_PREFIX = '_display';
2424
export const UI_PREFIX = '_ui';
2525
export const RELATED_PREFIX = '_related';
26-
export const GRAPHQL_ACTION_PREFIX = 'graphql_';
26+
export const GRAPHQL_ACTION_PREFIX = 'graphql_';
27+
export const PERMISSIONS_PREFIX = '_permissions';

packages/objectql/src/services/helpers/graphql/index.ts

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* @Author: [email protected]
33
* @Date: 2022-06-15 15:49:44
4-
* @LastEditors: sunhaolin@hotoa.com
5-
* @LastEditTime: 2022-11-07 20:55:13
4+
* @LastEditors: baozhoutao@steedos.com
5+
* @LastEditTime: 2022-12-06 10:31:30
66
* @Description:
77
*/
88

@@ -17,7 +17,7 @@ import { getSteedosSchema, getUserLocale } from '../../..';
1717
import { getQueryFields } from "./getQueryFields";
1818
import { getPrimaryFieldType } from "./getPrimaryFieldType";
1919

20-
import { BASIC_TYPE_MAPPING, EXPAND_SUFFIX, DISPLAY_PREFIX, RELATED_PREFIX, GRAPHQL_ACTION_PREFIX, UI_PREFIX } from "./consts";
20+
import { BASIC_TYPE_MAPPING, EXPAND_SUFFIX, DISPLAY_PREFIX, RELATED_PREFIX, GRAPHQL_ACTION_PREFIX, UI_PREFIX, PERMISSIONS_PREFIX } from "./consts";
2121

2222
export function generateActionGraphqlProp(actionName: string, objectConfig: SteedosObjectTypeConfig) {
2323
let gplObj: any = {};
@@ -76,6 +76,26 @@ export function generateActionGraphqlProp(actionName: string, objectConfig: Stee
7676
return gplObj;
7777
}
7878

79+
const callObjectServiceAction = async function(actionName, userSession, data?){
80+
const broker = getSteedosSchema().broker;
81+
return broker.call(actionName, data, { meta: { user: userSession}})
82+
}
83+
84+
const formatFileSize = function(fileSize) {
85+
var rev, unit;
86+
rev = fileSize / 1024.00;
87+
unit = 'KB';
88+
if (rev > 1024.00) {
89+
rev = rev / 1024.00;
90+
unit = 'MB';
91+
}
92+
if (rev > 1024.00) {
93+
rev = rev / 1024.00;
94+
unit = 'GB';
95+
}
96+
return rev.toFixed(2) + unit;
97+
};
98+
7999
export function generateSettingsGraphql(objectConfig: SteedosObjectTypeConfig) {
80100
let objectName = objectConfig.name;
81101
let fields = objectConfig.fields;
@@ -194,6 +214,27 @@ export function generateSettingsGraphql(objectConfig: SteedosObjectTypeConfig) {
194214
${type}
195215
`;
196216

217+
// _permissions
218+
let _permissions_type_name = `${PERMISSIONS_PREFIX}_${objectName}`;
219+
type += `${PERMISSIONS_PREFIX}: ${_permissions_type_name} `;
220+
resolvers[objectName][PERMISSIONS_PREFIX] = {
221+
action: `${getObjectServiceName(
222+
objectName
223+
)}.${GRAPHQL_ACTION_PREFIX}${PERMISSIONS_PREFIX}`,
224+
rootParams: {
225+
_id: "_id"
226+
},
227+
params: {
228+
'__objectName': objectName
229+
},
230+
};
231+
// define _permissions_type
232+
let _permissions_type = _getPermissionsType(_permissions_type_name, fields);
233+
type = gql`
234+
${_permissions_type}
235+
${type}
236+
`;
237+
197238
// _related
198239
if (objectConfig.enable_files) {
199240
let relatedObjName = "cms_files";
@@ -478,6 +519,17 @@ export function getGraphqlActions(objectConfig: SteedosObjectTypeConfig) {
478519
},
479520
};
480521

522+
actions[`${GRAPHQL_ACTION_PREFIX}${PERMISSIONS_PREFIX}`] = {
523+
handler: async function (ctx) {
524+
let params = ctx.params;
525+
let { __objectName } = params;
526+
let userSession = ctx.meta.user;
527+
return await callObjectServiceAction(`@${__objectName}.getRecordPermissionsById`, userSession, {
528+
recordId: params._id
529+
});;
530+
},
531+
};
532+
481533
return actions;
482534
}
483535

@@ -988,6 +1040,8 @@ async function translateToUI(objectName, doc, userSession: any, selectorFieldNam
9881040
}
9891041
}
9901042
displayObj[name] = fileValue;
1043+
}else if(fType == "filesize"){
1044+
displayObj[name] = formatFileSize(doc[name]);
9911045
} else {
9921046
displayObj[name] = formatBasicFieldValue(fType, field, doc[name], objConfig, userSession);
9931047
}
@@ -1049,6 +1103,35 @@ function _getUIType(typeName, fields) {
10491103
return type;
10501104
}
10511105

1106+
function _getPermissionsType(typeName, fields) {
1107+
return `
1108+
type ${typeName} {
1109+
allowCreate: Boolean
1110+
allowCreateFiles: Boolean
1111+
allowDelete: Boolean
1112+
allowDeleteFiles: Boolean
1113+
allowEdit: Boolean
1114+
allowEditFiles: Boolean
1115+
allowRead: Boolean
1116+
allowReadFiles: Boolean
1117+
disabled_actions: [String]
1118+
disabled_list_views: [String]
1119+
field_permissions: JSON
1120+
modifyAllFiles: Boolean
1121+
modifyAllRecords: Boolean
1122+
modifyAssignCompanysRecords: [String]
1123+
modifyCompanyRecords: Boolean
1124+
uneditable_fields: [String]
1125+
unreadable_fields: [String]
1126+
unrelated_objects: [String]
1127+
viewAllFiles: Boolean
1128+
viewAllRecords: Boolean
1129+
viewAssignCompanysRecords: [String]
1130+
viewCompanyRecords: Boolean
1131+
}
1132+
`
1133+
}
1134+
10521135
// 获取object元数据
10531136
export function getLocalService(objectApiName: string) {
10541137
let steedosSchema = getSteedosSchema();

packages/objectql/src/types/object.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,8 @@ export class SteedosObjectType extends SteedosObjectProperties {
781781
if ('modifyAssignCompanysRecords' === k) {
782782
if (!_.isEmpty(_v) && _.isArray(_v)) {
783783
userObjectPermission['viewAssignCompanysRecords'].push(..._v);
784+
// 去重
785+
userObjectPermission['viewAssignCompanysRecords'] = _.uniq(userObjectPermission['viewAssignCompanysRecords'])
784786
}
785787
}
786788
if (!_.isEmpty(_v) && _.isArray(_v)) {
@@ -1743,8 +1745,8 @@ export class SteedosObjectType extends SteedosObjectProperties {
17431745
}
17441746
else {
17451747
if (userSession) {
1746-
let _records = returnValue
1747-
if (method == 'findOne' && returnValue) {
1748+
let _records = values
1749+
if (method == 'findOne' && values) {
17481750
_records = [_records]
17491751
}
17501752
await this.appendRecordPermission(_records, userSession);
@@ -1905,7 +1907,7 @@ export class SteedosObjectType extends SteedosObjectProperties {
19051907

19061908
// 指定公司权限
19071909
let viewAssignCompanysRecordsFilter = [];
1908-
if (objPm.viewAssignCompanysRecords) {
1910+
if (!objPm.viewAllRecords && objPm.viewAssignCompanysRecords) {
19091911
_.each(objPm.viewAssignCompanysRecords, (assignCompanyId) => {
19101912
viewAssignCompanysRecordsFilter.push(`((company_id eq '${assignCompanyId}') or (company_ids eq '${assignCompanyId}'))`)
19111913
})

packages/process/src/notifications.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const sendNotifications = async (from: string, to: string, {instanceHisto
3636
ids: [linkToId]
3737
},
3838
related_name: relatedDocName,
39-
from: `Process ${status}`,
39+
from: from,
4040
space: instance.space
4141
};
4242

packages/standard-objects/objectTranslations/queue_import.en/queue_import.en.objectTranslation.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ actions:
105105
downloadTemplate:
106106
label: Download Template
107107
CustomLabels:
108+
queue_import_download: Download
109+
queue_import_form_field_mapping_prompt: "Indicates that the data uniqueness field {$label} does not exist in the field mapping. Please configure it."
110+
queue_import_tips: Import complete
111+
queue_import_success_notification_body: "A total of {$total_count} records are imported; \n Success: {$total_count}; \n Failed: {$failure_count};"
112+
queue_import_error_info: "Error message"
108113
queue_import_action_import_execute_success: Executed
109114
queue_import_action_import_need_file: Upload excel file, please.
110115
queue_import_action_import_just_need_one_file: Just need one file.

0 commit comments

Comments
 (0)