-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/#395 #423
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/#395 #423
Changes from 250 commits
d5e7cb7
13d0bde
98946c2
30b0617
0e8c374
1cc44f6
dbb2026
a1eb771
5a2cc95
abc793b
41cf55b
33c135d
919163b
e5c5f59
5bc071e
88cdcfa
0fc5f80
51848ef
ff0b2f5
26b4fa7
e170632
521bacd
523e210
c134d81
6239235
43e5e5e
0f10e4f
6b2628e
f09356d
c6421ca
09c5417
06d5599
8697c0d
020770e
3abbc85
909ba27
9b78e74
50b633b
3d52ac0
6927592
7671d7c
1882abb
0ffd76c
aab01e0
9296ff5
fc6028c
51f63e2
6b4a367
aa5ac83
b0e4d4c
c31f26d
7c3f14d
baf3bce
3a7e578
cd7b34f
9a6041b
a42408c
205a4ba
a20ba39
12e6087
2527685
3a698cd
c155d2f
bd914d7
94631c2
f450d74
63c6486
6a3e728
303680e
e060695
dc7c155
65399db
5d2cefc
6280ff8
ddac0fb
77d8c68
7e9c24c
f15daee
f513118
824dc95
fd7ef7b
1870dec
5599efc
7ea189b
d114b90
eb89bf2
ccf43b4
fac63a3
457152b
e910cd8
06e49d5
ca928e3
6db1eee
96363c1
e1cb962
e433755
cc1c181
9f0ca30
f943bfa
a3092cc
1668380
01a3764
0e49158
def2493
5f67827
b7d8b52
fdc6fc7
6458a52
cb2d318
3404e5e
83871c2
4efa5b3
9215cca
03f31f3
15c92d7
e5bd0fa
0f6a3ff
5c21450
5ea6e73
e37589f
3502469
0ecccea
8b003ca
469b651
29a157e
bb2cc97
c0b8821
e78e1e1
742e882
ca42b22
faf7a8a
b30f277
e2866c2
77e5ba7
6b8d90a
fcda31a
bfd8cb2
4c96540
4c32710
3e05252
97b90fa
16ec5d9
605d3c5
5c5f321
17346ef
656b93e
e62115b
eca5841
45dcf27
212a730
fca12e9
30f88a2
a26b0f1
6bbc12d
dc32d68
09dac1c
e03df21
9ec9ee2
597b5d6
2835b1c
5ac9029
8864526
08abec0
c58d244
d8c0b89
a826c1b
fab8e64
b1aa1b3
a9c5825
7c4a22e
92e0a24
a6a93a6
1c2032d
2d34758
69e4187
c08e4ef
85a4074
d87f9d7
342153e
047efb5
f16a29e
760957a
391fcfb
a29635a
ff522d9
c8c496e
5e5f493
8893fe7
416764e
f81eeed
bddb1cc
b5df177
e5e305f
b27d86b
9499f6e
9de712f
e9abaa2
5e39138
6b7bae7
47f02b9
d39fde9
e4f22ac
6cea37b
eefcb04
bb8fd9d
fb7a464
dd46447
4438677
76cdfd5
037f954
3760233
0874ef8
46db7c4
6a47218
bf25e7f
7d96a82
f27fa4b
9f2ef94
85f86b5
d73af7c
36840b3
69ddb36
0d0a643
618b3b6
47deb1f
5e50344
475f18b
292db4a
7de4450
daa8fc8
a9c05c6
b98f7d8
26b9927
1b28863
0849e39
1885d52
162b3aa
585165f
c24341e
7be224c
d724755
fff6cda
a7caf22
af2da12
edf9ca2
5c64384
913ec92
f4c9fbe
9d291fc
8def5dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,5 +114,8 @@ | |
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "date-fns": "^4.1.0" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import {Meta} from "@storybook/react"; | ||
mvriu5 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| import React from "react"; | ||
| import {DataTypeView} from "../data-type/DFlowDataType.view"; | ||
| import {FunctionDefinitionView} from "../function/DFlowFunction.view"; | ||
| import {FlowView} from "../DFlow.view"; | ||
| import {ContextStoreProvider} from "../../../utils/contextStore"; | ||
| import {useReactiveArrayService} from "../../../utils/reactiveArrayService"; | ||
| import {DFlowDataTypeReactiveService} from "../data-type/DFlowDataType.service"; | ||
| import {DFlowFunctionReactiveService} from "../function/DFlowFunction.service"; | ||
| import {DFlowReactiveService} from "../DFlow.service"; | ||
| import {DFlowReactiveSuggestionService} from "./DFlowSuggestion.service"; | ||
| import {DFlowSuggestion} from "./DFlowSuggestion.view"; | ||
| import {useSuggestions} from "./DFlowSuggestion.hook"; | ||
| import TextInput from "../../form/TextInput"; | ||
| import {DFlowSuggestionMenuFooter} from "./DFlowSuggestionMenuFooter"; | ||
| import {toInputSuggestions} from "./DFlowSuggestionMenu.util"; | ||
|
|
||
| export default { | ||
| title: "DFlowSuggestionMenuWithInput", | ||
| } as Meta | ||
|
|
||
| export const Example = () => { | ||
|
|
||
| const functionsData: FunctionDefinitionView[] = functionData.map((fd) => new FunctionDefinitionView(fd)) | ||
|
|
||
| const [dataTypeStore, dataTypeService] = useReactiveArrayService<DataTypeView, DFlowDataTypeReactiveService>(DFlowDataTypeReactiveService) | ||
| const [functionStore, functionService] = useReactiveArrayService<FunctionDefinitionView, DFlowFunctionReactiveService>(DFlowFunctionReactiveService, functionsData); | ||
| const [flowStore, flowService] = useReactiveArrayService<FlowView, DFlowReactiveService>(DFlowReactiveService, [new FlowView(flow)]); | ||
| const [suggestionStore, suggestionService] = useReactiveArrayService<DFlowSuggestion, DFlowReactiveSuggestionService>(DFlowReactiveSuggestionService); | ||
|
|
||
| React.useEffect(() => { | ||
| dataTypes.forEach(dt => dataTypeService.add(new DataTypeView(dt, dataTypeService))); | ||
| }, [dataTypeService]) | ||
|
|
||
| return <ContextStoreProvider | ||
| services={[[dataTypeStore, dataTypeService], [functionStore, functionService], [flowStore, flowService], [suggestionStore, suggestionService]]}> | ||
| {React.useMemo(() => <SuggestionMenu/>, [])} | ||
| </ContextStoreProvider> | ||
| } | ||
|
|
||
| const SuggestionMenu = () => { | ||
|
|
||
| const result = useSuggestions({dataType: {identifier: "NUMBER"}}, [], "some_database_id", 0, [0]) | ||
|
|
||
| return <div> | ||
| <TextInput title={"Text"} | ||
| clearable | ||
| transformValue={(value) => <span style={{color: "red"}}>{value}</span>} | ||
| suggestionsFooter={<DFlowSuggestionMenuFooter/>} | ||
| suggestions={toInputSuggestions(result)} | ||
| description={"Type what ever text you like"} | ||
| placeholder={"code0.tech"}/> | ||
| </div> | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import {Meta, StoryObj} from "@storybook/react"; | ||
| import React from "react"; | ||
| import DNamespaceProjectCard from "./DNamespaceProjectCard" | ||
| import {ContextStoreProvider} from "../../../utils/contextStore" | ||
| import {useReactiveArrayService} from "../../../utils/reactiveArrayService" | ||
| import {DNamespaceProjectView} from "./DNamespaceProject.view" | ||
| import {DNamespaceProjectReactiveService} from "./DNamespaceProject.service" | ||
| import { | ||
| NamespacesProjectsAssignRuntimesInput, | ||
| NamespacesProjectsCreateInput, NamespacesProjectsDeleteInput | ||
| } from "@code0-tech/sagittarius-graphql-types" | ||
|
|
||
| const meta: Meta = { | ||
| title: "DNamespaceProjectCard", | ||
| component: DNamespaceProjectCard | ||
| } | ||
|
|
||
| export default meta | ||
|
|
||
| type DNamespaceProjectCardStory = StoryObj<typeof DNamespaceProjectCard>; | ||
|
|
||
| export class DNamespaceProjectReactiveServiceExtended extends DNamespaceProjectReactiveService { | ||
| projectAssignRuntimes(payload: NamespacesProjectsAssignRuntimesInput): DNamespaceProjectView | undefined { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| projectsCreate(payload: NamespacesProjectsCreateInput): DNamespaceProjectView | undefined { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| projectsDelete(payload: NamespacesProjectsDeleteInput): void { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| export const DNamespaceProjectCardExample: DNamespaceProjectCardStory = { | ||
| render: (props) => { | ||
|
|
||
| const [projectStore, projectService] = useReactiveArrayService<DNamespaceProjectView, DNamespaceProjectReactiveServiceExtended>(DNamespaceProjectReactiveServiceExtended, [{ | ||
| id: "gid://sagittarius/NamespaceProject/1", | ||
| name: "Example Project", | ||
| description: "This is an example project description.", | ||
| createdAt: new Date().toString(), | ||
| updatedAt: new Date().toString(), | ||
| namespace: { | ||
| id: "gid://sagittarius/Namespace/1" | ||
| }, | ||
| flow: undefined, | ||
| flows: undefined, | ||
| primaryRuntime: undefined, | ||
| runtimes: undefined | ||
| }]) | ||
|
|
||
| return ( | ||
| <ContextStoreProvider services={[[projectStore, projectService]]}> | ||
| {React.useMemo(() => { | ||
| return <DNamespaceProjectCard projectId={"gid://sagittarius/NamespaceProject/1"}/> | ||
| }, [])} | ||
| </ContextStoreProvider> | ||
| ) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| "use client" | ||
|
|
||
| import React from "react" | ||
| import {Code0Component} from "../../../utils/types" | ||
| import { | ||
| NamespacesProjectsAssignRuntimesInput, | ||
| NamespacesProjectsCreateInput, NamespacesProjectsDeleteInput, | ||
| Scalars | ||
| } from "@code0-tech/sagittarius-graphql-types" | ||
| import {Card} from "../../../index" | ||
| import Text from "../../text/Text" | ||
| import {IconBox} from "@tabler/icons-react" | ||
| import Row from "../../row/Row" | ||
| import Col from "../../col/Col" | ||
| import {format} from "date-fns" | ||
| import {useService, useStore} from "../../../utils/contextStore" | ||
| import {DNamespaceProjectReactiveService} from "./DNamespaceProject.service" | ||
| import {DNamespaceProjectView} from "./DNamespaceProject.view" | ||
|
|
||
| export interface DNamespaceProjectCardProps extends Code0Component<HTMLDivElement> { | ||
| projectId: Scalars['NamespaceProjectID']['output'] | ||
| } | ||
|
|
||
| const DNamespaceProjectCard: React.FC<DNamespaceProjectCardProps> = props => { | ||
| const projectStore = useStore(DNamespaceProjectReactiveService) | ||
| const projectService = useService(DNamespaceProjectReactiveService) | ||
|
|
||
| const project = projectService.findById(props.projectId) | ||
|
|
||
| return React.useMemo(() => { | ||
| return ( | ||
| <Card style={{ padding: "16px"}} width={"100%"}> | ||
| <Row style={{ alignItems: "center" }}> | ||
| <IconBox size={52}/> | ||
| <Col style={{minWidth: 0, flex: 1}}> | ||
| <Text size={"lg"} hierarchy={"primary"} style={{overflow: "hidden", display: "block", marginBottom: ".25rem", textOverflow: "ellipsis", whiteSpace: "nowrap"}}> | ||
| {project?.name} | ||
| </Text> | ||
| <Text size={"md"} hierarchy={"secondary"} style={{overflow: "hidden", display: "block", marginBottom: ".25rem", textOverflow: "ellipsis", whiteSpace: "nowrap"}}> | ||
| {project?.description} | ||
| </Text> | ||
| <Text size={"sm"} hierarchy={"tertiary"} style={{display: "block", marginTop: ".75rem"}}> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use our Badge component to display such information with an additional icon. We can also display to which organization this project belongs over the namespace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why should i use a Badge here? I'm not using any icon in the shown code lines. The other icon in the ProjectCard is centered in a row against the 3 texts. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My idea was to use Badges for information like the updatedAt infos etc. with icons. |
||
| {format(new Date(project?.updatedAt ?? ""), "dd/MM/yyyy HH:mm")} | ||
| </Text> | ||
| </Col> | ||
| </Row> | ||
| </Card> | ||
| ) | ||
| }, [projectStore]) | ||
| } | ||
|
|
||
| export default DNamespaceProjectCard | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import {Meta, StoryObj} from "@storybook/react" | ||
| import DNamespaceProjectMenu from "./DNamespaceProjectMenu" | ||
| import {DNamespaceProjectReactiveService} from "./DNamespaceProject.service" | ||
| import { | ||
| NamespacesProjectsAssignRuntimesInput, | ||
| NamespacesProjectsCreateInput, NamespacesProjectsDeleteInput | ||
| } from "@code0-tech/sagittarius-graphql-types" | ||
| import {DNamespaceProjectView} from "./DNamespaceProject.view" | ||
| import {ContextStoreProvider} from "../../../utils/contextStore" | ||
| import React from "react" | ||
| import {useReactiveArrayService} from "../../../utils/reactiveArrayService" | ||
|
|
||
| const meta: Meta = { | ||
| title: "DNamespaceProjectMenu", | ||
| component: DNamespaceProjectMenu | ||
| } | ||
|
|
||
| export default meta | ||
|
|
||
| type DNamespaceProjectMenuStory = StoryObj<typeof DNamespaceProjectMenu>; | ||
|
|
||
| export class DNamespaceProjectReactiveServiceExtended extends DNamespaceProjectReactiveService { | ||
| projectAssignRuntimes(payload: NamespacesProjectsAssignRuntimesInput): DNamespaceProjectView | undefined { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| projectsCreate(payload: NamespacesProjectsCreateInput): DNamespaceProjectView | undefined { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| projectsDelete(payload: NamespacesProjectsDeleteInput): void { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| export const DProjectMenuExample: DNamespaceProjectMenuStory = { | ||
| render: (props) => { | ||
|
|
||
| const [projectStore, projectService] = useReactiveArrayService<DNamespaceProjectView, DNamespaceProjectReactiveServiceExtended>(DNamespaceProjectReactiveServiceExtended, [ | ||
| { | ||
| id: "gid://sagittarius/NamespaceProject/1", | ||
| name: "Example Project", | ||
| description: "This is an example project description.", | ||
| createdAt: new Date().toString(), | ||
| updatedAt: new Date().toString(), | ||
| namespace: { | ||
| id: "gid://sagittarius/Namespace/1" | ||
| }, | ||
| flow: undefined, | ||
| flows: undefined, | ||
| primaryRuntime: undefined, | ||
| runtimes: undefined | ||
| }, | ||
| { | ||
| id: "gid://sagittarius/NamespaceProject/2", | ||
| name: "Another Project", | ||
| description: "This is another project description.", | ||
| createdAt: new Date().toString(), | ||
| updatedAt: new Date().toString(), | ||
| namespace: { | ||
| id: "gid://sagittarius/Namespace/1" | ||
| }, | ||
| flow: undefined, | ||
| flows: undefined, | ||
| primaryRuntime: undefined, | ||
| runtimes: undefined | ||
| }]) | ||
|
|
||
| return ( | ||
| <ContextStoreProvider services={[[projectStore, projectService]]}> | ||
| {React.useMemo(() => { | ||
| return ( | ||
| <DNamespaceProjectMenu | ||
| projectId={"gid://sagittarius/NamespaceProject/1"} | ||
| onProjectSelect={props.onProjectSelect} | ||
| /> | ||
| ) | ||
| }, [])} | ||
| </ContextStoreProvider> | ||
| ) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| "use client" | ||
|
|
||
| import React from "react" | ||
| import {Menu, MenuContent, MenuItem, MenuPortal, MenuProps, MenuTrigger} from "../../menu/Menu" | ||
| import {DNamespaceProjectView} from "./DNamespaceProject.view" | ||
| import {DNamespaceProjectReactiveService} from "./DNamespaceProject.service" | ||
| import {useService} from "../../../utils/contextStore" | ||
| import {Scalars} from "@code0-tech/sagittarius-graphql-types" | ||
| import Button from "../../button/Button" | ||
|
|
||
| export interface DNamespaceProjectMenuProps extends MenuProps { | ||
| projectId: Scalars['NamespaceProjectID']['output'] | ||
| onProjectSelect: (payload: DNamespaceProjectView) => void | ||
| } | ||
|
|
||
| const DNamespaceProjectMenu: React.FC<DNamespaceProjectMenuProps> = props => { | ||
| const projectService = useService(DNamespaceProjectReactiveService) | ||
| const projectStore = useService(DNamespaceProjectReactiveService) | ||
| const currentProject = projectService.findById(props.projectId) | ||
|
|
||
| return React.useMemo(() => { | ||
| return ( | ||
| <Menu {...props}> | ||
| <MenuTrigger asChild> | ||
| <Button variant={"none"} style={{background: "transparent"}}> | ||
| {currentProject?.name} | ||
| </Button> | ||
| </MenuTrigger> | ||
| <MenuPortal> | ||
| <MenuContent side={"bottom"} align={"start"} sideOffset={0}> | ||
| {projectService.values().map((project) => ( | ||
| <MenuItem | ||
| key={project.id} | ||
| onSelect={() => props.onProjectSelect(project)} | ||
| > | ||
| {project.name} | ||
| </MenuItem> | ||
| ))} | ||
| </MenuContent> | ||
| </MenuPortal> | ||
| </Menu> | ||
| ) | ||
| }, [projectStore]) | ||
| } | ||
|
|
||
| export default DNamespaceProjectMenu |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import {Meta, StoryObj} from "@storybook/react" | ||
| import React from "react" | ||
| import DOrganizationCard from "./DOrganizationCard" | ||
| import {ContextStoreProvider} from "../../utils/contextStore" | ||
| import {useReactiveArrayService} from "../../utils/reactiveArrayService" | ||
| import {DOrganizationView} from "./DOrganizationView" | ||
| import {DOrganizationReactiveService} from "./DOrganizationService" | ||
| import { OrganizationsCreateInput, OrganizationsDeleteInput, OrganizationsUpdateInput } from "@code0-tech/sagittarius-graphql-types" | ||
|
|
||
| const meta: Meta = { | ||
| title: "DOrganizationCard", | ||
| component: DOrganizationCard | ||
| } | ||
|
|
||
| export default meta | ||
|
|
||
| type DOrganizationCardStory = StoryObj<typeof DOrganizationCard>; | ||
|
|
||
| class DOrganizationReactiveServiceExtended extends DOrganizationReactiveService { | ||
| organizationCreate(payload: OrganizationsCreateInput): DOrganizationView | undefined { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| organizationDelete(payload: OrganizationsDeleteInput): void { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| organizationUpdate(payload: OrganizationsUpdateInput): DOrganizationView | undefined { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| export const DOrganizationCardExample: DOrganizationCardStory = { | ||
| render: (props) => { | ||
|
|
||
| const [organizationStore, organizationService] = useReactiveArrayService<DOrganizationView, DOrganizationReactiveServiceExtended>(DOrganizationReactiveServiceExtended, [{ | ||
| id: "gid://sagittarius/Organization/1", | ||
| name: "Example Organization", | ||
| namespace: { | ||
| id: "gid://sagittarius/Namespace/1", | ||
| projects: { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not valid here, because the project count is stored in the namespace and not here. You need to fetch the namespace over the NamespaceService There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the correct way? Im doing the same thing in the component where i get my projectcount like this: const projectCount = organization?.namespace?.projects?.count |
||
| count: 5 | ||
| } | ||
| }, | ||
| createdAt: new Date().toString(), | ||
| updatedAt: new Date().toString() | ||
| }]) | ||
|
|
||
| return ( | ||
| <ContextStoreProvider services={[[organizationStore, organizationService]]}> | ||
| {React.useMemo(() => { | ||
| return <DOrganizationCard organizationId={"gid://sagittarius/Organization/1"}/> | ||
| }, [])} | ||
| </ContextStoreProvider> | ||
| ) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.