Skip to content

Commit 8d38b0c

Browse files
committed
MR 无权限页面
1 parent 11c80ef commit 8d38b0c

File tree

3 files changed

+44
-51
lines changed

3 files changed

+44
-51
lines changed

Coding_iOS/Controllers/MRDetailViewController.m

Lines changed: 38 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ @interface MRDetailViewController ()<UITableViewDataSource, UITableViewDelegate,
5959
@property (strong, nonatomic) NSString *activityPath;
6060
@property (strong, nonatomic) NSString *diffPath;
6161
@property (strong, nonatomic) ResourceReference *resourceReference;
62-
@property (strong, nonatomic) NSArray *activityList;
62+
@property (strong, nonatomic) NSMutableArray *activityList;
6363
@property (strong, nonatomic) NSMutableArray *activityCList;
64-
@property (strong, nonatomic) NSMutableArray *allDiscussions;
6564
@property (nonatomic, strong) NSMutableArray *projectUsers;
6665
@property (strong, nonatomic) NSString *reviewGoodPath;
6766
@property (strong, nonatomic) NSNumber *isLike;
@@ -85,8 +84,6 @@ - (void)viewDidLoad{
8584
[super viewDidLoad];
8685
self.loadedActivty = false;
8786
self.activityList = [[NSMutableArray alloc] init];
88-
self.activityCList = [[NSMutableArray alloc] init];
89-
self.allDiscussions = [[NSMutableArray alloc] init];
9087
self.title = [NSString stringWithFormat:@"%@ #%@", _curMRPR.des_project_name, _curMRPR.iid.stringValue];
9188
self.referencePath = [NSString stringWithFormat:@"/api/user/%@/project/%@/resource_reference/%@", _curMRPR.des_owner_name, _curMRPR.des_project_name,self.curMRPR.iid];
9289
self.activityPath = [NSString stringWithFormat:@"/api/user/%@/project/%@/git/merge/%@/activities", _curMRPR.des_owner_name, _curMRPR.des_project_name,self.curMRPR.iid];
@@ -187,32 +184,33 @@ - (void)configBottomView{
187184
_myTableView.scrollIndicatorInsets = insets;
188185
}
189186

190-
-(void)sortActivityList {
191-
if(self.curMRPRInfo == nil) {
192-
return ;
193-
}
194-
if (self.activityCList == nil) {
195-
return ;
187+
- (void)updateActivityList{
188+
if (!_curMRPRInfo || !_activityCList) {
189+
return;
196190
}
197-
NSMutableArray *dataArray = [[NSMutableArray alloc] initWithArray:self.activityCList];
198-
for(int i = 0; i < self.allDiscussions.count; i ++) {
199-
[dataArray addObject:self.allDiscussions[i]];
191+
NSMutableArray *activityList = [NSMutableArray new];
192+
for (NSArray *list in _curMRPRInfo.discussions) {
193+
ProjectLineNote *note = list.firstObject;
194+
if (note.path.length > 0) {
195+
note.action = @"mergeChanges";
196+
}
197+
[activityList addObject:note];
200198
}
201-
self.activityList = [dataArray sortedArrayUsingComparator:^NSComparisonResult(ProjectLineNote *obj1, ProjectLineNote *obj2) {
202-
NSComparisonResult result = [ [NSNumber numberWithDouble:[obj1.created_at timeIntervalSinceReferenceDate]] compare:[NSNumber numberWithDouble:[obj2.created_at timeIntervalSinceReferenceDate]]];
203-
return result;
199+
[activityList addObjectsFromArray:_activityCList];
200+
[activityList sortUsingComparator:^NSComparisonResult(ProjectLineNote *obj1, ProjectLineNote *obj2) {
201+
return [obj1.created_at compare:obj2.created_at];
204202
}];
205-
[self.myTableView reloadData];
203+
self.activityList = activityList;
206204
}
207205

206+
208207
- (void)updateProjectStatus {
209208
__weak typeof(self) weakSelf = self;
210209
[[Coding_NetAPIManager sharedManager] request_MRPRPreInfo_WithObj:_curMRPR andBlock:^(MRPRBaseInfo *data, NSError *error) {
211210
[weakSelf.view endLoading];
212211
[weakSelf.myRefreshControl endRefreshing];
213212
if (data) {
214213
weakSelf.curPreMRPRInfo = (MRPRPreInfo*)data;
215-
[weakSelf sortActivityList];
216214
[weakSelf.myTableView reloadData];
217215
[weakSelf configBottomView];
218216
}
@@ -241,37 +239,40 @@ - (void)refresh{
241239
[(MRPRBaseInfo *)data setContentHeight:weakSelf.curMRPRInfo.contentHeight];
242240
}
243241
weakSelf.curMRPRInfo = data;
244-
NSMutableArray *resultA = weakSelf.curMRPRInfo.discussions;
245-
if(resultA != nil){
246-
[weakSelf.allDiscussions removeAllObjects];
247-
for (int i = 0; i<resultA.count; i ++) {
248-
NSArray *pArray = resultA[i];
249-
ProjectLineNote* addTmp = pArray[0];
250-
if (addTmp.path != nil) {
251-
addTmp.action = @"mergeChanges";
252-
}
253-
[weakSelf.allDiscussions addObject:addTmp];
254-
}
255-
}
256-
weakSelf.bottomView = nil;
242+
[weakSelf updateActivityList];
257243
[weakSelf configBottomView];
258-
[weakSelf sortActivityList];
244+
[weakSelf.myTableView reloadData];
259245
}
246+
[weakSelf.view configBlankPage:EaseBlankPageTypeMRForbidden hasData:data != nil hasError:(error != nil && error.code != 1400) reloadButtonBlock:^(id sender) {
247+
[weakSelf refresh];
248+
}];
260249
}];
250+
//MR 动态
251+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:self.activityPath withParams:@{@"iid": _curMRPR.iid} withMethodType:Get andBlock:^(id data, NSError *error) {
252+
if (data) {
253+
id resultData = [data valueForKeyPath:@"data"];
254+
weakSelf.activityCList = [NSObject arrayFromJSON:resultData ofObjects:@"ProjectLineNote"];
255+
[weakSelf updateActivityList];
256+
[weakSelf.myTableView reloadData];
257+
}
258+
}];
259+
//项目成员
261260
[[Coding_NetAPIManager sharedManager] request_ProjectMembers_WithObj:self.curProject andBlock:^(id data, NSError *error) {
262261
[weakSelf.view endLoading];
263262
if (data) {
264263
NSMutableArray* projectUsers = data;
265264
weakSelf.projectUsers = projectUsers;
266265
}
267266
}];
267+
//MR 评审者
268268
[[Coding_NetAPIManager sharedManager] request_MRReviewerInfo_WithObj:_curMRPR andBlock:^(ReviewersInfo *data, NSError *error) {
269269
[weakSelf.view endLoading];
270270
[weakSelf.myRefreshControl endRefreshing];
271271
if (data) {
272272
weakSelf.curReviewersInfo = data;
273273
}
274274
}];
275+
//关联资源
275276
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:self.referencePath withParams:@{@"iid": _curMRPR.iid} withMethodType:Get andBlock:^(id data, NSError *error) {
276277
if (data) {
277278
if (weakSelf.resourceReference == nil) {
@@ -283,20 +284,7 @@ - (void)refresh{
283284

284285
}
285286
}];
286-
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:self.activityPath withParams:@{@"iid": _curMRPR.iid} withMethodType:Get andBlock:^(id data, NSError *error) {
287-
if (data) {
288-
id resultData = [data valueForKeyPath:@"data"];
289-
NSMutableArray *resultA = [NSObject arrayFromJSON:resultData ofObjects:@"ProjectLineNote"];
290-
if(resultA != nil){
291-
[weakSelf.activityCList removeAllObjects];
292-
for (int i = 0; i<resultA.count; i ++) {
293-
ProjectLineNote* addTmp = resultA[i];
294-
[weakSelf.activityCList addObject:addTmp];
295-
}
296-
[weakSelf sortActivityList];
297-
}
298-
}
299-
}];
287+
//项目信息
300288
if (!_curProject) {
301289
_curProject = [Project new];
302290
_curProject.owner_user_name = _curMRPR.des_owner_name;
@@ -420,7 +408,7 @@ - (void)authorizationMRPR{
420408
[[Coding_NetAPIManager sharedManager] request_MRPRAuthorization:_curMRPRInfo.mrpr andBlock:^(id data, NSError *error) {
421409
if (data) {
422410
weakSelf.curPreMRPRInfo.mrpr.granted = @1;
423-
weakSelf.bottomView = nil;
411+
// weakSelf.bottomView = nil;
424412
[weakSelf refresh];
425413
[weakSelf.myTableView reloadData];
426414
[weakSelf configBottomView];
@@ -433,7 +421,7 @@ - (void)cancelAuthorizationMRPR{
433421
[[Coding_NetAPIManager sharedManager] request_MRPRCancelAuthorization:_curMRPRInfo.mrpr andBlock:^(id data, NSError *error) {
434422
if (data) {
435423
weakSelf.curPreMRPRInfo.mrpr.granted = @0;
436-
weakSelf.bottomView = nil;
424+
// weakSelf.bottomView = nil;
437425
[weakSelf refresh];
438426
[weakSelf.myTableView reloadData];
439427
[weakSelf configBottomView];
@@ -457,7 +445,7 @@ - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger
457445

458446
#pragma mark TableM
459447
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
460-
return self.activityList.count <= 0? 4: 5;
448+
return !self.curMRPRInfo? 0: self.activityList.count > 0? 5: 4;
461449
}
462450
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
463451
NSInteger row = 0;
@@ -780,8 +768,7 @@ - (void)deleteComment:(ProjectLineNote *)lineNote{
780768
__weak typeof(self) weakSelf = self;
781769
[[Coding_NetAPIManager sharedManager] request_DeleteLineNote:lineNote.id inProject:_curMRPRInfo.mrpr.des_project_name ofUser:_curMRPRInfo.mrpr.des_owner_name andBlock:^(id data, NSError *error) {
782770
if (data) {
783-
[weakSelf.allDiscussions removeObject:lineNote];
784-
[weakSelf sortActivityList];
771+
[weakSelf.activityList removeObject:lineNote];
785772
[weakSelf.myTableView reloadData];
786773
}
787774
}];

Coding_iOS/Util/OC_Category/UIView+Common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ typedef NS_ENUM(NSInteger, EaseBlankPageType)
2525
EaseBlankPageTypeProject,
2626
EaseBlankPageTypeProjectOther,
2727
EaseBlankPageTypeFileDleted,
28+
EaseBlankPageTypeMRForbidden,
2829
EaseBlankPageTypeFolderDleted,
2930
EaseBlankPageTypePrivateMsg,
3031
EaseBlankPageTypeMyWatchedTopic,

Coding_iOS/Util/OC_Category/UIView+Common.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,11 @@ - (void)configWithType:(EaseBlankPageType)blankPageType hasData:(BOOL)hasData ha
629629
{
630630
imageName = @"blankpage_image_loadFail";
631631
tipStr = @"晚了一步\n文件刚刚被人删除了~";
632+
}
633+
case EaseBlankPageTypeMRForbidden://去了MR页面,发现没有权限
634+
{
635+
imageName = @"blankpage_image_loadFail";
636+
tipStr = @"无权访问\n请联系项目管理员进行代码权限设置";
632637
}
633638
break;
634639
case EaseBlankPageTypeFolderDleted://文件夹

0 commit comments

Comments
 (0)