-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
248 additions
and
21 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
client/components/FormControl/ProjectPickerControl/ProjectPickerControl.module.scss
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,22 @@ | ||
.projectPickerControl { | ||
position: inherit; | ||
|
||
.selectedLabels { | ||
display: flex; | ||
flex-direction: row; | ||
flex-wrap: wrap; | ||
|
||
>div { | ||
margin-bottom: 5px; | ||
} | ||
} | ||
|
||
.openPickerButton { | ||
margin: 12px 0; | ||
} | ||
|
||
.noneSelected { | ||
font-size: 12px; | ||
color: #586069; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
client/components/FormControl/ProjectPickerControl/ProjectPickerControl.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,31 @@ | ||
import { SearchProject } from 'components/SearchProject' | ||
import React from 'react' | ||
import { FormInputControlComponent } from '../types' | ||
import styles from './ProjectPickerControl.module.scss' | ||
import { IProjectPickerControlProps } from './types' | ||
import { useProjectPickerControl } from './useProjectPickerControl' | ||
|
||
/** | ||
* @category Reusable Component | ||
*/ | ||
export const ProjectPickerControl: FormInputControlComponent< | ||
IProjectPickerControlProps | ||
> = (props) => { | ||
const { onSelected } = useProjectPickerControl(props) | ||
return ( | ||
<SearchProject | ||
label={props.label} | ||
description={props.description} | ||
placeholder={props.placeholder} | ||
filterFunc={(project) => | ||
project?.customer?.key === props.model.value('customerKey') | ||
} | ||
onSelected={onSelected} | ||
selectedKey={props.model.value(props.name)} | ||
/> | ||
) | ||
} | ||
|
||
ProjectPickerControl.displayName = 'ProjectPickerControl' | ||
ProjectPickerControl.className = styles.projectPickerControl | ||
ProjectPickerControl.defaultProps = {} |
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,2 @@ | ||
export * from './ProjectPickerControl' | ||
export * from './types' |
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,8 @@ | ||
import { ISearchProjectProps } from 'components/SearchProject' | ||
import { HTMLAttributes } from 'react' | ||
import { FormInputControlBase } from '../types' | ||
|
||
export interface IProjectPickerControlProps | ||
extends FormInputControlBase, | ||
Pick<ISearchProjectProps, 'label' | 'placeholder' | 'description'>, | ||
Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {} |
14 changes: 14 additions & 0 deletions
14
client/components/FormControl/ProjectPickerControl/useProjectPickerControl.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,14 @@ | ||
import { ISearchProjectProps } from 'components/SearchProject/types' | ||
import { IProjectPickerControlProps } from './types' | ||
|
||
/** | ||
* Hook for the `ProjectPickerControl` component. | ||
* | ||
* @param props Props for the `ProjectPickerControl` component. | ||
*/ | ||
export function useProjectPickerControl(props: IProjectPickerControlProps) { | ||
const onSelected: ISearchProjectProps['onSelected'] = (project) => { | ||
props.model.set(props.name, project.tag) | ||
} | ||
return { onSelected } | ||
} |
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
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
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
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
Oops, something went wrong.