Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dashboard): workflow trigger integration instructions MRK-317 #7612

Merged
merged 39 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
08f6809
fix: wup
scopsy Jan 23, 2025
d802e73
Merge branch 'next' into mrk-316-workflow-checklist
scopsy Jan 26, 2025
873e6c3
fix: pr
scopsy Jan 27, 2025
4a85c51
fix: items
scopsy Jan 27, 2025
98718d0
Update workflow-checklist.tsx
scopsy Jan 27, 2025
a58ded1
fix
scopsy Jan 27, 2025
9c956ca
fix: refactor
scopsy Jan 27, 2025
9beb535
fix: items
scopsy Jan 27, 2025
fd6465a
fix: pass info
scopsy Jan 27, 2025
1d145d1
fix: remove sync to prod checklist item
scopsy Jan 27, 2025
ebc08fe
Merge branch 'next' into mrk-316-workflow-checklist
scopsy Jan 27, 2025
79a7bc3
Merge branch 'next' into mrk-316-workflow-checklist
scopsy Jan 28, 2025
5e91a00
fix: items
scopsy Jan 28, 2025
3316eed
Update trigger-event.usecase.ts
scopsy Jan 28, 2025
ffa5d91
Update trigger-event.usecase.ts
scopsy Jan 28, 2025
fe00433
feat: add ff
scopsy Jan 28, 2025
4873891
fix: last triggered at field
scopsy Jan 28, 2025
e24ef28
Update trigger-event.usecase.ts
scopsy Jan 28, 2025
708e987
fix: items on pr
scopsy Jan 28, 2025
6f066fa
Merge branch 'next' into mrk-316-workflow-checklist
scopsy Jan 28, 2025
e409051
Update trigger-event.usecase.ts
scopsy Jan 28, 2025
eac51c4
fix: hide last triggered
scopsy Jan 28, 2025
309c572
fix: add instructions
scopsy Jan 28, 2025
90d718d
fix: langs
scopsy Jan 28, 2025
2dd0c95
wip: code block
scopsy Jan 28, 2025
f484041
fix: position
scopsy Jan 29, 2025
24ee0e7
feat: add snippets
scopsy Jan 29, 2025
d60336c
f
scopsy Jan 29, 2025
3d936a5
fix: blocks
scopsy Jan 29, 2025
97868e3
fix
scopsy Jan 29, 2025
6d6aec2
Merge branch 'next' into mrk-317-workflow-trigger-integration-instruc…
scopsy Jan 29, 2025
5278236
spelling fixe
scopsy Jan 29, 2025
0b77c58
fix: add cta
scopsy Jan 29, 2025
fdc4efa
fix: workflow origin
scopsy Jan 29, 2025
3a68369
Merge branch 'next' into mrk-317-workflow-trigger-integration-instruc…
scopsy Feb 3, 2025
101bc5a
Update test-workflow-logs-sidebar.tsx
scopsy Feb 4, 2025
0bf3712
Update test-workflow-instructions.tsx
scopsy Feb 4, 2025
efb13ab
fix: workflowId
scopsy Feb 4, 2025
86b502c
Merge branch 'next' into mrk-317-workflow-trigger-integration-instruc…
scopsy Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,9 @@
"facated",
"dotenvcreate",
"querybuilder",
"liquified"
"liquified",
"autoload",
"novugo"
],
"flagWords": [],
"patterns": [
Expand Down
158 changes: 132 additions & 26 deletions apps/dashboard/src/components/primitives/code-block.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,88 @@
import { useState } from 'react';
import { tags as t } from '@lezer/highlight';
import { langs, loadLanguage } from '@uiw/codemirror-extensions-langs';
import { createTheme } from '@uiw/codemirror-themes';
import CodeMirror from '@uiw/react-codemirror';
import { materialDark } from '@uiw/codemirror-theme-material';
import { Check, Eye, EyeOff } from 'lucide-react';
import { useState } from 'react';
import { RiFileCopyLine } from 'react-icons/ri';
import { cn } from '../../utils/ui';
import { langs, loadLanguage } from '@uiw/codemirror-extensions-langs';

loadLanguage('tsx');
loadLanguage('json');
loadLanguage('shell');
loadLanguage('typescript');
loadLanguage('php');
loadLanguage('go');
loadLanguage('python');

const languageMap = {
typescript: langs.typescript,
tsx: langs.tsx,
json: langs.json,
shell: langs.shell,
php: langs.php,
go: langs.go,
python: langs.python,
} as const;

export type Language = keyof typeof languageMap;

const darkTheme = createTheme({
theme: 'dark',
settings: {
background: 'rgba(14, 18, 27, 0.90)',
foreground: '#EEFFFF',
caret: '#FFCC00',
selection: '#80CBC440',
lineHighlight: '#000000',
gutterBackground: 'rgba(14, 18, 27, 0.90)',
gutterForeground: '#545454',
},
styles: [
{ tag: t.keyword, color: '#C792EA' },
{ tag: t.operator, color: '#89DDFF' },
{ tag: t.special(t.brace), color: '#89DDFF' },
{ tag: t.propertyName, color: '#FFCB6B' },
{ tag: t.definition(t.propertyName), color: '#82AAFF' },
{ tag: t.string, color: '#C3E88D' },
{ tag: t.comment, color: '#546E7A' },
{ tag: t.variableName, color: '#EEFFFF' },
{ tag: [t.function(t.variableName), t.definition(t.variableName)], color: '#82AAFF' },
{ tag: t.typeName, color: '#F07178' },
{ tag: t.className, color: '#FFCB6B' },
{ tag: t.number, color: '#F78C6C' },
{ tag: t.bool, color: '#F78C6C' },
],
});

const lightTheme = createTheme({
theme: 'light',
settings: {
background: 'white',
foreground: '#24292e',
caret: '#24292e',
selection: '#0366d625',
lineHighlight: '#0366d608',
},
styles: [
{ tag: t.keyword, color: '#FF5D00' },
{ tag: t.operator, color: '#FF5D00' },
{ tag: t.special(t.brace), color: '#24292e' },
{ tag: t.propertyName, color: '#FB4BA3' },
{ tag: t.definition(t.propertyName), color: '#24292e' },
{ tag: t.string, color: '#8B41E1' },
{ tag: t.comment, color: '#6e7781' },
{ tag: t.variableName, color: '#24292e' },
{ tag: [t.function(t.variableName), t.definition(t.variableName)], color: '#24292e' },
{ tag: t.typeName, color: '#0550ae' },
{ tag: t.className, color: '#0550ae' },
],
});

interface CodeBlockProps {
code: string;
language?: Language;
theme?: 'dark' | 'light';
title?: string;
className?: string;
secretMask?: {
Expand Down Expand Up @@ -69,7 +129,14 @@ interface CodeBlockProps {
* title="Configuration"
* />
*/
export function CodeBlock({ code, language = 'typescript', title, className, secretMask = [] }: CodeBlockProps) {
export function CodeBlock({
code,
language = 'typescript',
theme = 'dark',
title,
className,
secretMask = [],
}: CodeBlockProps) {
const [isCopied, setIsCopied] = useState(false);
Comment on lines +132 to +139
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the code-block component to be used across all the dashboard areas including workflow trigger page

const [showSecrets, setShowSecrets] = useState(false);

Expand Down Expand Up @@ -105,32 +172,71 @@ export function CodeBlock({ code, language = 'typescript', title, className, sec
return lines.join('\n');
};

return (
<div className={cn('w-full rounded-xl border bg-neutral-800 p-[5px] pt-0', className)}>
<div className="flex items-center justify-between px-2 py-1">
{title && <span className="text-foreground-400 text-xs">{title}</span>}
<div className="ml-auto flex items-center gap-1">
{hasSecrets && (
<button
onClick={() => setShowSecrets(!showSecrets)}
className="text-foreground-400 hover:text-foreground-50 rounded-md p-2 transition-all duration-200 hover:bg-[#32424a] active:scale-95"
title={showSecrets ? 'Hide secrets' : 'Reveal secrets'}
>
{showSecrets ? <EyeOff className="h-4 w-4" /> : <Eye className="h-4 w-4" />}
</button>
const ActionButtons = () => (
<>
{hasSecrets && (
<button
type="button"
onClick={() => setShowSecrets(!showSecrets)}
className={cn(
'rounded-md p-2 transition-all duration-200 active:scale-95',
theme === 'light'
? 'text-gray-500 hover:bg-gray-100 hover:text-gray-900'
: 'text-foreground-400 hover:text-foreground-50 hover:bg-[#32424a]'
)}
<button
onClick={copyToClipboard}
className="text-foreground-400 hover:text-foreground-50 rounded-md p-2 transition-all duration-200 hover:bg-[#32424a] active:scale-95"
title="Copy code"
title={showSecrets ? 'Hide secrets' : 'Reveal secrets'}
>
{showSecrets ? <EyeOff className="h-4 w-4" /> : <Eye className="h-4 w-4" />}
</button>
)}
<button
onClick={copyToClipboard}
type="button"
className={cn(
'rounded-md p-2 transition-all duration-200 active:scale-95',
theme === 'light'
? 'text-gray-500 hover:bg-gray-100 hover:text-gray-900'
: 'text-foreground-400 hover:text-foreground-50 hover:bg-[#32424a]'
)}
title="Copy code"
>
{isCopied ? <Check className="h-4 w-4" /> : <RiFileCopyLine className="h-4 w-4" />}
</button>
</>
);

return (
<div
className={cn(
'w-full rounded-xl border px-2 py-1',
theme === 'light' ? 'border-neutral-200 bg-white' : 'border-neutral-700 bg-neutral-800',
!title && 'rounded-b-none py-3',
className
)}
>
{title ? (
<div className={cn('-mx-[5px] -mt-[5px] mb-0 flex items-center justify-between px-2 py-1')}>
<span className={cn('text-xs', theme === 'light' ? 'text-gray-600' : 'text-foreground-400')}>{title}</span>
<div className="ml-auto flex items-center gap-1">
<ActionButtons />
</div>
</div>
) : (
<div className="relative">
<div
className={cn(
'absolute right-1 top-0 z-10 flex items-center gap-1 rounded-md',
theme === 'light' ? '' : 'bg-neutral-800/80',
'backdrop-blur-sm'
)}
>
{isCopied ? <Check className="h-4 w-4" /> : <RiFileCopyLine className="h-4 w-4" />}
</button>
<ActionButtons />
</div>
</div>
</div>
)}
<CodeMirror
value={getMaskedCode()}
theme={materialDark}
theme={theme === 'dark' ? darkTheme : lightTheme}
extensions={[languageMap[language]()]}
basicSetup={{
lineNumbers: true,
Expand All @@ -139,7 +245,7 @@ export function CodeBlock({ code, language = 'typescript', title, className, sec
foldGutter: false,
}}
editable={false}
className="overflow-hidden rounded-lg text-xs [&_.cm-gutters]:bg-[#263238] [&_.cm-scroller]:font-mono"
className={cn('overflow-hidden rounded-lg text-xs [&_.cm-editor]:py-3 [&_.cm-scroller]:font-mono')}
/>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/src/components/primitives/sonner-helpers.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReactNode } from 'react';
import { ExternalToast, toast } from 'sonner';
import { Toast, ToastIcon, ToastProps } from './sonner';
import { ReactNode } from 'react';

export const showToast = ({
options,
Expand Down Expand Up @@ -33,7 +33,7 @@ export const showSuccessToast = (message: string, position: 'bottom-center' | 't
export const showErrorToast = (
message: string,
title?: string,
position: 'bottom-center' | 'top-center' = 'bottom-center'
position: 'bottom-center' | 'top-center' | 'bottom-right' = 'bottom-right'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make the default to right side

) => {
showToast({
title,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,5 @@
import { Editor } from '@/components/primitives/editor';
import { LanguageName, loadLanguage } from '@uiw/codemirror-extensions-langs';
import { EditorView } from '@uiw/react-codemirror';
import { useMemo } from 'react';
import type { SnippetLanguage } from './types';
import { CodeBlock, Language } from '../../primitives/code-block';

const basicSetup = { lineNumbers: true };

export const SnippetEditor = ({
language,
value,
readOnly = false,
}: {
language: SnippetLanguage;
value: string;
readOnly?: boolean;
}) => {
const editorLanguage: LanguageName = language === 'framework' ? 'typescript' : language;

const extensions = useMemo(() => {
const res = [EditorView.lineWrapping];
const langExtension = loadLanguage(editorLanguage)?.extension;
if (langExtension) {
res.push(langExtension);
}
return res;
}, [editorLanguage]);

return (
<Editor
readOnly={readOnly}
lang={editorLanguage}
className="h-full"
value={value}
extensions={extensions}
basicSetup={basicSetup}
multiline
/>
);
export const SnippetEditor = ({ language, value }: { language: Language; value: string }) => {
return <CodeBlock theme="light" className="h-full overflow-auto" language={language} code={value} />;
};
Comment on lines +3 to +4
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated it to use the code block reusable component instead of the current code mirror implementation to consolidate look and feel across all the snippets in the app

Loading
Loading