Skip to content

Commit

Permalink
refactor(SyncInfoModal): replace useApiKeysPage with useStudioState (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rifont authored Jul 1, 2024
1 parent 5d59c16 commit 30df5d4
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions apps/web/src/components/layout/components/v2/SyncInfoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { Prism } from '@mantine/prism';
import { Modal } from '@novu/design-system';
import { Tabs, Text, Title } from '@novu/novui';
import { FC } from 'react';
import { useApiKeysPage } from '../../../../pages/settings/ApiKeysPage/useApiKeysPage';
import { useBridgeURL } from '../../../../studio/hooks/useBridgeURL';
import { API_ROOT, ENV } from '../../../../config';
import { useStudioState } from '../../../../studio/StudioStateProvider';

export type SyncInfoModalProps = {
isOpen: boolean;
Expand All @@ -16,7 +16,7 @@ export type SyncInfoModalProps = {
const BRIDGE_ENDPOINT_PLACEHOLDER = '<YOUR_BRIDGE_URL>';

export const SyncInfoModal: FC<SyncInfoModalProps> = ({ isOpen, toggleOpen }) => {
const { secretKey } = useApiKeysPage();
const { devSecretKey } = useStudioState();
const bridgeUrl = useBridgeURL(true);

const tabs = [
Expand All @@ -25,7 +25,7 @@ export const SyncInfoModal: FC<SyncInfoModalProps> = ({ isOpen, toggleOpen }) =>
label: 'CLI',
content: (
<Prism withLineNumbers language="bash">
{getOtherCodeContent({ secretKey, bridgeUrl })}
{getOtherCodeContent({ secretKey: devSecretKey || '', bridgeUrl })}
</Prism>
),
},
Expand All @@ -34,7 +34,7 @@ export const SyncInfoModal: FC<SyncInfoModalProps> = ({ isOpen, toggleOpen }) =>
label: 'GitHub Actions',
content: (
<Prism withLineNumbers language="yaml">
{getGithubYamlContent({ secretKey, bridgeUrl })}
{getGithubYamlContent({ bridgeUrl })}
</Prism>
),
},
Expand All @@ -56,8 +56,9 @@ export const SyncInfoModal: FC<SyncInfoModalProps> = ({ isOpen, toggleOpen }) =>
);
};

function getGithubYamlContent({ secretKey, bridgeUrl }: { secretKey: string; bridgeUrl: string }) {
return `name: Deploy Workflow State to Novu
function getGithubYamlContent({ bridgeUrl }: { bridgeUrl: string }) {
return `# .github/workflows/novu.yml
name: Novu Sync
on:
workflow_dispatch:
Expand All @@ -67,10 +68,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Sync State to Novu
uses: novuhq/actions-novu-sync@v0.0.4
uses: novuhq/actions-novu-sync@v2
with:
secret-key: $\{{ secrets.NOVU_SECRET_KEY }}
bridge-url: ${bridgeUrl || BRIDGE_ENDPOINT_PLACEHOLDER}`;
Expand Down

0 comments on commit 30df5d4

Please sign in to comment.