From d307abe1f152601a0c17abc64cd0d96bccb0522b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barth=C3=A9l=C3=A9my=20Ledoux?= Date: Sun, 23 Jan 2022 21:41:24 -0600 Subject: [PATCH] feat: wire up the manage record keys button (#19829) --- packages/app/cypress/e2e/settings.cy.ts | 21 ++++++++++++++++++ .../src/settings/project/ProjectSettings.vue | 2 ++ .../app/src/settings/project/RecordKey.cy.tsx | 2 +- .../app/src/settings/project/RecordKey.vue | 22 ++++++++++--------- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/packages/app/cypress/e2e/settings.cy.ts b/packages/app/cypress/e2e/settings.cy.ts index a5dfaf9f2189..3e165d218abb 100644 --- a/packages/app/cypress/e2e/settings.cy.ts +++ b/packages/app/cypress/e2e/settings.cy.ts @@ -24,6 +24,27 @@ describe('App: Settings', () => { cy.findByText('Project ID').should('be.visible') }) + it('shows the recordKeys section', () => { + cy.loginUser() + + cy.visitApp() + cy.findByText('Settings').click() + cy.findByText('Project Settings').click() + cy.findByText('Record Key').should('be.visible') + }) + + it('opens cloud settings when clicking on "Manage Keys"', () => { + cy.loginUser() + cy.intercept('mutation-ExternalLink_OpenExternal', { 'data': { 'openExternal': true } }).as('OpenExternal') + cy.visitApp() + cy.findByText('Settings').click() + cy.findByText('Project Settings').click() + cy.findByText('Manage Keys').click() + cy.wait('@OpenExternal') + .its('request.body.variables.url') + .should('equal', 'http:/test.cloud/cloud-project/settings') + }) + it('can reconfigure a project', () => { cy.visitApp('settings') diff --git a/packages/app/src/settings/project/ProjectSettings.vue b/packages/app/src/settings/project/ProjectSettings.vue index d1a880717097..74254a4270bc 100644 --- a/packages/app/src/settings/project/ProjectSettings.vue +++ b/packages/app/src/settings/project/ProjectSettings.vue @@ -8,6 +8,7 @@ v-for="key of props.gql.currentProject.cloudProject.recordKeys" :key="key.id" :gql="key" + :manage-keys-url="props.gql.currentProject.cloudProject.cloudProjectSettingsUrl" /> @@ -34,6 +35,7 @@ fragment ProjectSettings on Query { __typename ... on CloudProject { id + cloudProjectSettingsUrl recordKeys { id ...RecordKey diff --git a/packages/app/src/settings/project/RecordKey.cy.tsx b/packages/app/src/settings/project/RecordKey.cy.tsx index e1f039c428df..e83f0785941a 100644 --- a/packages/app/src/settings/project/RecordKey.cy.tsx +++ b/packages/app/src/settings/project/RecordKey.cy.tsx @@ -12,7 +12,7 @@ describe('', () => { }, render: (gql) => (
- +
), }) diff --git a/packages/app/src/settings/project/RecordKey.vue b/packages/app/src/settings/project/RecordKey.vue index 4e8eef230bf7..687c4c9fd407 100644 --- a/packages/app/src/settings/project/RecordKey.vue +++ b/packages/app/src/settings/project/RecordKey.vue @@ -20,7 +20,7 @@
import { computed, ref } from 'vue' -import { useI18n } from '@cy/i18n' -import type { RecordKeyFragment } from '../../generated/graphql' -import SettingsSection from '../SettingsSection.vue' +import { gql } from '@urql/core' import Button from '@cy/components/Button.vue' +import CopyButton from '@cy/components/CopyButton.vue' +import ExternalLink from '@cy/gql-components/ExternalLink.vue' +import { useExternalLink } from '@cy/gql-components/useExternalLink' import IconKey from '~icons/cy/placeholder_x16.svg' import IconExport from '~icons/cy/export_x16.svg' -import { gql } from '@urql/core' -import CopyButton from '@cy/components/CopyButton.vue' +import type { RecordKeyFragment } from '../../generated/graphql' +import SettingsSection from '../SettingsSection.vue' import CodeBox from './CodeBox.vue' -import ExternalLink from '@packages/frontend-shared/src/gql-components/ExternalLink.vue' +import { useI18n } from '@cy/i18n' + +const { t } = useI18n() gql` fragment RecordKey on CloudRecordKey { @@ -65,11 +68,10 @@ fragment RecordKey on CloudRecordKey { const props = defineProps<{ gql: RecordKeyFragment + manageKeysUrl: string }>() -const openManageKeys = () => { } -const showRecordKey = ref(false) -const { t } = useI18n() +const openManageKeys = useExternalLink(props.manageKeysUrl) const recordKey = computed(() => props.gql.key)