-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: refactor the Get Started page Signed-off-by: Oleksii Kurinnyi <[email protected]> * feat: added Editor Selector component Signed-off-by: Oleksii Kurinnyi <[email protected]> * chore: integrate Editor Selector with other components Signed-off-by: Oleksii Kurinnyi <[email protected]> * feat: add editor definition form Signed-off-by: Oleksii Kurinnyi <[email protected]> * fixup! feat: add editor definition form * chore: rename editorId -> editorDefinition Signed-off-by: Oleksii Kurinnyi <[email protected]> * feat: add doc link Signed-off-by: Oleksii Kurinnyi <[email protected]> * fix: default editor and repo editor precedence Signed-off-by: Oleksii Kurinnyi <[email protected]> * feat: selected card title is black Signed-off-by: Oleksii Kurinnyi <[email protected]> * fixup! feat: selected card title is black --------- Signed-off-by: Oleksii Kurinnyi <[email protected]>
- Loading branch information
Showing
85 changed files
with
5,368 additions
and
2,142 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
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
28 changes: 28 additions & 0 deletions
28
...ard-frontend/src/components/EditorSelector/Definition/DefinitionField/__mocks__/index.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,28 @@ | ||
/* | ||
* Copyright (c) 2018-2024 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { Props } from '@/components/EditorSelector/Definition/DefinitionField'; | ||
|
||
export class EditorDefinitionField extends React.PureComponent<Props> { | ||
public render() { | ||
const { onChange } = this.props; | ||
|
||
return ( | ||
<div data-testid="editor-definition-field"> | ||
<button onClick={() => onChange('some/editor/id')}>Editor Definition Change</button> | ||
Editor Definition Field | ||
</div> | ||
); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...nts/EditorSelector/Definition/DefinitionField/__tests__/__snapshots__/index.spec.tsx.snap
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,71 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`EditorDefinitionField snapshot 1`] = ` | ||
<div | ||
className="pf-c-form__group" | ||
> | ||
<div | ||
className="pf-c-form__group-label" | ||
> | ||
<label | ||
className="pf-c-form__label" | ||
> | ||
<span | ||
className="pf-c-form__label-text" | ||
> | ||
Editor Definition | ||
</span> | ||
</label> | ||
</div> | ||
<div | ||
className="pf-c-form__group-control" | ||
> | ||
<input | ||
aria-invalid={false} | ||
aria-label="Editor Definition" | ||
className="pf-c-form-control" | ||
data-ouia-component-id="OUIA-Generated-TextInputBase-1" | ||
data-ouia-component-type="PF4/TextInput" | ||
data-ouia-safe={true} | ||
disabled={false} | ||
onBlur={[Function]} | ||
onChange={[Function]} | ||
onFocus={[Function]} | ||
placeholder="Enter the link to a container editor definition URL or an editor id" | ||
required={false} | ||
type="text" | ||
value="" | ||
/> | ||
<div | ||
aria-live="polite" | ||
className="pf-c-form__helper-text" | ||
id="undefined-helper" | ||
> | ||
<span | ||
className="pf-c-form__helper-text-icon" | ||
> | ||
<svg | ||
aria-hidden={true} | ||
aria-labelledby={null} | ||
fill="currentColor" | ||
height="1em" | ||
role="img" | ||
style={ | ||
{ | ||
"verticalAlign": "-0.125em", | ||
} | ||
} | ||
viewBox="0 0 192 512" | ||
width="1em" | ||
> | ||
<path | ||
d="M20 424.229h20V279.771H20c-11.046 0-20-8.954-20-20V212c0-11.046 8.954-20 20-20h112c11.046 0 20 8.954 20 20v212.229h20c11.046 0 20 8.954 20 20V492c0 11.046-8.954 20-20 20H20c-11.046 0-20-8.954-20-20v-47.771c0-11.046 8.954-20 20-20zM96 0C56.235 0 24 32.235 24 72s32.235 72 72 72 72-32.235 72-72S135.764 0 96 0z" | ||
/> | ||
</svg> | ||
</span> | ||
Default editor will be used if no definition is provided. | ||
</div> | ||
</div> | ||
</div> | ||
`; |
57 changes: 57 additions & 0 deletions
57
...rontend/src/components/EditorSelector/Definition/DefinitionField/__tests__/index.spec.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,57 @@ | ||
/* | ||
* Copyright (c) 2018-2024 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
|
||
import userEvent from '@testing-library/user-event'; | ||
import React from 'react'; | ||
|
||
import { EditorDefinitionField } from '@/components/EditorSelector/Definition/DefinitionField'; | ||
import getComponentRenderer, { screen } from '@/services/__mocks__/getComponentRenderer'; | ||
|
||
const { createSnapshot, renderComponent } = getComponentRenderer(getComponent); | ||
|
||
const mockOnChange = jest.fn(); | ||
|
||
describe('EditorDefinitionField', () => { | ||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
test('snapshot', () => { | ||
const snapshot = createSnapshot(); | ||
expect(snapshot.toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
test('helper text, definition change', () => { | ||
renderComponent(); | ||
|
||
const helperText = 'Default editor will be used if no definition is provided.'; | ||
|
||
expect(screen.queryByText(helperText)).not.toBeNull(); | ||
|
||
const input = screen.getByRole('textbox'); | ||
|
||
const editorId = 'some/editor/id'; | ||
userEvent.paste(input, editorId); | ||
|
||
expect(mockOnChange).toHaveBeenNthCalledWith(1, editorId); | ||
expect(screen.queryByText(helperText)).toBeNull(); | ||
|
||
userEvent.clear(input); | ||
|
||
expect(mockOnChange).toHaveBeenNthCalledWith(2, undefined); | ||
expect(screen.queryByText(helperText)).not.toBeNull(); | ||
}); | ||
}); | ||
|
||
function getComponent() { | ||
return <EditorDefinitionField onChange={mockOnChange} />; | ||
} |
56 changes: 56 additions & 0 deletions
56
...ges/dashboard-frontend/src/components/EditorSelector/Definition/DefinitionField/index.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,56 @@ | ||
/* | ||
* Copyright (c) 2018-2024 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
|
||
import { FormGroup, TextInput } from '@patternfly/react-core'; | ||
import { InfoIcon } from '@patternfly/react-icons'; | ||
import React from 'react'; | ||
|
||
export type Props = { | ||
onChange: (definition: string | undefined) => void; | ||
}; | ||
export type State = { | ||
definition: string; | ||
}; | ||
|
||
export class EditorDefinitionField extends React.PureComponent<Props, State> { | ||
constructor(props: Props) { | ||
super(props); | ||
|
||
this.state = { | ||
definition: '', | ||
}; | ||
} | ||
|
||
private handleChange(value: string) { | ||
value = value.trim(); | ||
this.setState({ definition: value }); | ||
this.props.onChange(value !== '' ? value : undefined); | ||
} | ||
|
||
public render() { | ||
const { definition } = this.state; | ||
|
||
const helperText = | ||
definition !== '' ? '' : 'Default editor will be used if no definition is provided.'; | ||
|
||
return ( | ||
<FormGroup label="Editor Definition" helperText={helperText} helperTextIcon={<InfoIcon />}> | ||
<TextInput | ||
aria-label="Editor Definition" | ||
placeholder="Enter the link to a container editor definition URL or an editor id" | ||
onChange={value => this.handleChange(value)} | ||
value={definition} | ||
/> | ||
</FormGroup> | ||
); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...ashboard-frontend/src/components/EditorSelector/Definition/ImageField/__mocks__/index.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,28 @@ | ||
/* | ||
* Copyright (c) 2018-2024 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { Props } from '@/components/EditorSelector/Definition/ImageField'; | ||
|
||
export class EditorImageField extends React.PureComponent<Props> { | ||
public render() { | ||
const { onChange } = this.props; | ||
|
||
return ( | ||
<div data-testid="editor-image-field"> | ||
<button onClick={() => onChange('editor-image')}>Editor Image Change</button> | ||
Editor Definition Field | ||
</div> | ||
); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...mponents/EditorSelector/Definition/ImageField/__tests__/__snapshots__/index.spec.tsx.snap
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,43 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`EditorDefinitionField snapshot 1`] = ` | ||
<div | ||
className="pf-c-form__group" | ||
> | ||
<div | ||
className="pf-c-form__group-label" | ||
> | ||
<label | ||
className="pf-c-form__label" | ||
> | ||
<span | ||
className="pf-c-form__label-text" | ||
> | ||
Editor Image | ||
</span> | ||
</label> | ||
</div> | ||
<div | ||
className="pf-c-form__group-control" | ||
> | ||
<input | ||
aria-invalid={false} | ||
aria-label="Editor Image" | ||
className="pf-c-form-control" | ||
data-ouia-component-id="OUIA-Generated-TextInputBase-1" | ||
data-ouia-component-type="PF4/TextInput" | ||
data-ouia-safe={true} | ||
disabled={false} | ||
onBlur={[Function]} | ||
onChange={[Function]} | ||
onFocus={[Function]} | ||
placeholder="Enter an editor container image" | ||
required={false} | ||
type="text" | ||
value="" | ||
/> | ||
</div> | ||
</div> | ||
`; |
Oops, something went wrong.