Skip to content

Commit 8751678

Browse files
refactor: [M3-9723] - Managed Tanstack routing (#11994)
* Initial commit: landing routing * monitors * remove barrel files * save progress * Wrap up monitors * SSH Access * Credentials * Wrapping up UI * fix units * e2e fixes * fix after rebase * fix remainin e2e failure * eslint fix * eslint fix * linting fixes * Added changeset: Managed Tanstack routing * feedback @mjac0bs
1 parent a3dafb8 commit 8751678

52 files changed

Lines changed: 1413 additions & 1039 deletions

Some content is hidden

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

packages/api-v4/src/managed/managed.ts

Lines changed: 72 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
updateManagedLinodeSchema,
77
updatePasswordSchema,
88
} from '@linode/validation/lib/managed.schema';
9+
910
import { API_ROOT } from '../constants';
1011
import Request, {
1112
setData,
@@ -14,8 +15,9 @@ import Request, {
1415
setURL,
1516
setXFilter,
1617
} from '../request';
17-
import { Filter, Params, ResourcePage as Page } from '../types';
18-
import {
18+
19+
import type { Filter, ResourcePage as Page, Params } from '../types';
20+
import type {
1921
ContactPayload,
2022
CredentialPayload,
2123
ManagedContact,
@@ -44,7 +46,7 @@ import {
4446
export const enableManaged = () =>
4547
Request<{}>(
4648
setMethod('POST'),
47-
setURL(`${API_ROOT}/account/settings/managed-enable`)
49+
setURL(`${API_ROOT}/account/settings/managed-enable`),
4850
);
4951

5052
/**
@@ -57,7 +59,7 @@ export const getServices = (params?: Params, filters?: Filter) =>
5759
setMethod('GET'),
5860
setParams(params),
5961
setXFilter(filters),
60-
setURL(`${API_ROOT}/managed/services`)
62+
setURL(`${API_ROOT}/managed/services`),
6163
);
6264

6365
/**
@@ -69,8 +71,8 @@ export const disableServiceMonitor = (serviceID: number) =>
6971
Request<ManagedServiceMonitor>(
7072
setMethod('POST'),
7173
setURL(
72-
`${API_ROOT}/managed/services/${encodeURIComponent(serviceID)}/disable`
73-
)
74+
`${API_ROOT}/managed/services/${encodeURIComponent(serviceID)}/disable`,
75+
),
7476
);
7577

7678
/**
@@ -82,8 +84,8 @@ export const enableServiceMonitor = (serviceID: number) =>
8284
Request<ManagedServiceMonitor>(
8385
setMethod('POST'),
8486
setURL(
85-
`${API_ROOT}/managed/services/${encodeURIComponent(serviceID)}/enable`
86-
)
87+
`${API_ROOT}/managed/services/${encodeURIComponent(serviceID)}/enable`,
88+
),
8789
);
8890

8991
/**
@@ -94,7 +96,7 @@ export const enableServiceMonitor = (serviceID: number) =>
9496
export const deleteServiceMonitor = (serviceID: number) =>
9597
Request<{}>(
9698
setMethod('DELETE'),
97-
setURL(`${API_ROOT}/managed/services/${encodeURIComponent(serviceID)}`)
99+
setURL(`${API_ROOT}/managed/services/${encodeURIComponent(serviceID)}`),
98100
);
99101

100102
/**
@@ -107,7 +109,18 @@ export const getLinodeSettings = (params?: Params, filters?: Filter) =>
107109
setMethod('GET'),
108110
setParams(params),
109111
setXFilter(filters),
110-
setURL(`${API_ROOT}/managed/linode-settings`)
112+
setURL(`${API_ROOT}/managed/linode-settings`),
113+
);
114+
115+
/**
116+
* getServiceMonitor
117+
*
118+
* Returns a Managed Service Monitor by ID.
119+
*/
120+
export const getServiceMonitor = (serviceId: number) =>
121+
Request<ManagedServiceMonitor>(
122+
setMethod('GET'),
123+
setURL(`${API_ROOT}/managed/services/${encodeURIComponent(serviceId)}`),
111124
);
112125

113126
/**
@@ -119,7 +132,7 @@ export const createServiceMonitor = (data: ManagedServicePayload) =>
119132
Request<ManagedServiceMonitor>(
120133
setMethod('POST'),
121134
setURL(`${API_ROOT}/managed/services`),
122-
setData(data, createServiceMonitorSchema)
135+
setData(data, createServiceMonitorSchema),
123136
);
124137

125138
/**
@@ -129,12 +142,25 @@ export const createServiceMonitor = (data: ManagedServicePayload) =>
129142
*/
130143
export const updateServiceMonitor = (
131144
monitorID: number,
132-
data: Partial<ManagedServicePayload>
145+
data: Partial<ManagedServicePayload>,
133146
) =>
134147
Request<ManagedServiceMonitor>(
135148
setMethod('PUT'),
136149
setURL(`${API_ROOT}/managed/services/${encodeURIComponent(monitorID)}`),
137-
setData(data, createServiceMonitorSchema)
150+
setData(data, createServiceMonitorSchema),
151+
);
152+
153+
/**
154+
* getCredential
155+
*
156+
* Returns a Managed Credential by ID.
157+
*/
158+
export const getCredential = (credentialId: number) =>
159+
Request<ManagedCredential>(
160+
setMethod('GET'),
161+
setURL(
162+
`${API_ROOT}/managed/credentials/${encodeURIComponent(credentialId)}`,
163+
),
138164
);
139165

140166
/**
@@ -147,7 +173,7 @@ export const getCredentials = (params?: Params, filters?: Filter) =>
147173
setMethod('GET'),
148174
setParams(params),
149175
setXFilter(filters),
150-
setURL(`${API_ROOT}/managed/credentials`)
176+
setURL(`${API_ROOT}/managed/credentials`),
151177
);
152178

153179
/**
@@ -158,14 +184,14 @@ export const getCredentials = (params?: Params, filters?: Filter) =>
158184
*/
159185
export const updateCredential = (
160186
credentialID: number,
161-
data: UpdateCredentialPayload
187+
data: UpdateCredentialPayload,
162188
) =>
163189
Request<ManagedCredential>(
164190
setMethod('PUT'),
165191
setData(data, updateCredentialSchema),
166192
setURL(
167-
`${API_ROOT}/managed/credentials/${encodeURIComponent(credentialID)}`
168-
)
193+
`${API_ROOT}/managed/credentials/${encodeURIComponent(credentialID)}`,
194+
),
169195
);
170196

171197
/**
@@ -175,16 +201,16 @@ export const updateCredential = (
175201
*/
176202
export const updatePassword = (
177203
credentialID: number,
178-
data: UpdatePasswordPayload
204+
data: UpdatePasswordPayload,
179205
) =>
180206
Request<{}>(
181207
setMethod('POST'),
182208
setData(data, updatePasswordSchema),
183209
setURL(
184210
`${API_ROOT}/managed/credentials/${encodeURIComponent(
185-
credentialID
186-
)}/update`
187-
)
211+
credentialID,
212+
)}/update`,
213+
),
188214
);
189215

190216
/**
@@ -197,9 +223,9 @@ export const deleteCredential = (credentialID: number) =>
197223
setMethod('POST'),
198224
setURL(
199225
`${API_ROOT}/managed/credentials/${encodeURIComponent(
200-
credentialID
201-
)}/revoke`
202-
)
226+
credentialID,
227+
)}/revoke`,
228+
),
203229
);
204230

