Skip to content

Commit

Permalink
Add namespace to create environment form (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabalafou authored Mar 20, 2024
1 parent 8b84d27 commit ee80e93
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export const EnvironmentCreate = ({ environmentNotification }: IEnvCreate) => {
return (
<Box sx={{ padding: "14px 12px" }}>
<EnvironmentDetailsHeader
namespace={newEnvironment.namespace}
onUpdateName={handleChangeName}
showEditButton={true}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ import {
interface IEnvironmentDetailsHeaderProps {
/**
* @param envName name of the selected environment
* @param namespace namespace of the environment
* @param onUpdateName change environment name
*/
envName?: string;
namespace?: string;
showEditButton: boolean | undefined;
onUpdateName: (value: string) => void;
}

export const EnvironmentDetailsHeader = ({
envName = "",
namespace,
onUpdateName,
showEditButton = true
}: IEnvironmentDetailsHeaderProps) => {
Expand All @@ -34,7 +37,8 @@ export const EnvironmentDetailsHeader = ({
sx={{
display: "flex",
alignItems: "center",
justifyContent: "space-between",
justifyContent:
mode === EnvironmentDetailsModes.CREATE ? "start" : "space-between",
marginBottom: "15px"
}}
>
Expand Down Expand Up @@ -64,9 +68,28 @@ export const EnvironmentDetailsHeader = ({
)}
{mode === EnvironmentDetailsModes.CREATE && (
<>
{namespace && (
<>
<TextField
label="Namespace"
value={namespace}
disabled
size="small"
/>
<div
aria-hidden
style={{
borderRight: `2px solid ${palette.secondary.main}`,
transform: "skew(-15deg)",
margin: "0 1rem",
height: "1.6rem"
}}
/>
</>
)}
<TextField
autoFocus
placeholder="Environment name"
label="Environment name"
sx={{
backgroundColor: palette.grey[100],
minWidth: "450px",
Expand All @@ -76,11 +99,10 @@ export const EnvironmentDetailsHeader = ({
}}
inputProps={{
style: {
padding: "8px 15px",
fontSize: "15px",
color: palette.common.black
}
}}
size="small"
onChange={e => onUpdateName(e.target.value)}
/>
{/* <StyledButtonPrimary>Archive</StyledButtonPrimary> */}
Expand Down
25 changes: 23 additions & 2 deletions test/environmentDetails/EnvironmentDetailsHeader.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe("<EnvironmentDetailsHeader />", () => {
});
});

it("should render component in create mode", () => {
it("should render component in create mode without namespace", () => {
const mockOnUpdateName = jest.fn();
const component = render(
mockTheme(
Expand All @@ -70,9 +70,30 @@ describe("<EnvironmentDetailsHeader />", () => {
store.dispatch(modeChanged(EnvironmentDetailsModes.CREATE));
});

const input = component.getByPlaceholderText("Environment name");
const input = component.getByLabelText("Environment name");
const newEnvName = "My new environment name";
fireEvent.change(input, { target: { value: newEnvName } });
expect(mockOnUpdateName).toHaveBeenCalledWith(newEnvName);
expect(component.queryByText("Namespace")).not.toBeInTheDocument();
});

it("should render component in create mode with namespace", () => {
const mockOnUpdateName = jest.fn();
const component = render(
mockTheme(
<Provider store={store}>
<EnvironmentDetailsHeader
envName={undefined}
namespace="test-namespace"
onUpdateName={mockOnUpdateName}
showEditButton={true}
/>
</Provider>
)
);
act(() => {
store.dispatch(modeChanged(EnvironmentDetailsModes.CREATE));
});
expect(component.getByLabelText("Namespace")).toBeInTheDocument();
});
});
2 changes: 1 addition & 1 deletion test/playwright/test_ux.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def _create_new_environment(page, screenshot=False):
if screenshot:
page.screenshot(path="test-results/conda-store-new-env.png")
# fill in the env name
page.get_by_placeholder("Environment name").fill(new_env_name)
page.get_by_label("Environment name").fill(new_env_name)
# fill in the description
page.get_by_placeholder("Enter here the description of your environment").fill("description")
# click the + to add a package
Expand Down

0 comments on commit ee80e93

Please sign in to comment.