Skip to content

Commit b868907

Browse files
committed
Get ProjectManageModal cleaner
1 parent fffcf7d commit b868907

File tree

5 files changed

+65
-28
lines changed

5 files changed

+65
-28
lines changed

src/i18n/locales/en/translation.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@
3737
"BLOCKS": "Blocks",
3838
"CODE": "Code",
3939
"COPY": "Copy",
40+
"FAILED_TO_RENAME_PROJECT": "Failed to rename project",
41+
"FAILED_TO_COPY_PROJECT": "Failed to copy project",
42+
"FAILED_TO_CREATE_PROJECT": "Failed to create a new project.",
43+
"FAILED_TO_DELETE_PROJECT": "Failed to delete the project.",
44+
"RENAME_PROJECT": "Rename Project",
45+
"COPY_PROJECT": "Copy Project",
46+
"NAME": "Name",
47+
"ACTIONS": "Actions",
48+
"DELETE_PROJECT_CONFIRM": "Delete {projectName}?",
49+
"DELETE_CANNOT_BE_UNDONE": "This action cannot be undone.",
50+
"NO_PROJECTS_FOUND": "No projects found",
51+
"CREATE_PROJECT_TO_START": "Please create a new project to get started.",
52+
"PAGINATION_ITEMS": "{range0}-{range1} of {total} items",
4053
"MECHANISMS": "Mechanisms",
4154
"OPMODES": "OpModes",
4255
"BLOCKLY":{

src/i18n/locales/es/translation.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@
3434
"BLOCKS": "Bloques",
3535
"CODE": "Código",
3636
"COPY": "Copiar",
37+
"FAILED_TO_RENAME_PROJECT": "Error al renombrar proyecto",
38+
"FAILED_TO_COPY_PROJECT": "Error al copiar proyecto",
39+
"FAILED_TO_CREATE_PROJECT": "Error al crear un nuevo proyecto.",
40+
"FAILED_TO_DELETE_PROJECT": "Error al eliminar el proyecto.",
41+
"RENAME_PROJECT": "Renombrar Proyecto",
42+
"COPY_PROJECT": "Copiar Proyecto",
43+
"NAME": "Nombre",
44+
"ACTIONS": "Acciones",
45+
"DELETE_PROJECT_CONFIRM": "¿Eliminar {projectName}?",
46+
"DELETE_CANNOT_BE_UNDONE": "Esta acción no se puede deshacer.",
47+
"NO_PROJECTS_FOUND": "No se encontraron proyectos",
48+
"CREATE_PROJECT_TO_START": "Por favor crea un nuevo proyecto para comenzar.",
49+
"PAGINATION_ITEMS": "{range0}-{range1} de {total} elementos",
3750
"addTabDialog": {
3851
"title": "Agregar Pestaña",
3952
"search": "Buscar..."

src/i18n/locales/he/translation.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@
3737
"BLOCKS": "בלוקים",
3838
"CODE": "קוד",
3939
"COPY": "העתק",
40+
"FAILED_TO_RENAME_PROJECT": "נכשל בשינוי שם הפרויקט",
41+
"FAILED_TO_COPY_PROJECT": "נכשל בהעתקת הפרויקט",
42+
"FAILED_TO_CREATE_PROJECT": "נכשל ביצירת פרויקט חדש.",
43+
"FAILED_TO_DELETE_PROJECT": "נכשל במחיקת הפרויקט.",
44+
"RENAME_PROJECT": "שנה שם פרויקט",
45+
"COPY_PROJECT": "העתק פרויקט",
46+
"NAME": "שם",
47+
"ACTIONS": "פעולות",
48+
"DELETE_PROJECT_CONFIRM": "מחק את {projectName}?",
49+
"DELETE_CANNOT_BE_UNDONE": "פעולה זו לא ניתנת לביטול.",
50+
"NO_PROJECTS_FOUND": "לא נמצאו פרויקטים",
51+
"CREATE_PROJECT_TO_START": "אנא צור פרויקט חדש כדי להתחיל.",
52+
"PAGINATION_ITEMS": "{range0}-{range1} מתוך {total} פריטים",
4053
"MECHANISMS": "מנגנונים",
4154
"OPMODES": "מצבי פעולה",
4255
"BLOCKLY":{

src/reactComponents/ProjectManageModal.tsx

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export default function ProjectManageModal(props: ProjectManageModalProps): Reac
113113
await loadProjectNames(props.storage);
114114
} catch (error) {
115115
console.error('Error renaming project:', error);
116-
props.setAlertErrorMessage('Failed to rename project');
116+
props.setAlertErrorMessage(t('FAILED_TO_RENAME_PROJECT'));
117117
}
118118

119119
setRenameModalOpen(false);
@@ -134,7 +134,7 @@ export default function ProjectManageModal(props: ProjectManageModalProps): Reac
134134
await loadProjectNames(props.storage);
135135
} catch (error) {
136136
console.error('Error copying project:', error);
137-
props.setAlertErrorMessage('Failed to copy project');
137+
props.setAlertErrorMessage(t('FAILED_TO_COPY_PROJECT'));
138138
}
139139

140140
setCopyModalOpen(false);
@@ -154,11 +154,12 @@ export default function ProjectManageModal(props: ProjectManageModalProps): Reac
154154
);
155155
} catch (e) {
156156
console.error('Failed to create a new project:', e);
157-
props.setAlertErrorMessage('Failed to create a new project.');
157+
props.setAlertErrorMessage(t('FAILED_TO_CREATE_PROJECT'));
158158
}
159159

