Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It has come up a couple times so I thought I should make a proposal for how I think we should share column renderers between tables. IMHO we have three cases: 1. Type-specific column rendering like Image name. These should continue to be type-specific as today. 2. Generic columns that really just need to (e.g.) render a string in a certain way. 3. The middle ground where it's a little more complex, or maybe you need to render a couple properties. This commit adds a simple type-mapping function to directly support #2, and applies it to VolumeList. For the middle ground, I think we're going to have convenient cases where objects used in two tables have the same property types & names (e.g. { id: string, some-prop: number}) and we can just render those, and other cases where maybe the renderer should use another type (e.g. Condition) or one of the objects has a different property name. Again, this commit provides a simple way for tables to do whatever mapping is required. Based on top of #5005 assuming that would merge soon. Fixes #5002. We would share more columns as we add other tables that would use them. Signed-off-by: Tim deBoer <git@tdeboer.ca>
- Loading branch information
1 parent
bf55792
commit ca30036
Showing
10 changed files
with
59 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/********************************************************************** | ||
* Copyright (C) 2023 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
***********************************************************************/ | ||
|
||
import '@testing-library/jest-dom/vitest'; | ||
import { test, expect } from 'vitest'; | ||
import { render, screen } from '@testing-library/svelte'; | ||
|
||
import SimpleColumn from './SimpleColumn.svelte'; | ||
|
||
test('Expect simple column styling', async () => { | ||
const obj = 'Test'; | ||
render(SimpleColumn, { object: obj }); | ||
|
||
const text = screen.getByText(obj); | ||
expect(text).toBeInTheDocument(); | ||
expect(text).toHaveClass('text-sm'); | ||
expect(text).toHaveClass('text-gray-700'); | ||
}); |
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 |
---|---|---|
|
@@ -2,4 +2,6 @@ | |
export let object: any; | ||
</script> | ||
|
||
{object.age} | ||
<div class="text-sm text-gray-700"> | ||
{object} | ||
</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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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