-
Notifications
You must be signed in to change notification settings - Fork 2
added Create Pipeline button and template modal to file explorer #340
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
266a80b
added Create Pipeline button and template modal to file explorer
flakronademi 5aabbb3
Merge remote-tracking branch 'origin/dev' into feature/create-pipelin…
flakronademi becf0c5
made Create Pipeline button always visible in sidebar instead of cond…
flakronademi 0f6a295
fix lint error
flakronademi 825c2d4
feat(createPipelineModal): redesign with gradient header and improved UX
flakronademi 3b24a7b
renamed getting started pipeline from pipeline.yml to pipeline-gettin…
flakronademi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
358 changes: 358 additions & 0 deletions
358
src/renderer/components/modals/createPipelineModal/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,358 @@ | ||
| import React from 'react'; | ||
| import { | ||
| Box, | ||
| Button, | ||
| Typography, | ||
| Stack, | ||
| Paper, | ||
| alpha, | ||
| CircularProgress, | ||
| Chip, | ||
| } from '@mui/material'; | ||
| import { | ||
| Close, | ||
| AccountTree, | ||
| CheckCircleOutline, | ||
| PlayArrow, | ||
| Code, | ||
| } from '@mui/icons-material'; | ||
| import { useTheme } from '@mui/material/styles'; | ||
| import { toast } from 'react-toastify'; | ||
| import { Modal } from '../modal'; | ||
| import { projectsServices } from '../../../services'; | ||
| import { Project } from '../../../../types/backend'; | ||
|
|
||
| interface PipelineTemplate { | ||
| id: string; | ||
| label: string; | ||
| description: string; | ||
| badge?: string; | ||
| steps: string[]; | ||
| content: string; | ||
| } | ||
|
|
||
| const TEMPLATES: PipelineTemplate[] = [ | ||
| { | ||
| id: 'getting-started', | ||
| label: 'Getting Started', | ||
| badge: 'Recommended', | ||
| description: | ||
| 'A simple pipeline that runs dbt deps, dbt test, and a teardown step. Perfect for new projects.', | ||
| steps: ['dbt deps', 'dbt test', 'teardown'], | ||
| content: `name: "CI" | ||
| jobs: | ||
| - name: "setup" | ||
| steps: | ||
| - name: Install dependencies | ||
| plugin: dbt@v1 | ||
| command: dbt deps | ||
| - name: "run-dbt-command" | ||
| steps: | ||
| - name: dbt test | ||
| plugin: dbt@v1 | ||
| command: dbt test | ||
| - name: "teardown" | ||
| type: "cleanup" | ||
| steps: | ||
| - name: Run teardown | ||
| plugin: command@v1 | ||
| command: echo "TEARDOWN" | ||
| `, | ||
| }, | ||
| { | ||
| id: 'full-ci', | ||
| label: 'Full CI/CD', | ||
| badge: 'Advanced', | ||
| description: | ||
| 'A complete pipeline with dependency install, model runs, tests, freshness checks, and a deploy notification step.', | ||
| steps: [ | ||
| 'dbt deps', | ||
| 'dbt run', | ||
| 'dbt test', | ||
| 'dbt source freshness', | ||
| 'deploy', | ||
| ], | ||
| content: `name: "Full CI/CD" | ||
| jobs: | ||
| - name: "setup" | ||
| steps: | ||
| - name: Install dependencies | ||
| plugin: dbt@v1 | ||
| command: dbt deps | ||
| - name: "build" | ||
| steps: | ||
| - name: Run models | ||
| plugin: dbt@v1 | ||
| command: dbt run | ||
| - name: "test" | ||
| steps: | ||
| - name: Run tests | ||
| plugin: dbt@v1 | ||
| command: dbt test | ||
| - name: Check source freshness | ||
| plugin: dbt@v1 | ||
| command: dbt source freshness | ||
| - name: "deploy" | ||
| steps: | ||
| - name: Notify deployment | ||
| plugin: command@v1 | ||
| command: echo "Deployment complete" | ||
| - name: "teardown" | ||
| type: "cleanup" | ||
| steps: | ||
| - name: Run teardown | ||
| plugin: command@v1 | ||
| command: echo "TEARDOWN" | ||
| `, | ||
| }, | ||
| ]; | ||
|
|
||
| interface CreatePipelineModalProps { | ||
| isOpen: boolean; | ||
| onClose: () => void; | ||
| project: Project; | ||
| onCreated: (filePath: string) => void; | ||
| } | ||
|
|
||
| export const CreatePipelineModal: React.FC<CreatePipelineModalProps> = ({ | ||
| isOpen, | ||
| onClose, | ||
| project, | ||
| onCreated, | ||
| }) => { | ||
| const theme = useTheme(); | ||
| const [selectedTemplateId, setSelectedTemplateId] = React.useState< | ||
| string | null | ||
| >(null); | ||
| const [isCreating, setIsCreating] = React.useState(false); | ||
|
|
||
| // Reset selection when modal opens | ||
| React.useEffect(() => { | ||
| if (isOpen) { | ||
| setSelectedTemplateId(null); | ||
| } | ||
| }, [isOpen]); | ||
|
|
||
| const handleCreate = async () => { | ||
| if (!selectedTemplateId) return; | ||
|
|
||
| const template = TEMPLATES.find((t) => t.id === selectedTemplateId); | ||
| if (!template) return; | ||
|
|
||
| setIsCreating(true); | ||
| try { | ||
| // Ensure .rosetta directory exists | ||
| await projectsServices.createFolder({ | ||
| filePath: project.path, | ||
| name: '.rosetta', | ||
| }); | ||
|
|
||
| const pipelinePath = `${project.path}/.rosetta/pipeline.yml`; | ||
| await projectsServices.saveFileContent({ | ||
| path: pipelinePath, | ||
| content: template.content, | ||
| }); | ||
|
|
||
| toast.success('Pipeline created successfully.'); | ||
| onCreated(pipelinePath); | ||
| onClose(); | ||
| } catch (error) { | ||
| const msg = | ||
| error instanceof Error ? error.message : 'Failed to create pipeline'; | ||
| toast.error(msg); | ||
| } finally { | ||
| setIsCreating(false); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <Modal | ||
| isOpen={isOpen} | ||
| onClose={onClose} | ||
| title="Create Pipeline" | ||
| maxWidth="sm" | ||
| > | ||
| <Stack spacing={3}> | ||
| {/* Header description */} | ||
| <Typography variant="body2" color="text.secondary"> | ||
| Choose a template to scaffold your pipeline. The file will be created | ||
| at <code>.rosetta/pipeline.yml</code> in your project. | ||
| </Typography> | ||
|
|
||
| {/* Template cards */} | ||
| <Stack spacing={1.5}> | ||
| {TEMPLATES.map((template) => { | ||
| const isSelected = selectedTemplateId === template.id; | ||
| return ( | ||
| <Paper | ||
| key={template.id} | ||
| variant="outlined" | ||
| onClick={() => setSelectedTemplateId(template.id)} | ||
| sx={{ | ||
| p: 2, | ||
| cursor: 'pointer', | ||
| border: '1px solid', | ||
| borderColor: isSelected | ||
| ? 'primary.main' | ||
| : theme.palette.divider, | ||
| bgcolor: isSelected | ||
| ? alpha( | ||
| theme.palette.primary.main, | ||
| theme.palette.mode === 'dark' ? 0.1 : 0.04, | ||
| ) | ||
| : 'background.paper', | ||
| transition: 'border-color 0.15s, background-color 0.15s', | ||
| '&:hover': { | ||
| borderColor: 'primary.main', | ||
| bgcolor: alpha( | ||
| theme.palette.primary.main, | ||
| theme.palette.mode === 'dark' ? 0.08 : 0.03, | ||
| ), | ||
| }, | ||
| }} | ||
| > | ||
| <Box | ||
| sx={{ | ||
| display: 'flex', | ||
| alignItems: 'flex-start', | ||
| gap: 1.5, | ||
| }} | ||
| > | ||
| {/* Icon */} | ||
| <Box | ||
| sx={{ | ||
| mt: 0.25, | ||
| p: 0.75, | ||
| borderRadius: 1, | ||
| bgcolor: isSelected | ||
| ? alpha(theme.palette.primary.main, 0.12) | ||
| : alpha(theme.palette.text.secondary, 0.08), | ||
| color: isSelected ? 'primary.main' : 'text.secondary', | ||
| display: 'flex', | ||
| flexShrink: 0, | ||
| }} | ||
| > | ||
| <AccountTree sx={{ fontSize: 18 }} /> | ||
| </Box> | ||
|
|
||
| {/* Content */} | ||
| <Box sx={{ flex: 1, minWidth: 0 }}> | ||
| <Box | ||
| sx={{ | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| gap: 1, | ||
| mb: 0.5, | ||
| }} | ||
| > | ||
| <Typography | ||
| variant="body2" | ||
| fontWeight={600} | ||
| color={isSelected ? 'primary.main' : 'text.primary'} | ||
| > | ||
| {template.label} | ||
| </Typography> | ||
| {template.badge && ( | ||
| <Chip | ||
| label={template.badge} | ||
| size="small" | ||
| color="primary" | ||
| variant="outlined" | ||
| sx={{ height: 18, fontSize: '0.6rem' }} | ||
| /> | ||
| )} | ||
| </Box> | ||
| <Typography | ||
| variant="caption" | ||
| color="text.secondary" | ||
| sx={{ lineHeight: 1.5, display: 'block' }} | ||
| > | ||
| {template.description} | ||
| </Typography> | ||
|
|
||
| {/* Steps preview */} | ||
| <Box | ||
| sx={{ | ||
| mt: 1, | ||
| display: 'flex', | ||
| gap: 0.5, | ||
| flexWrap: 'wrap', | ||
| }} | ||
| > | ||
| {template.steps.map((step) => ( | ||
| <Box | ||
| key={step} | ||
| sx={{ | ||
| display: 'inline-flex', | ||
| alignItems: 'center', | ||
| gap: 0.4, | ||
| px: 0.75, | ||
| py: 0.25, | ||
| borderRadius: 0.75, | ||
| bgcolor: alpha(theme.palette.text.secondary, 0.07), | ||
| }} | ||
| > | ||
| <Code sx={{ fontSize: 10, opacity: 0.6 }} /> | ||
| <Typography | ||
| variant="caption" | ||
| sx={{ fontSize: '0.65rem', opacity: 0.8 }} | ||
| > | ||
| {step} | ||
| </Typography> | ||
| </Box> | ||
| ))} | ||
| </Box> | ||
| </Box> | ||
|
|
||
| {/* Checkmark */} | ||
| {isSelected && ( | ||
| <CheckCircleOutline | ||
| sx={{ | ||
| color: 'primary.main', | ||
| fontSize: 20, | ||
| flexShrink: 0, | ||
| }} | ||
| /> | ||
| )} | ||
| </Box> | ||
| </Paper> | ||
| ); | ||
| })} | ||
| </Stack> | ||
|
|
||
| {/* Footer actions */} | ||
| <Box | ||
| display="flex" | ||
| justifyContent="flex-end" | ||
| gap={1.5} | ||
| pt={1} | ||
| borderTop={`1px solid ${theme.palette.divider}`} | ||
| > | ||
| <Button | ||
| variant="outlined" | ||
| onClick={onClose} | ||
| startIcon={<Close />} | ||
| sx={{ | ||
| minWidth: 100, | ||
| borderColor: alpha(theme.palette.divider, 0.5), | ||
| }} | ||
| > | ||
| Cancel | ||
| </Button> | ||
| <Button | ||
| variant="contained" | ||
| color="primary" | ||
| onClick={handleCreate} | ||
| disabled={!selectedTemplateId || isCreating} | ||
| startIcon={ | ||
| isCreating ? <CircularProgress size={16} /> : <PlayArrow /> | ||
| } | ||
| sx={{ minWidth: 140, fontWeight: 600 }} | ||
| > | ||
| {isCreating ? 'Creating...' : 'Create Pipeline'} | ||
| </Button> | ||
| </Box> | ||
| </Stack> | ||
| </Modal> | ||
| ); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Template cards aren't keyboard-accessible.
Selection relies solely on
onClickon aPaper; there's norole="button",tabIndex, oronKeyDown(Enter/Space) handling, so keyboard-only users cannot select a template at all.♿ Proposed fix
<Paper key={template.id} variant="outlined" onClick={() => setSelectedTemplateId(template.id)} + role="button" + tabIndex={0} + aria-pressed={isSelected} + onKeyDown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault(); + setSelectedTemplateId(template.id); + } + }} sx={{📝 Committable suggestion
🤖 Prompt for AI Agents