Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Private Image Sharing: include public images in images table in Linode Rebuild dialog ([#13568](https://github.com/linode/manager/pull/13568))
11 changes: 8 additions & 3 deletions packages/manager/src/components/ImageSelect/ImageSelectTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ interface Props {
* Error message to display above the table, e.g. from form validation.
*/
errorText?: string;
/**
* Determines whether additional filtering of images should be applied, typically if there is a StackScript selected.
*/
filter?: (image: Image) => boolean;
/**
* Callback fired when the user selects an image row.
*/
Expand All @@ -79,6 +83,7 @@ export const ImageSelectTable = (props: Props) => {
const {
currentRoute,
errorText,
filter,
onSelect,
pendoIDs,
queryParamsPrefix,
Expand Down Expand Up @@ -121,19 +126,19 @@ export const ImageSelectTable = (props: Props) => {
});

const {
data: imagesData,
data: _imagesData,
error: imagesError,
isFetching,
isLoading,
} = useAllImagesQuery(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As follow up work, could we make this new table use proper API pagination?

The API supports X-Filtering the Images endpoint on label, tags, and region so I think it would be possible. It could pay dividends in the future for accounts with tons of images.

Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created UIE-10836

{},
{
...combinedFilter,
is_public: false,
type: 'manual',
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is sufficient to achieve parity because looking at its ImageSelect counterpart, the variant is "all" so there's no filtering in useAllImagesQuery():

<ImageSelect
disabled={props.disabled}
errorText={fieldState.error?.message}
filter={getImageSelectFilter(stackscript)}
label="Image"
loading={isLoading}
noMarginTop
onChange={(value) => field.onChange(value?.id ?? null)}
value={field.value ?? null}
variant="all"
/>

and the StackScript-based filtering is applied a few lines down.

}
);

const imagesData = filter ? _imagesData?.filter(filter) : _imagesData;

const pagination = usePaginationV2({
clientSidePaginationData: imagesData,
currentRoute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const ImageSelectTableRow = (props: Props) => {
id,
image_sharing,
label,
regions: imageRegions,
regions: _imageRegions,
size,
status,
type,
Expand Down Expand Up @@ -77,6 +77,8 @@ export const ImageSelectTableRow = (props: Props) => {
return 'β€”';
};

const imageRegions = _imageRegions ?? []; // Failsafe for manual images whose `regions` property is null

const FormattedRegionList = () => (
<StyledFormattedRegionList>
{imageRegions.map((region: ImageRegion, idx) => {
Expand Down Expand Up @@ -125,7 +127,9 @@ export const ImageSelectTableRow = (props: Props) => {
? pluralize('Region', 'Regions', imageRegions.length)
: 'β€”'
}
tooltipText={<FormattedRegionList />}
tooltipText={
imageRegions?.length > 0 ? <FormattedRegionList /> : 'N/A'
}
/>
</TableCell>
</Hidden>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const Image = (props: Props) => {
: '/linodes') as LinkProps['to']
}
errorText={fieldState.error?.message}
filter={getImageSelectFilter(stackscript)}
onSelect={(image) => field.onChange(image?.id ?? null)}
pendoIDs={IMAGE_SELECT_TABLE_LINODE_REBUILD_PENDO_IDS}
queryParamsPrefix="images"
Expand Down
Loading