160160
setNewItemName('');
161161
await loadProjectNames(props.storage);
162+
handleSelectProject(newProjectName);
162163
};
163164

164165
/** Handles project deletion with proper cleanup. */
@@ -191,7 +192,7 @@ export default function ProjectManageModal(props: ProjectManageModalProps): Reac
191192
await storageProject.deleteProject(props.storage, projectNameToDelete);
192193
} catch (e) {
193194
console.error('Failed to delete the project:', e);
194-
props.setAlertErrorMessage('Failed to delete the project.');
195+
props.setAlertErrorMessage(t('FAILED_TO_DELETE_PROJECT'));
195196
}
196197
};
197198

@@ -222,12 +223,12 @@ export default function ProjectManageModal(props: ProjectManageModalProps): Reac
222223

223224
/** Gets the rename modal title. */
224225
const getRenameModalTitle = (): string => {
225-
return `Rename Project: ${currentRecord ? currentRecord.projectName : ''}`;
226+
return `${t('RENAME_PROJECT')}: ${currentRecord ? currentRecord.projectName : ''}`;
226227
};
227228

228229
/** Gets the copy modal title. */
229230
const getCopyModalTitle = (): string => {
230-
return `Copy Project: ${currentRecord ? currentRecord.projectName : ''}`;
231+
return `${t('COPY_PROJECT')}: ${currentRecord ? currentRecord.projectName : ''}`;
231232
};
232233

233234
/** Creates the container style object. */
@@ -246,7 +247,7 @@ export default function ProjectManageModal(props: ProjectManageModalProps): Reac
246247
/** Table column configuration. */
247248
const columns: Antd.TableProps<ProjectRecord>['columns'] = [
248249
{
249-
title: 'Name',
250+
title: t('NAME'),
250251
dataIndex: 'projectName',
251252
key: 'projectName',
252253
ellipsis: {
@@ -259,7 +260,7 @@ export default function ProjectManageModal(props: ProjectManageModalProps): Reac
259260
),
260261
},
261262
{
262-
title: 'Actions',
263+
title: t('ACTIONS'),
263264
key: 'actions',
264265
width: ACTIONS_COLUMN_WIDTH,
265266
render: (_, record: ProjectRecord) => (
@@ -291,8 +292,8 @@ export default function ProjectManageModal(props: ProjectManageModalProps): Reac
291292
{allProjectRecords.length > 1 && (
292293
<Antd.Tooltip title={t('Delete')}>
293294
<Antd.Popconfirm
294-
title={`Delete ${record.projectName}?`}
295-
description="This action cannot be undone."
295+
title={t('DELETE_PROJECT_CONFIRM', { projectName: record.projectName })}
296+
description={t('DELETE_CANNOT_BE_UNDONE')}
296297
onConfirm={() => handleDeleteProject(record.projectName)}
297298
okText={t('Delete')}
298299
cancelText={t('Cancel')}
@@ -377,30 +378,18 @@ export default function ProjectManageModal(props: ProjectManageModalProps): Reac
377378
title={t('Project Management')}
378379
open={props.isOpen}
379380
onCancel={props.onCancel}
380-
footer={[
381-
<Antd.Button key="close" onClick={props.onCancel}>
382-
{t('Close')}
383-
</Antd.Button>,
384-
]}
381+
footer={null}
385382
width={MODAL_WIDTH}
386383
>
387384
{props.noProjects && (
388385
<Antd.Alert
389-
message="No projects found"
390-
description="Please create a new project to get started."
386+
message={t('NO_PROJECTS_FOUND')}
387+
description={t('CREATE_PROJECT_TO_START')}
391388
type="info"
392389
showIcon
393390
style={getAlertStyle()}
394391
/>
395392
)}
396-
<div style={getContainerStyle()}>
397-
<ProjectNameComponent
398-
newItemName={newItemName}
399-
setNewItemName={setNewItemName}
400-
onAddNewItem={handleAddNewItem}
401-
projectNames={allProjectNames}
402-
/>
403-
</div>
404393
{!props.noProjects && (
405394
<Antd.Table<ProjectRecord>
406395
columns={columns}
@@ -412,17 +401,26 @@ export default function ProjectManageModal(props: ProjectManageModalProps): Reac
412401
showSizeChanger: false,
413402
showQuickJumper: false,
414403
showTotal: (total, range) =>
415-
`${range[0]}-${range[1]} of ${total} items`,
404+
t('PAGINATION_ITEMS', { range0: range[0], range1: range[1], total }),
416405
} : false}
417406
bordered
418407
locale={{
419-
emptyText: 'No projects found',
408+
emptyText: t('NO_PROJECTS_FOUND'),
420409
}}
421410
onRow={(record) => ({
422411
onDoubleClick: () => handleSelectProject(record.projectName),
423412
})}
424413
/>
425414
)}
415+
<br />
416+
<div style={getContainerStyle()}>
417+
<ProjectNameComponent
418+
newItemName={newItemName}
419+
setNewItemName={setNewItemName}
420+
onAddNewItem={handleAddNewItem}
421+
projectNames={allProjectNames}
422+
/>
423+
</div>
426424
</Antd.Modal>
427425
</>
428426
);

src/reactComponents/ProjectNameComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export default function ProjectNameComponent(props: ProjectNameComponentProps):
121121
type="primary"
122122
onClick={handleAddNewItem}
123123
>
124-
{t('New')}
124+
{t('CREATE')}
125125
</Antd.Button>
126126
);
127127

0 commit comments

Comments
 (0)