-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #966 from sgratch/add-mapping-tab-to-plans-details…
…-page 🐾 Enrich the mappings tab for the plans details page
- Loading branch information
Showing
20 changed files
with
1,516 additions
and
54 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
74 changes: 46 additions & 28 deletions
74
packages/forklift-console-plugin/src/modules/Plans/views/details/PlanDetailsPage.style.css
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
85 changes: 85 additions & 0 deletions
85
packages/forklift-console-plugin/src/modules/Plans/views/details/components/MappingList.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,85 @@ | ||
import React, { FC } from 'react'; | ||
import { useForkliftTranslation } from 'src/utils/i18n'; | ||
|
||
import { Button, DataList } from '@patternfly/react-core'; | ||
import { PlusCircleIcon } from '@patternfly/react-icons'; | ||
|
||
import { Mapping, MappingListItem } from './MappingListItem'; | ||
|
||
interface MappingListProps { | ||
/** | ||
* List of existed mappings | ||
*/ | ||
mappings: Mapping[]; | ||
/** | ||
* List of available source provider's mappings | ||
*/ | ||
availableSources?: string[]; | ||
/** | ||
* List of available target provider's mappings | ||
*/ | ||
availableDestinations?: string[]; | ||
replaceMapping?: (val: { current: Mapping; next: Mapping }) => void; | ||
deleteMapping?: (mapping: Mapping) => void; | ||
addMapping?: () => void; | ||
generalSourcesLabel: string; | ||
noSourcesLabel: string; | ||
/** | ||
* Is the 'mappings adding' buttons disabled | ||
*/ | ||
isDisabled?: boolean; | ||
/** | ||
* Is in edit/view mode? In case of view mode, the DataListCells are disabled and buttons are hidden | ||
*/ | ||
isEditable?: boolean; | ||
} | ||
|
||
export const MappingList: FC<MappingListProps> = ({ | ||
mappings, | ||
availableSources, | ||
availableDestinations, | ||
replaceMapping, | ||
deleteMapping, | ||
addMapping, | ||
generalSourcesLabel, | ||
noSourcesLabel, | ||
isDisabled = false, | ||
isEditable = true, | ||
}) => { | ||
const { t } = useForkliftTranslation(); | ||
|
||
return ( | ||
<> | ||
<DataList isCompact aria-label=""> | ||
{mappings?.map(({ source, destination }, index) => ( | ||
<MappingListItem | ||
source={source} | ||
destination={destination} | ||
sources={availableSources} | ||
destinations={availableDestinations} | ||
replaceMapping={replaceMapping} | ||
deleteMapping={deleteMapping} | ||
index={index} | ||
key={`${source}-${destination}`} | ||
generalSourcesLabel={generalSourcesLabel} | ||
noSourcesLabel={noSourcesLabel} | ||
isEditable={isEditable} | ||
/> | ||
))} | ||
</DataList> | ||
{isEditable ? ( | ||
<Button | ||
onClick={addMapping} | ||
type="button" | ||
variant="link" | ||
isDisabled={isDisabled} | ||
icon={<PlusCircleIcon />} | ||
> | ||
{t('Add mapping')} | ||
</Button> | ||
) : ( | ||
'' | ||
)} | ||
</> | ||
); | ||
}; |
Oops, something went wrong.