Skip to content

Commit

Permalink
feat: show resource digests on nodes
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Phelps <[email protected]>
  • Loading branch information
markphelps committed Nov 19, 2024
1 parent 02219bb commit b422e0e
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 80 deletions.
1 change: 1 addition & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
<!-- Docsify v4 -->
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-go.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-yaml.min.js"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func (s *Server) setupRoutes() {
s.router.Use(middleware.Logger)
s.router.Use(middleware.Recoverer)
s.router.Use(middleware.StripSlashes)
s.router.Mount("/debug", middleware.Profiler())

if s.ui != nil {
s.router.Mount("/", http.FileServer(http.FS(s.ui)))
}

s.router.Group(func(r chi.Router) {
r.Use(middleware.StripSlashes)
// TODO: make CORS configurable
r.Use(cors.Handler(cors.Options{
AllowedOrigins: []string{"http://*", "https://*"},
Expand Down Expand Up @@ -133,7 +134,6 @@ func (s *Server) createPipelineResponse(ctx context.Context, pipeline core.Pipel
return pipelineResponse{}, err
}
response.Value = v

phases = append(phases, response)
}

Expand Down
7 changes: 5 additions & 2 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"lucide-react": "^0.454.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-redux": "^9.1.2",
"tailwind-merge": "^2.5.4",
"tailwindcss-animate": "^1.0.7"
}
Expand Down
7 changes: 5 additions & 2 deletions ui/src/components/node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger
} from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { useState } from 'react';
Expand Down Expand Up @@ -65,7 +64,11 @@ const PhaseNode = ({ data }: NodeProps<PhaseNodeType>) => {
)}
</div>

<div className="mt-3 flex w-full flex-col">
<div className="mt-2 font-mono text-xs text-muted-foreground">
{data.value?.digest?.slice(-12)}
</div>

<div className="mt-2 flex w-full flex-col">
{data.labels &&
Object.entries(data.labels).length > 0 &&
Object.entries(data.labels).map(([key, value]) => (
Expand Down
8 changes: 4 additions & 4 deletions ui/src/components/pipeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ export function Pipeline(props: { pipeline: PipelineType }) {
height: 20,
color: 'currentColor'
},
animated: true,
selectable: false,
selectable: true,
style: {
strokeWidth: 2
}
Expand Down Expand Up @@ -153,8 +152,9 @@ function getElements(pipeline: PipelineType): FlowPipeline {
name: phase.name,
labels: phase.labels || {},
depends_on: phase.depends_on,
source_type: phase.source_type
},
source_type: phase.source_type,
value: phase.value
},
extent: 'parent'
};
nodes.push(node);
Expand Down
6 changes: 1 addition & 5 deletions ui/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { createRoot } from 'react-dom/client';
import { App } from './App';
import { Provider } from 'react-redux';
import { store } from './store/store';

const container = document.getElementById('app') as HTMLElement;
const root = createRoot(container);
root.render(
<Provider store={store}>
<App />
</Provider>
);
);
47 changes: 0 additions & 47 deletions ui/src/store/flowSlice.ts

This file was deleted.

5 changes: 0 additions & 5 deletions ui/src/store/hooks.ts

This file was deleted.

11 changes: 0 additions & 11 deletions ui/src/store/store.ts

This file was deleted.

6 changes: 6 additions & 0 deletions ui/src/types/flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ export interface FlowPipeline {

export type PipelineNode = PhaseNode;

type PhaseNodeValue = {
digest: string;
[key: string]: unknown;
};

type PhaseNodeData = {
pipeline: string;
name: string;
labels?: Record<string, string>;
depends_on?: string;
source_type?: string;
value?: PhaseNodeValue;
};

export type PhaseNode = Node<PhaseNodeData, 'phase'>;
Expand Down
7 changes: 6 additions & 1 deletion ui/src/types/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ export interface Pipeline {
phases: Phase[];
}

type Resource = {
digest: string;
[key: string]: unknown;
};

export interface Phase {
name: string;
depends_on?: string;
source_type?: string;
labels?: Record<string, string>;
value?: unknown;
value?: Resource;
}

export interface PipelineGroup {
Expand Down

0 comments on commit b422e0e

Please sign in to comment.