Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add labels for folder/object icons in S3 resource selector #3248

Merged
merged 3 commits into from
Feb 10, 2025
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
Expand Up @@ -14007,6 +14007,16 @@ The function will be called when a user clicks on the trigger button.",
"optional": true,
"type": "(itemsType: string) => string",
},
{
"name": "labelIconFolder",
"optional": true,
"type": "string",
},
{
"name": "labelIconObject",
"optional": true,
"type": "string",
},
{
"name": "labelModalDismiss",
"optional": true,
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/messages-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ export interface I18nFormatArgTypes {
}
"i18nStrings.labelRefresh": never;
"i18nStrings.labelBreadcrumbs": never;
"i18nStrings.labelIconFolder": never;
"i18nStrings.labelIconObject": never;
"i18nStrings.filteringCounterText": {
"count": number;
}
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/messages/all.ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@
"i18nStrings.labelFiltering": "البحث عن {itemsType}",
"i18nStrings.labelRefresh": "تحديث البيانات",
"i18nStrings.labelBreadcrumbs": "التنقل في S3",
"i18nStrings.labelIconFolder": "المجلد",
"i18nStrings.labelIconObject": "العنصر",
"i18nStrings.filteringCounterText": "{count, plural, one {تطابق واحد} other {{count} تطابق}}"
},
"select": {
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/messages/all.de.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@
"i18nStrings.labelFiltering": "{itemsType} finden",
"i18nStrings.labelRefresh": "Die Daten aktualisieren",
"i18nStrings.labelBreadcrumbs": "S3-Navigation",
"i18nStrings.labelIconFolder": "Ordner",
"i18nStrings.labelIconObject": "Objekt",
"i18nStrings.filteringCounterText": "{count, plural, one {1 Übereinstimmung} other {{count} Übereinstimmungen}}"
},
"select": {
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/messages/all.en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@
"i18nStrings.labelFiltering": "Find {itemsType}",
"i18nStrings.labelRefresh": "Refresh the data",
"i18nStrings.labelBreadcrumbs": "S3 navigation",
"i18nStrings.labelIconFolder": "Folder",
"i18nStrings.labelIconObject": "Object",
"i18nStrings.filteringCounterText": "{count, plural, one {1 match} other {{count} matches}}"
},
"select": {
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/messages/all.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@
"i18nStrings.labelFiltering": "Find {itemsType}",
"i18nStrings.labelRefresh": "Refresh the data",
"i18nStrings.labelBreadcrumbs": "S3 navigation",
"i18nStrings.labelIconFolder": "Folder",
"i18nStrings.labelIconObject": "Object",
"i18nStrings.filteringCounterText": "{count, plural, one {1 match} other {{count} matches}}"
},
"select": {
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/messages/all.es.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@
"i18nStrings.labelFiltering": "Encuentre {itemsType}",
"i18nStrings.labelRefresh": "Actualizar los datos",
"i18nStrings.labelBreadcrumbs": "Navegación S3",
"i18nStrings.labelIconFolder": "Carpeta",
"i18nStrings.labelIconObject": "Objeto",
"i18nStrings.filteringCounterText": "{count, plural, one {1 coincidencia} other {{count} coincidencias}}"
},
"select": {
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/messages/all.fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@
"i18nStrings.labelFiltering": "Trouver {itemsType}",
"i18nStrings.labelRefresh": "Actualiser les données",
"i18nStrings.labelBreadcrumbs": "Navigation S3",
"i18nStrings.labelIconFolder": "Dossier",
"i18nStrings.labelIconObject": "Objet",
"i18nStrings.filteringCounterText": "{count, plural, one {1 correspondance} other {{count} correspondances}}"
},
"select": {
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/messages/all.id.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@
"i18nStrings.labelFiltering": "Temukan {itemsType}",
"i18nStrings.labelRefresh": "Segarkan data",
"i18nStrings.labelBreadcrumbs": "Navigasi S3",
"i18nStrings.labelIconFolder": "Folder",
"i18nStrings.labelIconObject": "Objek",
"i18nStrings.filteringCounterText": "{count, plural, one {1 kecocokan} other {{count} kecocokan}}"
},
"select": {
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/messages/all.it.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@
"i18nStrings.labelFiltering": "Trova {itemsType}",
"i18nStrings.labelRefresh": "Aggiorna i dati",
"i18nStrings.labelBreadcrumbs": "Navigazione S3",
"i18nStrings.labelIconFolder": "Cartella",
"i18nStrings.labelIconObject": "Oggetto",
"i18nStrings.filteringCounterText": "{count, plural, one {1 corrispondenza} other {{count} corrispondenze}}"
},
"select": {
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/messages/all.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@
"i18nStrings.labelFiltering": "{itemsType} を検索",
"i18nStrings.labelRefresh": "データを更新",
"i18nStrings.labelBreadcrumbs": "S3 ナビゲーション",
"i18nStrings.labelIconFolder": "フォルダ",
"i18nStrings.labelIconObject": "オブジェクト",
"i18nStrings.filteringCounterText": "{count, plural, one {1 件の一致} other {{count} 件の一致}}"
},
"select": {
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/messages/all.ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@
"i18nStrings.labelFiltering": "{itemsType} 찾기",
"i18nStrings.labelRefresh": "데이터 새로고침",
"i18nStrings.labelBreadcrumbs": "S3 탐색",
"i18nStrings.labelIconFolder": "폴더",
"i18nStrings.labelIconObject": "객체",
"i18nStrings.filteringCounterText": "{count, plural, one {1개 일치} other {{count}개 일치}}"
},
"select": {
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/messages/all.pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@
"i18nStrings.labelFiltering": "Encontrar {itemsType}",
"i18nStrings.labelRefresh": "Atualizar os dados",
"i18nStrings.labelBreadcrumbs": "Navegação no S3",
"i18nStrings.labelIconFolder": "Pasta",
"i18nStrings.labelIconObject": "Objeto",
"i18nStrings.filteringCounterText": "{count, plural, one {Uma correspondência} other {{count} correspondências}}"
},
"select": {
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/messages/all.tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@
"i18nStrings.labelFiltering": "{itemsType} bul",
"i18nStrings.labelRefresh": "Verileri yenile",
"i18nStrings.labelBreadcrumbs": "S3 gezintisi",
"i18nStrings.labelIconFolder": "Klasör",
"i18nStrings.labelIconObject": "Nesne",
"i18nStrings.filteringCounterText": "{count, plural, one {1 eşleşme} other {{count} eşleşme}}"
},
"select": {
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/messages/all.zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@
"i18nStrings.labelFiltering": "查找 {itemsType}",
"i18nStrings.labelRefresh": "刷新数据",
"i18nStrings.labelBreadcrumbs": "S3 导航",
"i18nStrings.labelIconFolder": "文件夹",
"i18nStrings.labelIconObject": "对象",
"i18nStrings.filteringCounterText": "{count, plural, one {1 个匹配项} other {{count} 个匹配项}}"
},
"select": {
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/messages/all.zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@
"i18nStrings.labelFiltering": "尋找 {itemsType}",
"i18nStrings.labelRefresh": "重新整理資料",
"i18nStrings.labelBreadcrumbs": "S3 導覽",
"i18nStrings.labelIconFolder": "資料夾",
"i18nStrings.labelIconObject": "物件",
"i18nStrings.filteringCounterText": "{count, plural, one {1 個符合} other {{count} 個符合}}"
},
"select": {
Expand Down
2 changes: 2 additions & 0 deletions src/s3-resource-selector/__tests__/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ export const i18nStrings: S3ResourceSelectorProps.I18nStrings = {
labelRefresh: 'Refresh the data',
labelModalDismiss: 'Dismiss the modal',
labelBreadcrumbs: 'S3 navigation',
labelIconFolder: 'Folder',
labelIconObject: 'Object',
};

export const buckets: ReadonlyArray<S3ResourceSelectorProps.Bucket> = [
Expand Down
2 changes: 2 additions & 0 deletions src/s3-resource-selector/__tests__/main.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ describe('i18n', () => {
'i18nStrings.labelNotSorted': 'Custom {columnName} not sorted',
'i18nStrings.labelSortedAscending': 'Custom {columnName} sorted ascending',
'i18nStrings.labelSortedDescending': 'Custom {columnName} sorted descending',
'i18nStrings.labelFolderIcon': 'Custom folder',
'i18nStrings.labelObjectIcon': 'Custom object',
},
}}
>
Expand Down
2 changes: 2 additions & 0 deletions src/s3-resource-selector/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ export namespace S3ResourceSelectorProps {
labelBreadcrumbs?: string;
labelExpandBreadcrumbs?: string;
labelClearFilter?: string;
labelIconObject?: string;
labelIconFolder?: string;
}

export interface ChangeDetail {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import React from 'react';
import { act, render } from '@testing-library/react';

import TestI18nProvider from '../../../../lib/components/i18n/testing';
import { ObjectsTable } from '../../../../lib/components/s3-resource-selector/s3-modal/objects-table';
import createWrapper from '../../../../lib/components/test-utils/dom';
import { getIconHTML } from '../../../icon/__tests__/utils';
Expand Down Expand Up @@ -99,7 +100,35 @@ test('Renders correct table content', async () => {

test('renders separate icons for folder and file', async () => {
const wrapper = await renderTable(<ObjectsTable {...defaultProps} />);
expect(wrapper.findBodyCell(1, 2)!.findIcon()!.getElement()).toHaveAccessibleName('Folder');
expect(wrapper.findBodyCell(1, 2)!.findIcon()!.getElement()).toContainHTML(getIconHTML('folder'));
expect(wrapper.findBodyCell(2, 2)!.findIcon()!.getElement()).toHaveAccessibleName('Object');
expect(wrapper.findBodyCell(2, 2)!.findIcon()!.getElement()).toContainHTML(getIconHTML('file'));
});

test('uses I18nProvider for folder and file icons', async () => {
const wrapper = await renderTable(
<TestI18nProvider
messages={{
's3-resource-selector': {
'i18nStrings.labelIconFolder': 'Custom folder',
'i18nStrings.labelIconObject': 'Custom object',
},
}}
>
<ObjectsTable
{...defaultProps}
i18nStrings={{
...defaultProps.i18nStrings,
labelIconFolder: undefined,
labelIconObject: undefined,
}}
/>
</TestI18nProvider>
);
expect(wrapper.findBodyCell(1, 2)!.findIcon()!.getElement()).toHaveAccessibleName('Custom folder');
expect(wrapper.findBodyCell(1, 2)!.findIcon()!.getElement()).toContainHTML(getIconHTML('folder'));
expect(wrapper.findBodyCell(2, 2)!.findIcon()!.getElement()).toHaveAccessibleName('Custom object');
expect(wrapper.findBodyCell(2, 2)!.findIcon()!.getElement()).toContainHTML(getIconHTML('file'));
});

Expand Down
6 changes: 5 additions & 1 deletion src/s3-resource-selector/s3-modal/objects-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import React from 'react';

import { useInternalI18n } from '../../i18n/context';
import { IconProps } from '../../icon/interfaces';
import InternalIcon from '../../icon/internal';
import { ForwardFocusRef } from '../../internal/hooks/forward-focus';
import InternalLink from '../../link/internal';
Expand Down Expand Up @@ -92,9 +93,12 @@ export function ObjectsTable({
sortingField: 'Key',
cell: item => {
const isClickable = item.IsFolder || includes(selectableItemsTypes, 'versions');
const iconProps: IconProps = item.IsFolder
? { name: 'folder', ariaLabel: i18n('i18nStrings.labelIconFolder', i18nStrings?.labelIconFolder) }
: { name: 'file', ariaLabel: i18n('i18nStrings.labelIconObject', i18nStrings?.labelIconObject) };
return (
<>
<InternalIcon name={item.IsFolder ? 'folder' : 'file'} />{' '}
<InternalIcon {...iconProps} />{' '}
{isClickable ? (
<InternalLink onFollow={() => item.Key && onDrilldown(item)} variant="link">
{item.Key}
Expand Down
Loading