Skip to content

Commit

Permalink
Merge pull request #15 from alonkeyval/revert-14-gen-1133-configured-…
Browse files Browse the repository at this point in the history
…destinations-list

[GEN-1133] feat: configured destinations list"
  • Loading branch information
alonkeyval authored Aug 18, 2024
2 parents 8629638 + 9c8d603 commit c78130f
Show file tree
Hide file tree
Showing 20 changed files with 77 additions and 1,275 deletions.
685 changes: 38 additions & 647 deletions frontend/graph/generated.go

Large diffs are not rendered by default.

13 changes: 2 additions & 11 deletions frontend/graph/model/destination.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package model

import (
"github.com/odigos-io/odigos/common"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -39,19 +40,9 @@ type ExportedSignals struct {
type Destination struct {
Id string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Type common.DestinationType `json:"type"`
ExportedSignals ExportedSignals `json:"signals"`
Fields map[string]string `json:"fields"`
DestinationType DestinationTypesCategoryItem `json:"destination_type"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

type ConfiguredDestination struct {
Id string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
ExportedSignals ExportedSignals `json:"signals"`
Fields string `json:"fields"`
DestinationType DestinationTypesCategoryItem `json:"destination_type"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}
11 changes: 0 additions & 11 deletions frontend/graph/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,6 @@ type Destination {
conditions: [Condition!]
}

type ConfiguredDestination {
id: ID!
name: String!
type: String!
exportedSignals: ExportedSignals!
fields: String!
destinationType: DestinationTypesCategoryItem!
conditions: [Condition!]
}

type GetConfigResponse {
installation: InstallationStatus!
}
Expand Down Expand Up @@ -214,7 +204,6 @@ input PersistNamespaceSourceInput {
type Query {
computePlatform: ComputePlatform
config: GetConfigResponse
destinations: [ConfiguredDestination!]!
destinationTypes: GetDestinationTypesResponse
destinationTypeDetails(type: String!): GetDestinationDetailsResponse
}
Expand Down
48 changes: 4 additions & 44 deletions frontend/graph/schema.resolvers.go

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

38 changes: 1 addition & 37 deletions frontend/services/destinations.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func K8sDestinationToEndpointFormat(k8sDest v1alpha1.Destination, secretFields m
return model.Destination{
Id: k8sDest.Name,
Name: destName,
Type: string(destType),
Type: destType,
ExportedSignals: model.ExportedSignals{
Traces: isSignalExported(k8sDest, common.TracesObservabilitySignal),
Metrics: isSignalExported(k8sDest, common.MetricsObservabilitySignal),
Expand All @@ -182,42 +182,6 @@ func K8sDestinationToEndpointFormat(k8sDest v1alpha1.Destination, secretFields m
}
}

func K8sDestinationToConfiguredDestination(k8sDest v1alpha1.Destination, secretFields map[string]string) model.ConfiguredDestination {
destType := k8sDest.Spec.Type
destName := k8sDest.Spec.DestinationName
mergedFields := mergeDataAndSecrets(k8sDest.Spec.Data, secretFields)
destTypeConfig := DestinationTypeConfigToCategoryItem(destinations.GetDestinationByType(string(destType)))
mergedFieldsJSON, err := json.Marshal(mergedFields)
if err != nil {
// Handle error appropriately
mergedFieldsJSON = []byte("{}") // Default to empty JSON object if marshalling fails
}

var conditions []metav1.Condition
for _, condition := range k8sDest.Status.Conditions {
conditions = append(conditions, metav1.Condition{
Type: condition.Type,
Status: condition.Status,
Message: condition.Message,
LastTransitionTime: condition.LastTransitionTime,
})
}

return model.ConfiguredDestination{
Id: k8sDest.Name,
Name: destName,
Type: string(destType),
ExportedSignals: model.ExportedSignals{
Traces: isSignalExported(k8sDest, common.TracesObservabilitySignal),
Metrics: isSignalExported(k8sDest, common.MetricsObservabilitySignal),
Logs: isSignalExported(k8sDest, common.LogsObservabilitySignal),
},
Fields: string(mergedFieldsJSON),
DestinationType: destTypeConfig,
Conditions: conditions,
}
}

func isSignalExported(dest v1alpha1.Destination, signal common.ObservabilitySignal) bool {
for _, s := range dest.Spec.Signals {
if s == signal {
Expand Down
11 changes: 0 additions & 11 deletions frontend/webapp/app/setup/choose-destination/page.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
'use client';
import React from 'react';
import styled from 'styled-components';
import { SideMenu } from '@/components';
import { ChooseDestinationContainer } from '@/containers/main';

const SideMenuWrapper = styled.div`
position: absolute;
left: 24px;
top: 144px;
`;

export default function ChooseDestinationPage() {
return (
<>
<SideMenuWrapper>
<SideMenu currentStep={3} />
</SideMenuWrapper>
<ChooseDestinationContainer />
</>
);
Expand Down
11 changes: 0 additions & 11 deletions frontend/webapp/app/setup/choose-sources/page.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
'use client';
import React from 'react';
import styled from 'styled-components';
import { SideMenu } from '@/components';
import { ChooseSourcesContainer } from '@/containers/main';

const SideMenuWrapper = styled.div`
position: absolute;
left: 24px;
top: 144px;
`;

export default function ChooseSourcesPage() {
return (
<>
<SideMenuWrapper>
<SideMenu currentStep={2} />
</SideMenuWrapper>
<ChooseSourcesContainer />
</>
);
Expand Down
10 changes: 10 additions & 0 deletions frontend/webapp/app/setup/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';
import React from 'react';
import styled from 'styled-components';
import { SideMenu } from '@/components';

const LayoutContainer = styled.div`
width: 100%;
Expand All @@ -11,6 +12,12 @@ const LayoutContainer = styled.div`
flex-direction: column;
`;

const SideMenuWrapper = styled.div`
position: absolute;
left: 24px;
top: 144px;
`;

const MainContent = styled.div`
display: flex;
max-width: 1440px;
Expand All @@ -26,6 +33,9 @@ export default function SetupLayout({
}) {
return (
<LayoutContainer>
<SideMenuWrapper>
<SideMenu />
</SideMenuWrapper>
<MainContent>{children}</MainContent>
</LayoutContainer>
);
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion frontend/webapp/components/destinations/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './add-destination-button';
export * from './monitors-tap-list';
export * from './configured-destination-fields';
34 changes: 6 additions & 28 deletions frontend/webapp/components/setup/menu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Image from 'next/image';
import { StepProps } from '@/types';
import React, { useEffect } from 'react';
import { Text } from '@/reuseable-components';
import { StepProps } from '@/types';
import Image from 'next/image';
import React from 'react';
import styled, { css } from 'styled-components';

const Container = styled.div`
Expand All @@ -14,7 +14,7 @@ const Step = styled.div<{ state: 'finish' | 'active' | 'disabled' }>`
display: flex;
gap: 16px;
padding: 10px 0;
cursor: ${({ state }) => (state === 'disabled' ? 'auto' : 'auto')};
cursor: ${({ state }) => (state === 'disabled' ? 'not-allowed' : 'pointer')};
opacity: ${({ state }) => (state === 'disabled' ? 0.5 : 1)};
transition: opacity 0.3s;
Expand Down Expand Up @@ -59,11 +59,7 @@ const StepTitle = styled(Text)`

const StepSubtitle = styled(Text)``;

const SideMenu: React.FC<{ data?: StepProps[]; currentStep?: number }> = ({
data,
currentStep,
}) => {
const [stepsList, setStepsList] = React.useState<StepProps[]>([]);
const SideMenu: React.FC<{ data?: StepProps[] }> = ({ data }) => {
const steps: StepProps[] = data || [
{
title: 'INSTALLATION',
Expand All @@ -74,8 +70,6 @@ const SideMenu: React.FC<{ data?: StepProps[]; currentStep?: number }> = ({
{
title: 'SOURCES',
state: 'active',
subtitle: '',

stepNumber: 2,
},
{
Expand All @@ -84,26 +78,10 @@ const SideMenu: React.FC<{ data?: StepProps[]; currentStep?: number }> = ({
stepNumber: 3,
},
];
useEffect(() => {
console.log({ currentStep });
if (currentStep) {
const currentSteps = (data || steps).map((step, index) => {
if (index < currentStep - 1) {
return { ...step, state: 'finish' as const };
} else if (index === currentStep - 1) {
return { ...step, state: 'active' as const };
} else {
return { ...step, state: 'disabled' as const };
}
});
console.log({ currentSteps });
setStepsList(currentSteps);
}
}, [currentStep, data]);

return (
<Container>
{stepsList.map((step, index) => (
{steps.map((step, index) => (
<Step key={index} state={step.state}>
<IconWrapper state={step.state}>
{step.state === 'finish' && (
Expand Down
Loading

0 comments on commit c78130f

Please sign in to comment.