-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): warehouse creation wizard (#2728)
Signed-off-by: Remington Breeze <[email protected]> Signed-off-by: Mayursinh Sarvaiya <[email protected]> Signed-off-by: Kent Rancourt <[email protected]> Co-authored-by: Remington Breeze <[email protected]> Co-authored-by: Kent Rancourt <[email protected]> Co-authored-by: Rafal <[email protected]>
- Loading branch information
1 parent
9c1d29b
commit 6c10f68
Showing
25 changed files
with
816 additions
and
147 deletions.
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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,18 @@ | ||
import { createContext, useContext } from 'react'; | ||
|
||
type RjsfConfig = { | ||
showDescription: boolean; | ||
}; | ||
|
||
type RjsfConfigContextType = RjsfConfig & { | ||
setConfig(nextConfig: RjsfConfig): void; | ||
}; | ||
|
||
export const RjsfConfigContext = createContext<RjsfConfigContextType>({ | ||
showDescription: false, | ||
setConfig() { | ||
// noop | ||
} | ||
}); | ||
|
||
export const useRjsfConfigContext = () => useContext(RjsfConfigContext); |
13 changes: 13 additions & 0 deletions
13
ui/src/features/common/form/rjsf/description-field-template.tsx
This file contains 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,13 @@ | ||
import { DescriptionFieldProps } from '@rjsf/utils'; | ||
|
||
import { useRjsfConfigContext } from './context'; | ||
|
||
export const DescriptionFieldTemplate = (props: DescriptionFieldProps) => { | ||
const rjsfConfigContext = useRjsfConfigContext(); | ||
|
||
if (!rjsfConfigContext.showDescription) { | ||
return null; | ||
} | ||
|
||
return <span className='text-xs text-gray-400 mt-1 block mb-4'>{props.description}</span>; | ||
}; |
This file contains 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,9 @@ | ||
import { Templates } from '@rjsf/antd'; | ||
import { FieldTemplateProps } from '@rjsf/utils'; | ||
|
||
export const FieldTemplate = (props: FieldTemplateProps) => { | ||
return ( | ||
// @ts-expect-error it is component | ||
<Templates.FieldTemplate {...props} formContext={{ wrapperStyle: { marginBottom: '0px' } }} /> | ||
); | ||
}; |
44 changes: 44 additions & 0 deletions
44
ui/src/features/common/form/rjsf/object-field-template.tsx
This file contains 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,44 @@ | ||
import { Templates } from '@rjsf/antd'; | ||
import { ObjectFieldTemplateProps } from '@rjsf/utils'; | ||
import { Collapse } from 'antd'; | ||
import { useMemo } from 'react'; | ||
|
||
export const ObjectFieldTemplate = (props: ObjectFieldTemplateProps) => { | ||
if (!Templates.ObjectFieldTemplate) { | ||
throw new Error('[BUG]: Templates.ObjectFieldTemplate is undefined'); | ||
} | ||
|
||
const orderedProperties = useMemo( | ||
() => | ||
props.properties.sort((a, b) => { | ||
const aRequired = props.schema.required?.includes(a.name); | ||
const bRequired = props.schema.required?.includes(b.name); | ||
|
||
if (aRequired) { | ||
return -1; | ||
} | ||
|
||
if (bRequired) { | ||
return 1; | ||
} | ||
|
||
return 0; | ||
}), | ||
[props.properties, props.schema.required] | ||
); | ||
|
||
if (props.title) { | ||
return ( | ||
<Collapse | ||
items={[ | ||
{ | ||
children: <Templates.ObjectFieldTemplate {...props} properties={orderedProperties} />, | ||
label: props.title | ||
} | ||
]} | ||
/> | ||
); | ||
} | ||
|
||
return <Templates.ObjectFieldTemplate {...props} properties={orderedProperties} />; | ||
}; |
This file contains 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,9 @@ | ||
.container { | ||
@apply bg-gray-50; | ||
@apply p-5; | ||
@apply rounded-md; | ||
|
||
label { | ||
@apply font-semibold; | ||
} | ||
} |
This file contains 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,11 @@ | ||
import { faBoxes, faUserGear } from '@fortawesome/free-solid-svg-icons'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
|
||
export const IconSetByKargoTerminology = { | ||
subscription: () => ( | ||
<div className='flex items-center gap-2'> | ||
<FontAwesomeIcon icon={faBoxes} /> | ||
<FontAwesomeIcon icon={faUserGear} /> | ||
</div> | ||
) | ||
}; |
This file contains 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,32 @@ | ||
import { Descriptions } from 'antd'; | ||
import { DescriptionsItemType } from 'antd/es/descriptions'; | ||
|
||
export const ObjectDescription = (props: { data: object }) => { | ||
const items: DescriptionsItemType[] = []; | ||
|
||
for (const [key, value] of Object.entries(props.data)) { | ||
if (Array.isArray(value)) { | ||
if (value?.length > 0) { | ||
items.push({ key, label: key, children: value?.join(', ') }); | ||
} | ||
continue; | ||
} | ||
|
||
if (value === null || value === undefined || typeof value === 'undefined') { | ||
continue; | ||
} | ||
|
||
if (typeof value === 'object') { | ||
items.push({ key, label: key, children: <ObjectDescription data={value} /> }); | ||
continue; | ||
} | ||
|
||
items.push({ | ||
key, | ||
label: key, | ||
children: `${value}` | ||
}); | ||
} | ||
|
||
return <Descriptions bordered column={1} items={items} />; | ||
}; |
85 changes: 0 additions & 85 deletions
85
ui/src/features/project/pipelines/create-warehouse-modal.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.