Skip to content

Commit 8707424

Browse files
feat: add more deeplinks (#3833)
1 parent 250f037 commit 8707424

File tree

3 files changed

+151
-10
lines changed

3 files changed

+151
-10
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import {Organization} from '../../../src/types'
2+
3+
describe('Deep linking', () => {
4+
beforeEach(() => {
5+
cy.flush()
6+
cy.signin()
7+
})
8+
9+
// If you're here and the test failure you're looking at is legitimate, it probably means a page
10+
// that a deep link pointed to has changed. There are implications to this; docs and marketing pages
11+
// might use the deep link that has changed. We want to avoid having broken deep links out on the web,
12+
// so there might be some follow-up work necessary with docs or marketing pages.
13+
it.skip('should be redirected to the approprate page from a shortened link', () => {
14+
cy.get('@org').then((org: Organization) => {
15+
cy.setFeatureFlags({
16+
deepLinking: true,
17+
}).then(() => {
18+
cy.wait(1000)
19+
cy.visit('/me/about')
20+
cy.location('pathname').should('eq', `/orgs/${org.id}/about`)
21+
22+
cy.visit('/me/alerts')
23+
cy.location('pathname').should('eq', `/orgs/${org.id}/alerting`)
24+
25+
cy.visit('/me/billing')
26+
cy.location('pathname').should('eq', `/orgs/${org.id}/billing`)
27+
28+
cy.visit('/me/buckets')
29+
cy.location('pathname').should(
30+
'eq',
31+
`/orgs/${org.id}/load-data/buckets`
32+
)
33+
34+
cy.visit('/me/csharpclient')
35+
cy.location('pathname').should(
36+
'eq',
37+
`/orgs/${org.id}/load-data/client-libraries/csharp`
38+
)
39+
40+
cy.visit('/me/dashboards')
41+
cy.location('pathname').should('eq', `/orgs/${org.id}/dashboards-list`)
42+
43+
cy.visit('/me/data-explorer')
44+
cy.location('pathname').should('eq', `/orgs/${org.id}/data-explorer`)
45+
46+
cy.visit('/me/goclient')
47+
cy.location('pathname').should(
48+
'eq',
49+
`/orgs/${org.id}/load-data/client-libraries/go`
50+
)
51+
52+
cy.visit('/me/home')
53+
cy.location('pathname').should('eq', `/orgs/${org.id}`)
54+
55+
cy.visit('/me/labels')
56+
cy.location('pathname').should('eq', `/orgs/${org.id}/settings/labels`)
57+
58+
cy.visit('/me/load-data')
59+
cy.location('pathname').should(
60+
'eq',
61+
`/orgs/${org.id}/load-data/sources`
62+
)
63+
64+
cy.visit('/me/nodejsclient')
65+
cy.location('pathname').should(
66+
'eq',
67+
`/orgs/${org.id}/load-data/client-libraries/javascript-node`
68+
)
69+
70+
cy.visit('/me/notebooks')
71+
cy.location('pathname').should('eq', `/orgs/${org.id}/notebooks`)
72+
73+
cy.visit('/me/pythonclient')
74+
cy.location('pathname').should(
75+
'eq',
76+
`/orgs/${org.id}/load-data/client-libraries/python`
77+
)
78+
79+
cy.visit('/me/secrets')
80+
cy.location('pathname').should('eq', `/orgs/${org.id}/settings/secrets`)
81+
82+
cy.visit('/me/tasks')
83+
cy.location('pathname').should('eq', `/orgs/${org.id}/tasks`)
84+
85+
cy.visit('/me/telegraf-mqtt')
86+
cy.location('pathname').should(
87+
'eq',
88+
`/orgs/${org.id}/load-data/telegraf-plugins/mqtt_consumer`
89+
)
90+
91+
cy.visit('/me/telegrafs')
92+
cy.location('pathname').should(
93+
'eq',
94+
`/orgs/${org.id}/load-data/telegrafs`
95+
)
96+
97+
cy.visit('/me/templates')
98+
cy.location('pathname').should(
99+
'eq',
100+
`/orgs/${org.id}/settings/templates`
101+
)
102+
103+
cy.visit('/me/tokens')
104+
cy.location('pathname').should('eq', `/orgs/${org.id}/load-data/tokens`)
105+
106+
cy.visit('/me/usage')
107+
cy.location('pathname').should('eq', `/orgs/${org.id}/usage`)
108+
109+
cy.visit('/me/users')
110+
cy.location('pathname').should('eq', `/orgs/${org.id}/users`)
111+
112+
cy.visit('/me/variables')
113+
cy.location('pathname').should(
114+
'eq',
115+
`/orgs/${org.id}/settings/variables`
116+
)
117+
})
118+
})
119+
})
120+
})

src/shared/components/NotFound.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {AppState, Organization} from 'src/types'
2424

2525
// Utils
2626
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
27+
import {buildDeepLinkingMap} from 'src/utils/deepLinks'
2728

2829
// Components
2930
import LogoWithCubo from 'src/checkout/LogoWithCubo'
@@ -157,21 +158,13 @@ class NotFound extends Component<Props> {
157158
org = await fetchOrg()
158159
}
159160

160-
const deepLinkingMap = {
161-
'/me/alerts': `/orgs/${org.id}/alerting`,
162-
'/me/billing': `/orgs/${org.id}/billing`,
163-
'/me/dashboards': `/orgs/${org.id}/dashboards-list`,
164-
'/me/notebooks': `/orgs/${org.id}/notebooks`,
165-
'/me/tasks': `/orgs/${org.id}/tasks`,
166-
'/me/usage': `/orgs/${org.id}/usage`,
167-
}
161+
const deepLinkingMap = buildDeepLinkingMap(org)
168162

169163
if (deepLinkingMap.hasOwnProperty(this.props.location.pathname)) {
170164
this.props.history.replace(deepLinkingMap[this.props.location.pathname])
171165
return
172-
} else {
173-
this.setState({isFetchingOrg: false})
174166
}
167+
this.setState({isFetchingOrg: false})
175168
}
176169
}
177170

