Skip to content

Commit d307abe

Browse files
author
Barthélémy Ledoux
authored
feat: wire up the manage record keys button (#19829)
1 parent 5cac74c commit d307abe

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

packages/app/cypress/e2e/settings.cy.ts

+21
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,27 @@ describe('App: Settings', () => {
2424
cy.findByText('Project ID').should('be.visible')
2525
})
2626

27+
it('shows the recordKeys section', () => {
28+
cy.loginUser()
29+
30+
cy.visitApp()
31+
cy.findByText('Settings').click()
32+
cy.findByText('Project Settings').click()
33+
cy.findByText('Record Key').should('be.visible')
34+
})
35+
36+
it('opens cloud settings when clicking on "Manage Keys"', () => {
37+
cy.loginUser()
38+
cy.intercept('mutation-ExternalLink_OpenExternal', { 'data': { 'openExternal': true } }).as('OpenExternal')
39+
cy.visitApp()
40+
cy.findByText('Settings').click()
41+
cy.findByText('Project Settings').click()
42+
cy.findByText('Manage Keys').click()
43+
cy.wait('@OpenExternal')
44+
.its('request.body.variables.url')
45+
.should('equal', 'http:/test.cloud/cloud-project/settings')
46+
})
47+
2748
it('can reconfigure a project', () => {
2849
cy.visitApp('settings')
2950

packages/app/src/settings/project/ProjectSettings.vue

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
v-for="key of props.gql.currentProject.cloudProject.recordKeys"
99
:key="key.id"
1010
:gql="key"
11+
:manage-keys-url="props.gql.currentProject.cloudProject.cloudProjectSettingsUrl"
1112
/>
1213
</template>
1314
<SpecPatterns :gql="props.gql.currentProject" />
@@ -34,6 +35,7 @@ fragment ProjectSettings on Query {
3435
__typename
3536
... on CloudProject {
3637
id
38+
cloudProjectSettingsUrl
3739
recordKeys {
3840
id
3941
...RecordKey

packages/app/src/settings/project/RecordKey.cy.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('<RecordKey />', () => {
1212
},
1313
render: (gql) => (
1414
<div class="py-4 px-8">
15-
<RecordKey gql={gql} />
15+
<RecordKey gql={gql} manageKeysUrl="http://project.cypress.io/settings" />
1616
</div>
1717
),
1818
})

packages/app/src/settings/project/RecordKey.vue

+12-10
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</template>
2121
<div
2222
v-if="recordKey"
23-
class="inline-flex justify-start gap-10px"
23+
class="gap-10px inline-flex justify-start"
2424
>
2525
<CodeBox
2626
:code="recordKey"
@@ -45,16 +45,19 @@
4545

4646
<script lang="ts" setup>
4747
import { computed, ref } from 'vue'
48-
import { useI18n } from '@cy/i18n'
49-
import type { RecordKeyFragment } from '../../generated/graphql'
50-
import SettingsSection from '../SettingsSection.vue'
48+
import { gql } from '@urql/core'
5149
import Button from '@cy/components/Button.vue'
50+
import CopyButton from '@cy/components/CopyButton.vue'
51+
import ExternalLink from '@cy/gql-components/ExternalLink.vue'
52+
import { useExternalLink } from '@cy/gql-components/useExternalLink'
5253
import IconKey from '~icons/cy/placeholder_x16.svg'
5354
import IconExport from '~icons/cy/export_x16.svg'
54-
import { gql } from '@urql/core'
55-
import CopyButton from '@cy/components/CopyButton.vue'
55+
import type { RecordKeyFragment } from '../../generated/graphql'
56+
import SettingsSection from '../SettingsSection.vue'
5657
import CodeBox from './CodeBox.vue'
57-
import ExternalLink from '@packages/frontend-shared/src/gql-components/ExternalLink.vue'
58+
import { useI18n } from '@cy/i18n'
59+
60+
const { t } = useI18n()
5861
5962
gql`
6063
fragment RecordKey on CloudRecordKey {
@@ -65,11 +68,10 @@ fragment RecordKey on CloudRecordKey {
6568
6669
const props = defineProps<{
6770
gql: RecordKeyFragment
71+
manageKeysUrl: string
6872
}>()
6973
70-
const openManageKeys = () => { }
71-
const showRecordKey = ref(false)
72-
const { t } = useI18n()
74+
const openManageKeys = useExternalLink(props.manageKeysUrl)
7375
7476
const recordKey = computed(() => props.gql.key)
7577
</script>

0 commit comments

Comments
 (0)