-
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.
* fix: workspace actions toggling * refactor: rework WorkspaceActionsProvider, extract consumers Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com> * refactor: update sidebar navigation Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com> * refactor: update workspaces list Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com> * refactor: workspace details page Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com> * chore: clean up Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com> * fixup! refactor: workspace details page * fixup! fixup! refactor: workspace details page * fixup! fixup! fixup! refactor: workspace details page * fixup! fixup! fixup! fixup! refactor: workspace details page * Update packages/dashboard-frontend/src/contexts/WorkspaceActions/DeleteButton/__tests__/index.spec.tsx Co-authored-by: Oleksii Orel <oorel@redhat.com> * Fix linter warning --------- Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com> Co-authored-by: Oleksii Orel <oorel@redhat.com>
- Loading branch information
Showing
57 changed files
with
2,619 additions
and
1,875 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
19 changes: 19 additions & 0 deletions
19
.../dashboard-frontend/src/Layout/Navigation/RecentItem/WorkspaceActions/__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,19 @@ | ||
/* | ||
* 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'; | ||
|
||
export class RecentItemWorkspaceActions extends React.PureComponent { | ||
render(): React.ReactNode { | ||
return <div>RecentItemWorkspaceActions</div>; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...Layout/Navigation/RecentItem/WorkspaceActions/__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,19 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`RecentItemWorkspaceActions snapshot 1`] = ` | ||
<div | ||
onClick={[Function]} | ||
> | ||
<div | ||
data-testid="workspace-actions-dropdown" | ||
> | ||
<button | ||
data-testid="workspace-actions-dropdown-open-workspace-button" | ||
disabled={false} | ||
onClick={[Function]} | ||
> | ||
Open | ||
</button> | ||
</div> | ||
</div> | ||
`; |
53 changes: 53 additions & 0 deletions
53
...board-frontend/src/Layout/Navigation/RecentItem/WorkspaceActions/__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,53 @@ | ||
/* | ||
* 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 { Provider } from 'react-redux'; | ||
|
||
import { NavigationRecentItemObject } from '@/Layout/Navigation'; | ||
import { RecentItemWorkspaceActions } from '@/Layout/Navigation/RecentItem/WorkspaceActions'; | ||
import getComponentRenderer from '@/services/__mocks__/getComponentRenderer'; | ||
import { constructWorkspace } from '@/services/workspace-adapter'; | ||
import { DevWorkspaceBuilder } from '@/store/__mocks__/devWorkspaceBuilder'; | ||
import { FakeStoreBuilder } from '@/store/__mocks__/storeBuilder'; | ||
|
||
jest.mock('@/contexts/WorkspaceActions/Dropdown'); | ||
|
||
const { createSnapshot } = getComponentRenderer(getComponent); | ||
|
||
describe('RecentItemWorkspaceActions', () => { | ||
test('snapshot', () => { | ||
const workspace = constructWorkspace( | ||
new DevWorkspaceBuilder() | ||
.withName('my-workspace') | ||
.withUID('1234') | ||
.withStatus({ phase: 'STOPPED' }) | ||
.build(), | ||
); | ||
|
||
const snapshot = createSnapshot({ | ||
label: 'my-workspace', | ||
to: '/namespace/my-workspace', | ||
workspace, | ||
}); | ||
expect(snapshot).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
function getComponent(item: NavigationRecentItemObject): React.ReactElement { | ||
const store = new FakeStoreBuilder().build(); | ||
return ( | ||
<Provider store={store}> | ||
<RecentItemWorkspaceActions item={item} /> | ||
</Provider> | ||
); | ||
} |
58 changes: 58 additions & 0 deletions
58
packages/dashboard-frontend/src/Layout/Navigation/RecentItem/WorkspaceActions/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,58 @@ | ||
/* | ||
* 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 { WorkspaceActionsConsumer } from '@/contexts/WorkspaceActions'; | ||
import { WorkspaceActionsDropdown } from '@/contexts/WorkspaceActions/Dropdown'; | ||
import { NavigationRecentItemObject } from '@/Layout/Navigation'; | ||
|
||
type Props = { | ||
item: NavigationRecentItemObject; | ||
}; | ||
|
||
export class RecentItemWorkspaceActions extends React.PureComponent<Props> { | ||
constructor(props: Props) { | ||
super(props); | ||
} | ||
|
||
public render(): React.ReactElement { | ||
const { item } = this.props; | ||
const menuAppendTo = document.body; | ||
|
||
return ( | ||
<div | ||
onClick={e => { | ||
e.stopPropagation(); | ||
}} | ||
> | ||
<WorkspaceActionsConsumer> | ||
{context => { | ||
return ( | ||
<WorkspaceActionsDropdown | ||
context={context} | ||
isPlain | ||
menuAppendTo={menuAppendTo} | ||
onAction={async () => { | ||
// no-op | ||
}} | ||
position="right" | ||
toggle="kebab-toggle" | ||
workspace={item.workspace} | ||
/> | ||
); | ||
}} | ||
</WorkspaceActionsConsumer> | ||
</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
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
Oops, something went wrong.