Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add dependency dialogue (#4828)
- Loading branch information
Showing
5 changed files
with
118 additions
and
17 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
frontend/src/component/feature/Dependencies/AddDependencyDialogue.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,49 @@ | ||
import React, { useState } from 'react'; | ||
import { Box, styled, Typography } from '@mui/material'; | ||
import { Dialogue } from 'component/common/Dialogue/Dialogue'; | ||
import GeneralSelect from 'component/common/GeneralSelect/GeneralSelect'; | ||
|
||
interface IAddDependencyDialogueProps { | ||
showDependencyDialogue: boolean; | ||
onClose: () => void; | ||
} | ||
|
||
const StyledSelect = styled(GeneralSelect)(({ theme }) => ({ | ||
marginTop: theme.spacing(2), | ||
marginBottom: theme.spacing(1.5), | ||
})); | ||
|
||
export const AddDependencyDialogue = ({ | ||
showDependencyDialogue, | ||
onClose, | ||
}: IAddDependencyDialogueProps) => { | ||
const [dependency, setDependency] = useState(''); | ||
|
||
return ( | ||
<Dialogue | ||
open={showDependencyDialogue} | ||
title="Add parent feature dependency" | ||
onClose={onClose} | ||
onClick={() => {}} | ||
primaryButtonText={'Add'} | ||
secondaryButtonText="Cancel" | ||
> | ||
<Box> | ||
You feature will be evaluated only when the selected parent | ||
feature is enabled in the same environment. | ||
<br /> | ||
<br /> | ||
<Typography>What feature do you want to depend on?</Typography> | ||
<StyledSelect | ||
fullWidth | ||
options={[ | ||
{ key: 'a', label: 'featureA' }, | ||
{ key: 'empty', label: '' }, | ||
]} | ||
value={dependency} | ||
onChange={setDependency} | ||
/> | ||
</Box> | ||
</Dialogue> | ||
); | ||
}; |
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
30 changes: 30 additions & 0 deletions
30
...verviewSidePanel/FeatureOverviewSidePanelDetails/FeatureOverviewSidePanelDetails.test.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,30 @@ | ||
import { screen } from '@testing-library/react'; | ||
import { render } from 'utils/testRenderer'; | ||
import { FeatureOverviewSidePanelDetails } from './FeatureOverviewSidePanelDetails'; | ||
import { IFeatureToggle } from 'interfaces/featureToggle'; | ||
import { testServerRoute, testServerSetup } from 'utils/testServer'; | ||
|
||
const server = testServerSetup(); | ||
|
||
testServerRoute(server, '/api/admin/ui-config', { | ||
flags: { | ||
dependentFeatures: true, | ||
}, | ||
}); | ||
|
||
test('show dependency dialogue', async () => { | ||
render( | ||
<FeatureOverviewSidePanelDetails | ||
feature={{ name: 'feature' } as IFeatureToggle} | ||
header={''} | ||
/> | ||
); | ||
|
||
const addParentButton = await screen.findByText('Add parent feature'); | ||
|
||
addParentButton.click(); | ||
|
||
expect( | ||
screen.getByText('Add parent feature dependency') | ||
).toBeInTheDocument(); | ||
}); |
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