src/utils/deepLinks.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import {Organization} from 'src/client'
2+
3+
export const buildDeepLinkingMap = (org: Organization) => ({
4+
'/me/about': `/orgs/${org.id}/about`,
5+
'/me/alerts': `/orgs/${org.id}/alerting`,
6+
'/me/billing': `/orgs/${org.id}/billing`,
7+
'/me/buckets': `/orgs/${org.id}/load-data/buckets`,
8+
'/me/csharpclient': `/orgs/${org.id}/load-data/client-libraries/csharp`,
9+
'/me/dashboards': `/orgs/${org.id}/dashboards-list`,
10+
'/me/data-explorer': `/orgs/${org.id}/data-explorer`,
11+
'/me/goclient': `/orgs/${org.id}/load-data/client-libraries/go`,
12+
'/me/home': `/orgs/${org.id}`,
13+
'/me/javaclient': `/orgs/${org.id}/load-data/client-libraries/java`,
14+
'/me/labels': `/orgs/${org.id}/settings/labels`,
15+
'/me/load-data': `/orgs/${org.id}/load-data/sources`,
16+
'/me/nodejsclient': `/orgs/${org.id}/load-data/client-libraries/javascript-node`,
17+
'/me/notebooks': `/orgs/${org.id}/notebooks`,
18+
'/me/pythonclient': `/orgs/${org.id}/load-data/client-libraries/python`,
19+
'/me/secrets': `/orgs/${org.id}/settings/secrets`,
20+
'/me/tasks': `/orgs/${org.id}/tasks`,
21+
'/me/telegraf-mqtt': `/orgs/${org.id}/load-data/telegraf-plugins/mqtt_consumer`,
22+
'/me/telegrafs': `/orgs/${org.id}/load-data/telegrafs`,
23+
'/me/templates': `/orgs/${org.id}/settings/templates`,
24+
'/me/tokens': `/orgs/${org.id}/load-data/tokens`,
25+
'/me/usage': `/orgs/${org.id}/usage`,
26+
'/me/users': `/orgs/${org.id}/users`,
27+
'/me/variables': `/orgs/${org.id}/settings/variables`,
28+
})

0 commit comments

Comments
 (0)