Skip to content

Commit 8a449c8

Browse files
authored
refactor: Unused actions and utils (#7244)
1 parent 7462d7a commit 8a449c8

8 files changed

Lines changed: 0 additions & 132 deletions

File tree

frontend/common/dispatcher/action-constants.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const Actions = Object.assign({}, BaseActions, {
1010
'CREATE_PROJECT': 'CREATE_PROJECT',
1111
'DELETE_CHANGE_REQUEST': 'DELETE_CHANGE_REQUEST',
1212
'DELETE_ENVIRONMENT': 'DELETE_ENVIRONMENT',
13-
'DELETE_INVITE': 'DELETE_INVITE',
1413
'DELETE_ORGANISATION': 'DELETE_ORGANISATION',
1514
'DELETE_PROJECT': 'DELETE_PROJECT',
1615
'DELETE_USER': 'DELETE_USER',
@@ -31,11 +30,9 @@ const Actions = Object.assign({}, BaseActions, {
3130
'GET_ORGANISATION': 'GET_ORGANISATION',
3231
'GET_PROJECT': 'GET_PROJECT',
3332
'INVALIDATE_INVITE_LINK': 'INVALIDATE_INVITE_LINK',
34-
'MIGRATE_PROJECT': 'MIGRATE_PROJECT',
3533
'OAUTH': 'OAUTH',
3634
'REFRESH_FEATURES': 'REFRESH_FEATURES',
3735
'REMOVE_USER_FLAG': 'REMOVE_USER_FLAG',
38-
'RESEND_INVITE': 'RESEND_INVITE',
3936
'SELECT_ENVIRONMENT': 'SELECT_ENVIRONMENT',
4037
'SELECT_ORGANISATION': 'SELECT_ORGANISATION',
4138
'TOGGLE_USER_FLAG': 'TOGGLE_USER_FLAG',

frontend/common/dispatcher/app-actions.js

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,6 @@ const AppActions = Object.assign({}, BaseAppActions, {
7171
env,
7272
})
7373
},
74-
deleteInvite(id) {
75-
Dispatcher.handleViewAction({
76-
actionType: Actions.DELETE_INVITE,
77-
id,
78-
})
79-
},
8074
deleteOrganisation() {
8175
Dispatcher.handleViewAction({
8276
actionType: Actions.DELETE_ORGANISATION,
@@ -225,12 +219,6 @@ const AppActions = Object.assign({}, BaseAppActions, {
225219
link,
226220
})
227221
},
228-
migrateProject(projectId) {
229-
Dispatcher.handleViewAction({
230-
actionType: Actions.MIGRATE_PROJECT,
231-
projectId,
232-
})
233-
},
234222
oauthLogin(oauthType, data) {
235223
Dispatcher.handleViewAction({
236224
actionType: Actions.OAUTH,
@@ -260,40 +248,18 @@ const AppActions = Object.assign({}, BaseAppActions, {
260248
identityFlag,
261249
})
262250
},
263-
resendInvite(id) {
264-
Dispatcher.handleViewAction({
265-
actionType: Actions.RESEND_INVITE,
266-
id,
267-
})
268-
},
269251
resetPassword(data) {
270252
Dispatcher.handleViewAction({
271253
actionType: Actions.RESET_PASSWORD,
272254
...data,
273255
})
274256
},
275-
saveEnv(name) {
276-
Dispatcher.handleViewAction({
277-
actionType: Actions.EDIT_ENVIRONMENT,
278-
name,
279-
})
280-
},
281257
selectOrganisation(id) {
282258
Dispatcher.handleViewAction({
283259
actionType: Actions.SELECT_ORGANISATION,
284260
id,
285261
})
286262
},
287-
toggleFlag(index, environments, comment, environmentFlags, projectFlags) {
288-
Dispatcher.handleViewAction({
289-
actionType: Actions.TOGGLE_FLAG,
290-
comment,
291-
environmentFlags,
292-
environments,
293-
index,
294-
projectFlags,
295-
})
296-
},
297263
toggleUserFlag(params) {
298264
Dispatcher.handleViewAction({
299265
actionType: Actions.TOGGLE_USER_FLAG,

frontend/common/dispatcher/base/_action-constants.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
export default {
55
'LOGIN': 'LOGIN',
66
'LOGOUT': 'LOGOUT',
7-
'REFRESH': 'REFRESH',
87
'REGISTER': 'REGISTER',
9-
'REGISTER_NOTIFICATIONS': 'REGISTER_NOTIFICATIONS',
108
'RESET_PASSWORD': 'RESET_PASSWORD',
119
'SET_TOKEN': 'SET_TOKEN',
1210
'SET_USER': 'SET_USER',

frontend/common/dispatcher/base/_app-actions.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ export default {
1212
actionType: Actions.LOGOUT,
1313
})
1414
},
15-
refresh() {
16-
// refresh the entire app
17-
Dispatcher.handleViewAction({
18-
actionType: Actions.REFRESH,
19-
})
20-
},
2115
register(details, isInvite) {
2216
// refresh the entire app
2317
Dispatcher.handleViewAction({
@@ -26,12 +20,6 @@ export default {
2620
isInvite,
2721
})
2822
},
29-
registerNotifications(data) {
30-
Dispatcher.handleViewAction({
31-
actionType: Actions.REGISTER_NOTIFICATIONS,
32-
data,
33-
})
34-
},
3523
setToken(token) {
3624
Dispatcher.handleViewAction({
3725
actionType: Actions.SET_TOKEN,

frontend/common/stores/organisation-store.js

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,6 @@ const controller = {
7171
})
7272
})
7373
},
74-
deleteInvite: (id) => {
75-
store.saving()
76-
data
77-
.delete(`${Project.api}organisations/${store.id}/invites/${id}/`)
78-
.then(() => {
79-
API.trackEvent(Constants.events.DELETE_INVITE)
80-
if (store.model) {
81-
store.model.invites = filter(
82-
store.model.invites,
83-
(i) => i.id !== id,
84-
)
85-
}
86-
store.saved()
87-
})
88-
.catch((e) => API.ajaxHandler(store, e))
89-
},
90-
9174
deleteProject: (id) => {
9275
const idInt = parseInt(id)
9376
store.saving()
@@ -257,22 +240,6 @@ const controller = {
257240
}),
258241
)
259242
},
260-
resendInvite: (id) => {
261-
data
262-
.post(`${Project.api}organisations/${store.id}/invites/${id}/resend/`)
263-
.then(() => {
264-
API.trackEvent(Constants.events.RESEND_INVITE)
265-
toast('Invite resent successfully')
266-
})
267-
.catch((e) => {
268-
toast(
269-
`Failed to resend invite. ${
270-
e && e.error ? e.error : 'Please try again later'
271-
}`,
272-
'danger',
273-
)
274-
})
275-
},
276243
updateUserRole: (id, role) => {
277244
data
278245
.post(
@@ -332,15 +299,9 @@ store.dispatcherIndex = Dispatcher.register(store, (payload) => {
332299
case Actions.DELETE_PROJECT:
333300
controller.deleteProject(action.id)
334301
break
335-
case Actions.DELETE_INVITE:
336-
controller.deleteInvite(action.id)
337-
break
338302
case Actions.DELETE_USER:
339303
controller.deleteUser(action.id)
340304
break
341-
case Actions.RESEND_INVITE:
342-
controller.resendInvite(action.id)
343-
break
344305
case Actions.UPDATE_USER_ROLE:
345306
controller.updateUserRole(action.id, action.role)
346307
break

frontend/common/stores/project-store.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,6 @@ const controller = {
168168
document.location.href = '/404?entity=project'
169169
})
170170
},
171-
migrateProject: (id) => {
172-
store.loading()
173-
data.post(`${Project.api}projects/${id}/migrate-to-edge/`).then(() => {
174-
controller.getProject(id, () => store.saved(), true)
175-
})
176-
},
177171
}
178172

179173
const store = Object.assign({}, BaseStore, {
@@ -227,9 +221,6 @@ store.dispatcherIndex = Dispatcher.register(store, (payload) => {
227221
const action = payload.action // this is our action from handleViewAction
228222

229223
switch (action.actionType) {
230-
case Actions.MIGRATE_PROJECT:
231-
controller.migrateProject(parseInt(action.projectId))
232-
break
233224
case Actions.GET_PROJECT:
234225
controller.getProject(parseInt(action.projectId))
235226
break

frontend/common/utils/__tests__/format.test.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,6 @@ describe('Format', () => {
1717
})
1818
})
1919

20-
describe('nearestTen', () => {
21-
it.each`
22-
input | expected
23-
${0} | ${'00'}
24-
${5} | ${'05'}
25-
${9} | ${'09'}
26-
${10} | ${10}
27-
${15} | ${15}
28-
${99} | ${99}
29-
`('nearestTen($input) returns $expected', ({ expected, input }) => {
30-
expect(Format.nearestTen(input)).toBe(expected)
31-
})
32-
})
33-
3420
describe('camelCase', () => {
3521
it.each`
3622
input | expected

frontend/common/utils/format.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import moment from 'moment'
2-
31
type Person = {
42
firstName?: string
53
lastName?: string
@@ -39,23 +37,6 @@ const Format = {
3937
: Format.camelCase(sn)
4038
},
4139

42-
moment(
43-
value: string | null | undefined,
44-
format: string,
45-
): string | null | undefined {
46-
// DATE, hh:mm > 23:00
47-
if (value) {
48-
const m = moment(value)
49-
return m.format(format)
50-
}
51-
return value
52-
},
53-
54-
nearestTen(value: number): string | number {
55-
// 11 > 10
56-
return value >= 10 ? value : `0${value}`
57-
},
58-
5940
newLineDelimiter: '↵',
6041

6142
shortenNumber(number: number): string {

0 commit comments

Comments
 (0)