Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit 557d8f7

Browse files
author
Noah Hanjun Lee
authored
Change the message level in UI (#124)
* Update message level for 403 error * Remove lock / unlock in settings
1 parent 5866c34 commit 557d8f7

File tree

7 files changed

+24
-77
lines changed

7 files changed

+24
-77
lines changed

ui/src/redux/deployment.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export const deployToSCM = createAsyncThunk<Deployment, void, { state: {deployme
113113
return deployment
114114
} catch(e) {
115115
if (e instanceof HttpForbiddenError) {
116-
message.error("Only write permission can deploy.", 3)
116+
message.warn("Only write permission can deploy.", 3)
117117
} else if (e instanceof HttpUnprocessableEntityError) {
118118
const msg = <span>
119119
<span>It is unprocesable entity. Discussions <a href="https://github.com/gitploy-io/gitploy/discussions/64">#64</a></span><br/>

ui/src/redux/members.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const fetchUsers = createAsyncThunk<User[], void, { state: {members: Memb
2828
return users
2929
} catch(e) {
3030
if (e instanceof HttpForbiddenError) {
31-
message.error("Only admin can access.", 3)
31+
message.warn("Only admin can access.", 3)
3232
}
3333

3434
return rejectWithValue(e)
@@ -44,7 +44,7 @@ export const updateUser = createAsyncThunk<User, {user: User, admin: boolean}, {
4444
return u
4545
} catch(e) {
4646
if (e instanceof HttpForbiddenError) {
47-
message.error("Only admin can access.", 3)
47+
message.warn("Only admin can access.", 3)
4848
}
4949

5050
return rejectWithValue(e)
@@ -60,7 +60,7 @@ export const deleteUser = createAsyncThunk<string, User, { state: {members: Memb
6060
return user.id
6161
} catch(e) {
6262
if (e instanceof HttpForbiddenError) {
63-
message.error("Only admin can access.", 3)
63+
message.warn("Only admin can access.", 3)
6464
}
6565

6666
return rejectWithValue(e)

ui/src/redux/repo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const activate = createAsyncThunk<Repo, void, { state: {repo: RepoState}
4040
return nr
4141
} catch(e) {
4242
if (e instanceof HttpForbiddenError) {
43-
message.error("Only admin permission can activate.", 3)
43+
message.warn("Only admin permission can activate.", 3)
4444
} else {
4545
message.error("It has failed to save.", 3)
4646
}

ui/src/redux/repoDeploy.tsx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,9 @@ export const addBranchManually = createAsyncThunk<Branch, string, { state: {repo
135135
return branch
136136
} catch(e) {
137137
if (e instanceof HttpNotFoundError) {
138-
message.error("The ref is not found. Check the ref is corrent.")
139-
} else {
140-
message.error("It has failed to add the ref.")
141-
}
138+
message.warn("The branch is not found. Check the branch is correct.")
139+
}
140+
142141
return rejectWithValue(e)
143142
}
144143
}
@@ -178,10 +177,9 @@ export const addCommitManually = createAsyncThunk<Commit, string, { state: {repo
178177
return commit
179178
} catch(e) {
180179
if (e instanceof HttpNotFoundError) {
181-
message.error("The ref is not found. Check the ref is corrent.")
182-
} else {
183-
message.error("It has failed to add the ref.")
184-
}
180+
message.warn("The ref is not found. Check the ref is correct.")
181+
}
182+
185183
return rejectWithValue(e)
186184
}
187185
}
@@ -220,10 +218,9 @@ export const addTagManually = createAsyncThunk<Tag, string, { state: {repoDeploy
220218
return tag
221219
} catch(e) {
222220
if (e instanceof HttpNotFoundError) {
223-
message.error("The ref is not found. Check the ref is corrent.")
224-
} else {
225-
message.error("It has failed to add the ref.")
226-
}
221+
message.warn("The tag is not found. Check the tag is correct.")
222+
}
223+
227224
return rejectWithValue(e)
228225
}
229226
}
@@ -293,7 +290,7 @@ export const deploy = createAsyncThunk<void, void, { state: {repoDeploy: RepoDep
293290
message.success(msg, 3)
294291
} catch(e) {
295292
if (e instanceof HttpForbiddenError) {
296-
message.error("Only write permission can deploy.", 3)
293+
message.warn("Only write permission can deploy.", 3)
297294
} else if (e instanceof HttpUnprocessableEntityError) {
298295
const msg = <span>
299296
<span>It is unprocesable entity. Discussions <a href="https://github.com/gitploy-io/gitploy/discussions/64">#64</a></span><br/>

ui/src/redux/repoLock.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const lock = createAsyncThunk<Lock, string, { state: {repoLock: RepoLockS
8282
return locks
8383
} catch (e) {
8484
if (e instanceof HttpForbiddenError) {
85-
message.error("Only write permission can lock.", 3)
85+
message.warn("Only write permission can lock.", 3)
8686
}
8787
return rejectWithValue(e)
8888
}
@@ -107,7 +107,7 @@ export const unlock = createAsyncThunk<Lock, string, { state: {repoLock: RepoLoc
107107
return lock
108108
} catch (e) {
109109
if (e instanceof HttpForbiddenError) {
110-
message.error("Only write permission can unlock.", 3)
110+
message.warn("Only write permission can unlock.", 3)
111111
}
112112
return rejectWithValue(e)
113113
}

ui/src/redux/repoRollback.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export const rollback = createAsyncThunk<void, void, { state: {repoRollback: Rep
144144
message.success(msg, 3)
145145
} catch(e) {
146146
if (e instanceof HttpForbiddenError) {
147-
message.error("Only write permission can deploy.", 3)
147+
message.warn("Only write permission can deploy.", 3)
148148
} else if (e instanceof HttpUnprocessableEntityError) {
149149
const msg = <span>
150150
<span>It is unprocesable entity. Discussions <a href="https://github.com/gitploy-io/gitploy/discussions/64">#64</a></span><br/>

ui/src/redux/repoSettings.ts

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createSlice, createAsyncThunk, PayloadAction } from "@reduxjs/toolkit"
22
import { message } from "antd"
33

4-
import { searchRepo, updateRepo, deactivateRepo, lockRepo, unlockRepo } from "../apis"
4+
import { searchRepo, updateRepo, deactivateRepo } from "../apis"
55
import { Repo, RequestStatus, HttpForbiddenError } from "../models"
66

77
interface RepoSettingsState {
@@ -43,10 +43,9 @@ export const save = createAsyncThunk<Repo, void, { state: {repoSettings: RepoSet
4343
return nr
4444
} catch(e) {
4545
if (e instanceof HttpForbiddenError) {
46-
message.error("Only admin permission can update.", 3)
47-
} else {
48-
message.error("It has failed to save.", 3)
49-
}
46+
message.warn("Only admin permission can update.", 3)
47+
}
48+
5049
return rejectWithValue(e)
5150
}
5251
},
@@ -64,52 +63,9 @@ export const deactivate = createAsyncThunk<Repo, void, { state: {repoSettings: R
6463
return nr
6564
} catch(e) {
6665
if (e instanceof HttpForbiddenError) {
67-
message.error("Only admin permission can deactivate.", 3)
68-
} else {
69-
message.error("It has failed to save.", 3)
70-
}
71-
return rejectWithValue(e)
72-
}
73-
},
74-
)
75-
76-
export const lock = createAsyncThunk<Repo, void, { state: {repoSettings: RepoSettingsState} }>(
77-
'repoSettings/lock',
78-
async (_, { getState, rejectWithValue } ) => {
79-
const { repo } = getState().repoSettings
80-
if (!repo) throw new Error("There is no repo.")
81-
82-
try {
83-
const ret = await lockRepo(repo)
84-
message.info("Lock the repository successfully.", 3)
85-
return ret
86-
} catch(e) {
87-
if (e instanceof HttpForbiddenError) {
88-
message.error("Only admin permission can lock the repository.", 3)
89-
} else {
90-
message.error("It has failed to lock.", 3)
91-
}
92-
return rejectWithValue(e)
93-
}
94-
},
95-
)
96-
97-
export const unlock = createAsyncThunk<Repo, void, { state: {repoSettings: RepoSettingsState} }>(
98-
'repoSettings/unlock',
99-
async (_, { getState, rejectWithValue } ) => {
100-
const { repo } = getState().repoSettings
101-
if (!repo) throw new Error("There is no repo.")
66+
message.warn("Only admin permission can deactivate.", 3)
67+
}
10268

103-
try {
104-
const ret = await unlockRepo(repo)
105-
message.info("Unlock the repository successfully.", 3)
106-
return ret
107-
} catch(e) {
108-
if (e instanceof HttpForbiddenError) {
109-
message.error("Only admin permission can unlock the repository.", 3)
110-
} else {
111-
message.error("It has failed to unlock.", 3)
112-
}
11369
return rejectWithValue(e)
11470
}
11571
},
@@ -158,11 +114,5 @@ export const repoSettingsSlice = createSlice({
158114
.addCase(deactivate.rejected, (state) => {
159115
state.deactivating = RequestStatus.Idle
160116
})
161-
.addCase(lock.fulfilled, (state, action) => {
162-
state.repo = action.payload
163-
})
164-
.addCase(unlock.fulfilled, (state, action) => {
165-
state.repo = action.payload
166-
})
167117
}
168118
})

0 commit comments

Comments
 (0)