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
23 changes: 11 additions & 12 deletions client/modules/User/components/CollectionItemRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { useTranslation } from 'react-i18next';
import { useDispatch } from 'react-redux';
import { removeFromCollection } from '../../IDE/actions/collections';
import { formatDateToString } from '../../../utils/formatDate';
import RemoveIcon from '../../../images/close.svg';
import { Tooltip } from '../../../common/Tooltip';
import { TableDropdown } from '../../../components/Dropdown/TableDropdown';
import { MenuItem } from '../../../components/Dropdown/MenuItem';

const CollectionItemRow = ({ collection, item, isOwner }) => {
const { t } = useTranslation();
Expand Down Expand Up @@ -47,17 +47,16 @@ const CollectionItemRow = ({ collection, item, isOwner }) => {
<th scope="row">{name}</th>
<td>{formatDateToString(item.createdAt)}</td>
<td>{sketchOwnerUsername}</td>
<td className="collection-row__action-column">
<td className="sketch-list__dropdown-column">
{isOwner && (
<Tooltip content={t('Collection.SketchRemoveARIA')}>
<button
className="collection-row__remove-button"
onClick={handleSketchRemove}
aria-label={t('Collection.SketchRemoveARIA')}
>
<RemoveIcon focusable="false" aria-hidden="true" />
</button>
</Tooltip>
<TableDropdown
aria-label={t('SketchList.ToggleLabelARIA')}
className="collection-item__dropdown"
>
<MenuItem onClick={handleSketchRemove}>
{t('Collection.SketchRemoveLabel')}
</MenuItem>
</TableDropdown>
)}
</td>
</tr>
Expand Down
20 changes: 5 additions & 15 deletions client/modules/User/components/CollectionItemRow.unit.test.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import thunk from 'redux-thunk';
import configureStore from 'redux-mock-store';
import { reduxRender, screen, fireEvent, act } from '../../../test-utils';
import { reduxRender, screen } from '../../../test-utils';
import { initialTestState } from '../../../testData/testReduxStore';
import CollectionItemRow from './CollectionItemRow';

Expand Down Expand Up @@ -56,9 +56,9 @@ describe('<CollectionItemRow />', () => {
expect(screen.getByText('testuser')).toBeInTheDocument();
});

it('shows the remove button when user is the owner', () => {
it('shows the dropdown menu when user is the owner', () => {
subject();
expect(screen.getByRole('button', { name: /remove/i })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /toggle/i })).toBeInTheDocument();
});

describe('when user is not the owner', () => {
Expand All @@ -70,24 +70,14 @@ describe('<CollectionItemRow />', () => {
subjectProps = { ...subjectProps, isOwner: true };
});

it('does not show the remove button', () => {
it('does not show the dropdown menu', () => {
subject();
expect(
screen.queryByRole('button', { name: /remove/i })
screen.queryByRole('button', { name: /toggle/i })
).not.toBeInTheDocument();
});
});

it('wraps the remove button with a tooltip', async () => {
subject();

const button = screen.getByRole('button', { name: /remove/i });
await act(async () => {
fireEvent.mouseEnter(button);
});
expect(button).toHaveClass('tooltipped');
});

describe('when the project is deleted', () => {
beforeAll(() => {
subjectProps = {
Expand Down
61 changes: 7 additions & 54 deletions client/styles/components/_collection.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
padding: #{math.div(24, $base-font-size)}rem #{math.div(66, $base-font-size)}rem;
position: relative;
flex: 1;
overflow: hidden;
overflow: visible;
display: flex;
flex-direction:column;

Expand Down Expand Up @@ -116,7 +116,7 @@
display: flex;
flex-direction: column;
flex: 1;
overflow: hidden;
overflow: visible;
max-width: #{math.div(1012, $base-font-size)}rem;
margin: 0 auto;
width: 100%;
Expand All @@ -127,7 +127,6 @@
}

.collection-table-wrapper {
overflow-y: auto;
max-width: 100%;
min-height: 100%;
}
Expand All @@ -145,57 +144,11 @@
font-size: #{math.div(16, $base-font-size)}rem;
}

.collection-row__action-column {
width: #{math.div(60, $base-font-size)}rem;
position: relative;

.tooltip-wrapper {
display: inline-flex;
width: auto;

.tooltipped::after {
right: 0;
left: auto;
}

.tooltipped-n::before,
.tooltipped::before {
right: #{math.div(10, $base-font-size)}rem;
left: auto;
}
.collection-item__dropdown {
& ul {
width: #{math.div(180, $base-font-size)}rem;
top: 74%;
right: calc(100% - 26px);
}
}

.collection-row__remove-button {
display: inline-block;
width:#{math.div(35, $base-font-size)}rem;
height:#{math.div(35, $base-font-size)}rem;
@include icon();
@include themify() {
// icon graphic
path {
fill: getThemifyVariable('table-button-color');
}

// icon background circle
path:first-child {
fill: getThemifyVariable('table-button-background-color');
}

& svg {
width:#{math.div(35, $base-font-size)}rem;
height:#{math.div(35, $base-font-size)}rem;
}

&:hover,
&:focus {
path {
fill: getThemifyVariable('table-button-hover-color');
}

path:first-child {
fill: getThemifyVariable('table-button-background-hover-color');
}
}
}
}
1 change: 1 addition & 0 deletions translations/locales/bn/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@
"AddSketch": "স্কেচ যোগ করুন",
"DeleteFromCollection": "{{name_sketch}} কে এই সংগ্রহ থেকে সরাতে চান কি না?",
"SketchDeleted": "স্কেচ ডিলিট হয়েছে",
"SketchRemoveLabel": "Remove from Collection",
"SketchRemoveARIA": "সংগ্রহ থেকে স্কেচ রিমুভ করুন",
"DescriptionPlaceholder": "বর্ণনা যোগ করুন",
"NumSketches": "{{count}} স্কেচ",
Expand Down
1 change: 1 addition & 0 deletions translations/locales/de/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@
"AddSketch": "Sketch hinzufügen",
"DeleteFromCollection": "Bist Du sicher, dass Du {{name_sketch}} aus dieser Sammlung entfernen willst?",
"SketchDeleted": "Sketch gelöscht",
"SketchRemoveLabel": "Remove from Collection",
"SketchRemoveARIA": "Sketch aus der Sammlung entfernen",
"DescriptionPlaceholder": "Beschreibung hinzufügen",
"Description": "Beschreibung",
Expand Down
1 change: 1 addition & 0 deletions translations/locales/en-US/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@
"DeleteFromCollection": "Are you sure you want to remove {{name_sketch}} from this collection?",
"SketchDeleted": "Sketch deleted",
"SketchRemoveARIA": "Remove sketch from collection",
"SketchRemoveLabel": "Remove from Collection",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sorry I think these are the last few changes—since this is a new translation key, would you be able to add this to the other translation files to help with tracking changes? You can add in their English translation as a placeholder!

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.

thank you for the heads up! added the SketchRemoveLabel key to all locale files as a placeholder with the english value

"DescriptionPlaceholder": "Add description",
"Description": "description",
"NumSketches": "{{count}} sketch",
Expand Down
1 change: 1 addition & 0 deletions translations/locales/es-419/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@
"AddSketch": "Agregar Bosquejo",
"DeleteFromCollection": "¿Estás seguro que quieres remover {{name_sketch}} de esta colección?",
"SketchDeleted": "El bosquejo fue eliminado",
"SketchRemoveLabel": "Remove from Collection",
"SketchRemoveARIA": "Remover bosquejo de la colección",
"DescriptionPlaceholder": "Agregar descripción",
"Description": "descripción",
Expand Down
1 change: 1 addition & 0 deletions translations/locales/fr-CA/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@
"AddSketch": "Ajouter un croquis",
"DeleteFromCollection": "Êtes-vous sûr de vouloir supprimer {{name_sketch}} de cette collection?",
"SketchDeleted": "Croquis supprimé",
"SketchRemoveLabel": "Remove from Collection",
"SketchRemoveARIA": "Supprimer le croquis de la collection",
"DescriptionPlaceholder": "Ajouter une description",
"Description": "description",
Expand Down
1 change: 1 addition & 0 deletions translations/locales/hi/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@
"AddSketch": "स्केच जोड़ें",
"DeleteFromCollection": "क्या आप वाकई {{name_sketch}} को इस संग्रह से हटाना चाहते हो?",
"SketchDeleted": "स्केच डिलीट किया",
"SketchRemoveLabel": "Remove from Collection",
"SketchRemoveARIA": "स्केच संग्रह से हटाएं",
"DescriptionPlaceholder": "विवरण लिखें",
"NumSketches": "{{count}} स्केच",
Expand Down
1 change: 1 addition & 0 deletions translations/locales/it/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@
"AddSketch": "Aggiungi sketch",
"DeleteFromCollection": "Sei sicuro di voler cancellare {{name_sketch}} dalla collezione?",
"SketchDeleted": "Sketch cancellato",
"SketchRemoveLabel": "Remove from Collection",
"SketchRemoveARIA": "Cancella sketch dalla collezione",
"DescriptionPlaceholder": "Aggiungi descrizione",
"Description": "descrizione",
Expand Down
1 change: 1 addition & 0 deletions translations/locales/ja/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@
"AddSketch": "スケッチを追加する",
"DeleteFromCollection": "このコレクションから {{name_sketch}} を削除してもよろしいですか?",
"SketchDeleted": "スケッチが削除されました",
"SketchRemoveLabel": "Remove from Collection",
"SketchRemoveARIA": "コレクションからスケッチを削除する",
"DescriptionPlaceholder": "スケッチについて記述する",
"Description": "コレクションについて",
Expand Down
1 change: 1 addition & 0 deletions translations/locales/ko/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@
"AddSketch": "스케치 추가하기 Add Sketch",
"DeleteFromCollection": "Are you sure you want to remove {{name_sketch}} from this collection?",
"SketchDeleted": "Sketch deleted",
"SketchRemoveLabel": "Remove from Collection",
"SketchRemoveARIA": "Remove sketch from collection",
"DescriptionPlaceholder": "Add description",
"Description": "description",
Expand Down
1 change: 1 addition & 0 deletions translations/locales/ne/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@
"AddSketch": "स्केच थप्नुहोस्",
"DeleteFromCollection": "के तपाईं पक्का यो कलेक्सनबाट {{name_sketch}} हटाउन चाहनुहुन्छ?",
"SketchDeleted": "स्केच डिलिट भयो",
"SketchRemoveLabel": "Remove from Collection",
"SketchRemoveARIA": "कलेक्सनबाट स्केच हटाउनुहोस्",
"DescriptionPlaceholder": "विवरण थप्नुहोस्",
"Description": "विवरण",
Expand Down
1 change: 1 addition & 0 deletions translations/locales/pt-BR/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@
"AddSketch": "Adicionar Esboço",
"DeleteFromCollection": "Realmente quer remover {{name_sketch}} dessa coleção?",
"SketchDeleted": "Esboço apagado",
"SketchRemoveLabel": "Remove from Collection",
"SketchRemoveARIA": "Remover esboço da coleção",
"DescriptionPlaceholder": "Adicionar descrição",
"NumSketches": "{{count}} esboço(s)",
Expand Down
1 change: 1 addition & 0 deletions translations/locales/sv/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@
"AddSketch": "Lägg till sketch",
"DeleteFromCollection": "Är du säker på att du vill radera {{name_sketch}} från den här samlingen?",
"SketchDeleted": "Sketchen är raderad",
"SketchRemoveLabel": "Remove from Collection",
"SketchRemoveARIA": "Radera sketch från samling",
"DescriptionPlaceholder": "Lägg till beskrivning",
"Description": "beskrivning",
Expand Down
1 change: 1 addition & 0 deletions translations/locales/tr/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@
"AddSketch": "Eskiz ekle",
"DeleteFromCollection": "{{name_sketch}} eskizini koleksiyondan kaldırmak istediğinizden emin misiniz?",
"SketchDeleted": "Eskiz silindi",
"SketchRemoveLabel": "Remove from Collection",
"SketchRemoveARIA": "Eskiz koleksiyondan kaldır",
"DescriptionPlaceholder": "Açıklama ekle",
"Description": "açıklama",
Expand Down
1 change: 1 addition & 0 deletions translations/locales/uk-UA/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@
"AddSketch": "Додати скетч",
"DeleteFromCollection": "Ви впевнені, що хочете видалити {{name_sketch}} з цієї колекції?",
"SketchDeleted": "Скетч видалено",
"SketchRemoveLabel": "Remove from Collection",
"SketchRemoveARIA": "Видалити скетч із колекції",
"DescriptionPlaceholder": "Додати опис",
"Description": "опис",
Expand Down
1 change: 1 addition & 0 deletions translations/locales/ur/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@
"AddSketch": "خاکہ شامل کریں۔",
"DeleteFromCollection": "کیا آپ واقعی ہٹانا چاہتے ہیں {{name_sketch}} اس مجموعہ سے؟",
"SketchDeleted": "خاکہ حذف کر دیا گیا۔",
"SketchRemoveLabel": "Remove from Collection",
"SketchRemoveARIA": "مجموعہ سے خاکہ کو ہٹا دیں۔",
"DescriptionPlaceholder": "تفصیل شامل کریں۔",
"Description": "تفصیل",
Expand Down
1 change: 1 addition & 0 deletions translations/locales/zh-CN/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@
"AddSketch": "添加项目",
"DeleteFromCollection": "您确定要从此集合中删除 {{name_sketch}} 吗?",
"SketchDeleted": "项目已删除",
"SketchRemoveLabel": "Remove from Collection",
"SketchRemoveARIA": "从集合中移除项目",
"DescriptionPlaceholder": "添加描述",
"Description": "描述",
Expand Down
1 change: 1 addition & 0 deletions translations/locales/zh-TW/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@
"AddSketch": "新增草稿",
"DeleteFromCollection": "確定要從本作品集移除 {{name_sketch}}?",
"SketchDeleted": "已刪除草稿",
"SketchRemoveLabel": "Remove from Collection",
"SketchRemoveARIA": "從作品集移除草稿",
"DescriptionPlaceholder": "新增說明",
"Description": "說明",
Expand Down
Loading