205231
/*
@@ -211,7 +237,7 @@ export const createCredential = (data: CredentialPayload) =>
211237
Request<ManagedCredential>(
212238
setMethod('POST'),
213239
setURL(`${API_ROOT}/managed/credentials`),
214-
setData(data, createCredentialSchema)
240+
setData(data, createCredentialSchema),
215241
);
216242

217243
/**
@@ -224,7 +250,7 @@ export const createCredential = (data: CredentialPayload) =>
224250
export const getSSHPubKey = () =>
225251
Request<ManagedSSHPubKey>(
226252
setMethod('GET'),
227-
setURL(`${API_ROOT}/managed/credentials/sshkey`)
253+
setURL(`${API_ROOT}/managed/credentials/sshkey`),
228254
);
229255

230256
/**
@@ -235,14 +261,25 @@ export const getSSHPubKey = () =>
235261
*/
236262
export const updateLinodeSettings = (
237263
linodeId: number,
238-
data: { ssh: Partial<ManagedSSHSetting> }
264+
data: { ssh: Partial<ManagedSSHSetting> },
239265
) =>
240266
Request<ManagedLinodeSetting>(
241267
setURL(
242-
`${API_ROOT}/managed/linode-settings/${encodeURIComponent(linodeId)}`
268+
`${API_ROOT}/managed/linode-settings/${encodeURIComponent(linodeId)}`,
243269
),
244270
setMethod('PUT'),
245-
setData(data, updateManagedLinodeSchema)
271+
setData(data, updateManagedLinodeSchema),
272+
);
273+
274+
/**
275+
* getManagedContact
276+
*
277+
* Returns a Managed Contact by ID.
278+
*/
279+
export const getManagedContact = (contactId: number) =>
280+
Request<ManagedContact>(
281+
setMethod('GET'),
282+
setURL(`${API_ROOT}/managed/contacts/${encodeURIComponent(contactId)}`),
246283
);
247284

248285
/**
@@ -255,7 +292,7 @@ export const getManagedContacts = (params?: Params, filters?: Filter) =>
255292
setMethod('GET'),
256293
setParams(params),
257294
setXFilter(filters),
258-
setURL(`${API_ROOT}/managed/contacts`)
295+
setURL(`${API_ROOT}/managed/contacts`),
259296
);
260297

261298
/**
@@ -267,7 +304,7 @@ export const createContact = (data: ContactPayload) =>
267304
Request<ManagedContact>(
268305
setMethod('POST'),
269306
setURL(`${API_ROOT}/managed/contacts`),
270-
setData(data, createContactSchema)
307+
setData(data, createContactSchema),
271308
);
272309

273310
/**
@@ -277,12 +314,12 @@ export const createContact = (data: ContactPayload) =>
277314
*/
278315
export const updateContact = (
279316
contactId: number,
280-
data: Partial<ContactPayload>
317+
data: Partial<ContactPayload>,
281318
) =>
282319
Request<ManagedContact>(
283320
setMethod('PUT'),
284321
setURL(`${API_ROOT}/managed/contacts/${encodeURIComponent(contactId)}`),
285-
setData(data, createContactSchema)
322+
setData(data, createContactSchema),
286323
);
287324

