Skip to content

Commit

Permalink
feat: add source modal
Browse files Browse the repository at this point in the history
  • Loading branch information
BenElferink committed Feb 10, 2025
1 parent e2bc390 commit afb9e66
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/containers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ export * from './multi-source-control/index'
export * from './notification-manager/index'
export * from './source-drawer/index'
export * from './source-form/index'
export * from './source-modal/index'
export * from './source-selection-form/index'
export * from './toast-list/index'
2 changes: 1 addition & 1 deletion src/containers/source-modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const SourceModal: FC<SourceModalProps> = ({
persistSources,
}) => {
const { currentModal, setCurrentModal } = useModalStore()
const isOpen = currentModal === ENTITY_TYPES.ACTION
const isOpen = currentModal === ENTITY_TYPES.SOURCE

const [selectedNamespace, setSelectedNamespace] = useState('')

Expand Down
52 changes: 52 additions & 0 deletions src/containers/source-modal/source-modal.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React, { useEffect, useState } from 'react'
import { useModalStore } from '../../store'
import type { Namespace } from '../../@types'
import type { StoryFn } from '@storybook/react'
import { SourceModal, type SourceModalProps } from '.'
import { ENTITY_TYPES, MOCK_SOURCES } from '@odigos/ui-utils'

export default {
title: 'Containers/SourceModal',
component: SourceModal,
}

export const Default: StoryFn<SourceModalProps> = (props) => {
const { setCurrentModal } = useModalStore()

useEffect(() => {
setCurrentModal(ENTITY_TYPES.SOURCE)
}, [])

const namespaces = props.namespaces || []
const [namespace, setNamespace] = useState<Namespace | undefined>(props.namespace || undefined)

return (
<SourceModal
namespacesLoading={props.namespacesLoading || false}
namespaces={namespaces}
namespace={namespace}
getNamespaceSources={(ns) => setNamespace(namespaces.find((n) => n.name === ns))}
persistSources={async () => {}}
/>
)
}

Default.args = {
namespaces: [
{
name: 'default',
selected: false,
sources: MOCK_SOURCES.map((s) => ({ ...s, selected: false })),
},
{
name: 'odigos-system',
selected: false,
sources: undefined,
},
{
name: 'kube-public',
selected: false,
sources: undefined,
},
],
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useState } from 'react'
import type { Namespace } from '../../@types'
import type { StoryFn } from '@storybook/react'
import { SourceSelectionForm, type SourceSelectionFormProps } from '.'
import { useSourceSelectionFormData } from '../../helpers'
import { MOCK_SOURCES } from '@odigos/ui-utils'
import { Namespace } from '../../@types'
import { useSourceSelectionFormData } from '../../helpers'
import { SourceSelectionForm, type SourceSelectionFormProps } from '.'

export default {
title: 'Containers/SourceSelectionForm',
Expand Down

0 comments on commit afb9e66

Please sign in to comment.