-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Full content of the .gitconfig (#1271)
* feat: show full content of .gitconfig Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com> * chore: re-generate list of licenses Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com> * fixup! feat: show full content of .gitconfig * fixup! chore: re-generate list of licenses * fixup! fixup! feat: show full content of .gitconfig --------- Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
- Loading branch information
Showing
22 changed files
with
794 additions
and
278 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
29 changes: 29 additions & 0 deletions
29
packages/dashboard-frontend/src/components/BasicViewer/__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,29 @@ | ||
/* | ||
* 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/BasicViewer'; | ||
|
||
export class BasicViewer extends React.PureComponent<Props> { | ||
public render(): React.ReactNode { | ||
const { id, value } = this.props; | ||
|
||
return ( | ||
<div> | ||
Mock Basic Viewer | ||
<span data-testid="basic-viewer-id">{id}</span> | ||
<span data-testid="basic-viewer-value">{value}</span> | ||
</div> | ||
); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...dashboard-frontend/src/components/BasicViewer/__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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`BasicViewer snapshot 1`] = ` | ||
<div | ||
className="basicViewer" | ||
> | ||
<div | ||
id="basic-viewer-id" | ||
/> | ||
</div> | ||
`; |
43 changes: 43 additions & 0 deletions
43
packages/dashboard-frontend/src/components/BasicViewer/__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,43 @@ | ||
/* | ||
* 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 { BasicViewer } from '@/components/BasicViewer'; | ||
import getComponentRenderer, { screen } from '@/services/__mocks__/getComponentRenderer'; | ||
|
||
const { createSnapshot, renderComponent } = getComponentRenderer(getComponent); | ||
|
||
describe('BasicViewer', () => { | ||
test('snapshot', () => { | ||
const snapshot = createSnapshot('line 1\nline 2\nline 3'); | ||
expect(snapshot.toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
test('handle content change', () => { | ||
const { reRenderComponent } = renderComponent('line 1\nline 2\nline 3'); | ||
|
||
const textbox = screen.getByRole('textbox'); | ||
|
||
// no new line character | ||
expect(textbox).toHaveTextContent('line 1line 2line 3'); | ||
|
||
reRenderComponent('line 4\nline 5\nline 6'); | ||
|
||
// no new line character | ||
expect(textbox).toHaveTextContent('line 4line 5line 6'); | ||
}); | ||
}); | ||
|
||
function getComponent(value: string): React.ReactElement { | ||
return <BasicViewer id="basic-viewer-id" value={value} />; | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/dashboard-frontend/src/components/BasicViewer/index.module.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* 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 | ||
*/ | ||
|
||
.basicViewer { | ||
overflow: auto; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
.basicViewer > div { | ||
overflow: auto; | ||
height: 100%; | ||
border: 1px solid var(--pf-global--BorderColor--100); | ||
} |
66 changes: 66 additions & 0 deletions
66
packages/dashboard-frontend/src/components/BasicViewer/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,66 @@ | ||
/* | ||
* 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 { defaultHighlightStyle, syntaxHighlighting } from '@codemirror/language'; | ||
import { EditorState } from '@codemirror/state'; | ||
import { EditorView } from '@codemirror/view'; | ||
import React from 'react'; | ||
|
||
import styles from '@/components/BasicViewer/index.module.css'; | ||
|
||
export type Props = { | ||
value: string; | ||
id: string; | ||
}; | ||
|
||
export class BasicViewer extends React.PureComponent<Props> { | ||
private editor: EditorView | undefined; | ||
|
||
public componentDidMount(): void { | ||
const parent = window.document.querySelector(`#${this.props.id}`); | ||
if (parent) { | ||
const state = this.getEditorState(); | ||
this.editor = new EditorView({ | ||
state, | ||
parent, | ||
}); | ||
} | ||
} | ||
|
||
public componentWillUnmount(): void { | ||
if (this.editor) { | ||
this.editor.destroy(); | ||
} | ||
} | ||
|
||
componentDidUpdate(prevProps: Readonly<Props>): void { | ||
if (this.editor && this.props.value !== prevProps.value) { | ||
const state = this.getEditorState(); | ||
this.editor.setState(state); | ||
} | ||
} | ||
|
||
private getEditorState(): EditorState { | ||
return EditorState.create({ | ||
doc: this.props.value, | ||
extensions: [syntaxHighlighting(defaultHighlightStyle), EditorState.readOnly.of(true)], | ||
}); | ||
} | ||
|
||
public render(): React.ReactElement { | ||
return ( | ||
<div className={styles.basicViewer}> | ||
<div id={this.props.id}></div> | ||
</div> | ||
); | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
packages/dashboard-frontend/src/pages/UserPreferences/GitConfig/Toolbar/__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,34 @@ | ||
/* | ||
* 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 '@/pages/UserPreferences/GitConfig/Toolbar'; | ||
|
||
export class GitConfigToolbar extends React.PureComponent<Props> { | ||
render() { | ||
const { mode, onAdd, onChangeMode } = this.props; | ||
const nextMode = mode === 'form' ? 'viewer' : 'form'; | ||
return ( | ||
<div> | ||
Mock Git Config Toolbar | ||
<span data-testid="toolbar-mode">{mode}</span> | ||
<button data-testid="toolbar-on-add" onClick={onAdd}> | ||
Add | ||
</button> | ||
<button data-testid="toolbar-on-change-mode" onClick={() => onChangeMode(nextMode)}> | ||
Switch Mode | ||
</button> | ||
</div> | ||
); | ||
} | ||
} |
Oops, something went wrong.