288325
/**
@@ -293,7 +330,7 @@ export const updateContact = (
293330
export const deleteContact = (contactId: number) =>
294331
Request<{}>(
295332
setMethod('DELETE'),
296-
setURL(`${API_ROOT}/managed/contacts/${encodeURIComponent(contactId)}`)
333+
setURL(`${API_ROOT}/managed/contacts/${encodeURIComponent(contactId)}`),
297334
);
298335

299336
/**
@@ -304,7 +341,7 @@ export const deleteContact = (contactId: number) =>
304341
export const getManagedIssues = () =>
305342
Request<Page<ManagedIssue>>(
306343
setMethod('GET'),
307-
setURL(`${API_ROOT}/managed/issues`)
344+
setURL(`${API_ROOT}/managed/issues`),
308345
);
309346

310347
/**
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Tech Stories
3+
---
4+
5+
Managed Tanstack routing ([#11994](https://github.com/linode/manager/pull/11994))

packages/manager/cypress/e2e/core/managed/managed-contacts.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { visitUrlWithManagedEnabled } from 'support/api/managed';
66
import {
77
mockCreateContact,
88
mockDeleteContact,
9+
mockGetContact,
910
mockGetContacts,
1011
mockUpdateContact,
1112
} from 'support/intercepts/managed';
@@ -148,6 +149,7 @@ describe('Managed Contacts tab', () => {
148149
},
149150
};
150151

152+
mockGetContact(contact).as('getContact');
151153
mockGetContacts([contact]).as('getContacts');
152154
mockUpdateContact(contactId, updatedContact).as('updateContact');
153155
visitUrlWithManagedEnabled('/managed/contacts');
@@ -165,6 +167,8 @@ describe('Managed Contacts tab', () => {
165167
.click();
166168
});
167169

170+
cy.wait('@getContact');
171+
168172
// Fill out and submit "Edit Contact" form.
169173
ui.drawer
170174
.findByTitle('Edit Contact')
@@ -216,6 +220,7 @@ describe('Managed Contacts tab', () => {
216220
name: contactName,
217221
});
218222

223+
mockGetContact(contact).as('getContact');
219224
mockGetContacts([contact]).as('getContacts');
220225
mockDeleteContact(contactId).as('deleteContact');
221226
visitUrlWithManagedEnabled('/managed/contacts');
@@ -233,6 +238,7 @@ describe('Managed Contacts tab', () => {
233238
.click();
234239
});
235240

241+
cy.wait('@getContact');
236242
// Fill out and submit type-to-confirm.
237243
ui.dialog
238244
.findByTitle(`Delete Contact ${contactName}?`)

packages/manager/cypress/e2e/core/managed/managed-credentials.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { visitUrlWithManagedEnabled } from 'support/api/managed';
66
import {
77
mockCreateCredential,
88
mockDeleteCredential,
9+
mockGetCredential,
910
mockGetCredentials,
1011
mockUpdateCredential,
1112
mockUpdateCredentialUsernamePassword,
@@ -120,6 +121,7 @@ describe('Managed Credentials tab', () => {
120121
};
121122

122123
mockGetCredentials([credential]).as('getCredentials');
124+
mockGetCredential(credential).as('getCredential');
123125
mockUpdateCredential(credentialId, updatedCredential).as(
124126
'updateCredential'
125127
);
@@ -141,6 +143,8 @@ describe('Managed Credentials tab', () => {
141143
.click();
142144
});
143145

146+
cy.wait('@getCredential');
147+
144148
// Fill out forms to update credential label, and username/password pair.
145149
ui.drawer
146150
.findByTitle(`Edit Credential: ${credentialOldLabel}`)
@@ -203,6 +207,7 @@ describe('Managed Credentials tab', () => {
203207
label: credentialLabel,
204208
});
205209

210+
mockGetCredential(credential).as('getCredential');
206211
mockGetCredentials([credential]).as('getCredentials');
207212
mockDeleteCredential(credentialId).as('deleteCredential');
208213
visitUrlWithManagedEnabled('/managed/credentials');
@@ -235,6 +240,8 @@ describe('Managed Credentials tab', () => {
235240
.click();
236241
});
237242

243+
cy.wait('@getCredential');
244+
238245
// Confirm that toast notification is shown and credential is no longer listed.
239246
cy.wait('@deleteCredential');
240247
ui.toast.assertMessage('Credential deleted successfully.');

0 commit comments

Comments
 (0)