fix(intake): narrow brand center department permissions
This commit is contained in:
parent
adba625280
commit
708d28cd94
@ -39,6 +39,27 @@ describe('intake node permission settings', () => {
|
||||
}),
|
||||
).toEqual(['planning'])
|
||||
|
||||
expect(
|
||||
resolveIntakeNodePermissionSubjectKeys({
|
||||
role: 'USER',
|
||||
businessRoles: ['PURCHASING'],
|
||||
departmentPaths: [
|
||||
'江苏简尚品牌管理有限公司 > 供应链中心 > 基本盘 采购部 > 采购二部',
|
||||
'江苏简尚品牌管理有限公司 > 龙晨品牌中心 > 供应链中心(江苏简尚品牌管理有限公司 > 龙晨品牌中心)',
|
||||
],
|
||||
}),
|
||||
).toEqual(['purchase'])
|
||||
|
||||
expect(
|
||||
resolveIntakeNodePermissionSubjectKeys({
|
||||
role: 'USER',
|
||||
businessRoles: [],
|
||||
departmentPaths: [
|
||||
'江苏简尚品牌管理有限公司 > 品牌中心 > 顾家事业部 > 策划部',
|
||||
],
|
||||
}),
|
||||
).toEqual(['brandCenter'])
|
||||
|
||||
expect(
|
||||
resolveIntakeNodePermissionSubjectKeys({
|
||||
role: 'USER',
|
||||
|
||||
@ -722,6 +722,17 @@ function normalizeDepartmentPath(value: unknown) {
|
||||
return normalizeText(value).replace(/\s+/g, "");
|
||||
}
|
||||
|
||||
function getDepartmentPathSegments(path: string) {
|
||||
return path
|
||||
.split(">")
|
||||
.map((segment) => segment.trim())
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
function hasDepartmentPathSegment(path: string, segment: string) {
|
||||
return getDepartmentPathSegments(path).includes(segment);
|
||||
}
|
||||
|
||||
function getDepartmentPathValues(user: IntakeNonIntegratedPermissionUser) {
|
||||
return [
|
||||
user.department?.fullPath,
|
||||
@ -755,15 +766,15 @@ function isProductResearchDepartmentPath(path: string) {
|
||||
}
|
||||
|
||||
function isBrandPlanningDepartmentPath(path: string) {
|
||||
return /品牌中心/.test(path) && /商品企划部/.test(path);
|
||||
return hasDepartmentPathSegment(path, "品牌中心") && /商品企划部/.test(path);
|
||||
}
|
||||
|
||||
function isSpaceVisualDepartmentPath(path: string) {
|
||||
return /空间视觉部/.test(path) && (!/>/.test(path) || /品牌中心/.test(path));
|
||||
return /空间视觉部/.test(path) && (!/>/.test(path) || hasDepartmentPathSegment(path, "品牌中心"));
|
||||
}
|
||||
|
||||
function isBrandCenterDepartmentPath(path: string) {
|
||||
return /品牌中心/.test(path);
|
||||
return hasDepartmentPathSegment(path, "品牌中心");
|
||||
}
|
||||
|
||||
function isPricingGroupDepartmentPath(path: string) {
|
||||
|
||||
@ -184,6 +184,23 @@ describe('non-integrated intake permissions', () => {
|
||||
expect(canDownloadNonIntegratedWorkspace(baseProduct, otherBrandPlanner, '产品模型')).toBe(false)
|
||||
})
|
||||
|
||||
it('does not treat Longchen brand center paths as main brand center permissions', () => {
|
||||
const purchaserWithLongchenPath = {
|
||||
id: 'purchase-longchen-id',
|
||||
name: '夭夭',
|
||||
role: 'USER',
|
||||
businessRoles: ['PURCHASING'],
|
||||
departmentPaths: [
|
||||
'江苏简尚品牌管理有限公司 > 供应链中心 > 基本盘 采购部 > 采购二部',
|
||||
'江苏简尚品牌管理有限公司 > 龙晨品牌中心 > 供应链中心(江苏简尚品牌管理有限公司 > 龙晨品牌中心)',
|
||||
],
|
||||
}
|
||||
|
||||
expect(canEditNonIntegratedWorkspace(baseProduct, purchaserWithLongchenPath, '产品定厂')).toBe(false)
|
||||
expect(canDownloadNonIntegratedWorkspace(baseProduct, purchaserWithLongchenPath, '产品模型')).toBe(false)
|
||||
expect(canEditNonIntegratedWorkspace(baseProduct, purchaserWithLongchenPath, '产品限价')).toBe(false)
|
||||
})
|
||||
|
||||
it('lets operation owners download only their own product information', () => {
|
||||
const operationOwner = {
|
||||
id: 'operation-id',
|
||||
|
||||
@ -146,6 +146,17 @@ function normalizeDepartmentPath(value: unknown) {
|
||||
return normalizeText(value).replace(/\s+/g, '')
|
||||
}
|
||||
|
||||
function getDepartmentPathSegments(path: string) {
|
||||
return path
|
||||
.split('>')
|
||||
.map((segment) => segment.trim())
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
function hasDepartmentPathSegment(path: string, segment: string) {
|
||||
return getDepartmentPathSegments(path).includes(segment)
|
||||
}
|
||||
|
||||
function getDepartmentPathValues(user: IntakeNonIntegratedPermissionUser) {
|
||||
return [
|
||||
user.department?.fullPath,
|
||||
@ -179,15 +190,15 @@ function isProductResearchDepartmentPath(path: string) {
|
||||
}
|
||||
|
||||
function isBrandPlanningDepartmentPath(path: string) {
|
||||
return /商品企划部/.test(path)
|
||||
return hasDepartmentPathSegment(path, '品牌中心') && /商品企划部/.test(path)
|
||||
}
|
||||
|
||||
function isBrandCenterDepartmentPath(path: string) {
|
||||
return /品牌中心/.test(path)
|
||||
return hasDepartmentPathSegment(path, '品牌中心')
|
||||
}
|
||||
|
||||
function isSpaceVisualDepartmentPath(path: string) {
|
||||
return /空间视觉部/.test(path) && (!/>/.test(path) || /品牌中心/.test(path))
|
||||
return /空间视觉部/.test(path) && (!/>/.test(path) || hasDepartmentPathSegment(path, '品牌中心'))
|
||||
}
|
||||
|
||||
function isSupplyChainPurchaseDepartmentPath(path: string) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user