Skip to content

Commit

Permalink
feat: remove project from app if security token does not exist (#468)
Browse files Browse the repository at this point in the history
* fix issue#345

* only remove local project if sec-token not exist

* change the error message

* move the error notify to strings

* update delete project toast message

* update localization strings
  • Loading branch information
yongbing-chen authored Sep 29, 2020
1 parent d859d38 commit 730e196
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 14 deletions.
18 changes: 13 additions & 5 deletions src/common/localization/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const english: IAppStrings = {
composing: "Model is composing, please wait...",
column: {
icon: {
name:"Composed Icon",
name: "Composed Icon",
},
id: {
headerName: "Model Id",
Expand Down Expand Up @@ -480,7 +480,7 @@ export const english: IAppStrings = {
keys: {
lessThan: "<",
greaterThan: ">",
},
},
description: {
prevPage: "Go to previous page",
nextPage: "Go to next page",
Expand All @@ -491,7 +491,7 @@ export const english: IAppStrings = {
minus: "-",
plus: "=",
slash: "/",
},
},
description: {
in: "Zoom in",
out: "Zoom out",
Expand All @@ -502,11 +502,11 @@ export const english: IAppStrings = {
keys: {
delete: "Delete",
backSpace: "Backspace",
},
},
description: {
delete: "Remove selection and delete labels of selected words",
backSpace: "Remove selection and delete labels of selected words",
},
},
},
drawnRegions: {
keys: {
Expand Down Expand Up @@ -575,6 +575,10 @@ export const english: IAppStrings = {
message: `An error occured while deleting the project.
Validate the project file and security token exist and try again`,
},
projectDeleteErrorSecurityTokenNotFound: {
title: "Security token not found when delete project",
message: "Security Token Not Found. Project [${project.name}] has been removed from FoTT tool."
},
projectNotFound: {
title: "Error loading project",
message: "We couldn't find the project file ${file} at the target blob container ${container}.\
Expand Down Expand Up @@ -672,6 +676,10 @@ export const english: IAppStrings = {
title: "Model not found",
message: "Model \"${modelID}\" not found. Please use another model.",
},
connectionNotExistError: {
title: "Connection doesn't exist",
message: "Connection doesn't exist."
},
getOcrError: {
title: "Cannot load OCR file",
message: "Failed to load from OCR file. Please check your connection or network settings.",
Expand Down
20 changes: 14 additions & 6 deletions src/common/localization/es-cl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ export const spanish: IAppStrings = {
},
canvasCommandBar: {
items: {
layers:{
layers: {
text: "Capas",
subMenuItems: {
text: "Texto",
Expand Down Expand Up @@ -481,7 +481,7 @@ export const spanish: IAppStrings = {
keys: {
lessThan: "<",
greaterThan: ">",
},
},
description: {
prevPage: "Ir a la página anterior en documentos de varias páginas",
nextPage: "Ir a la página siguiente en documentos de varias páginas",
Expand All @@ -492,7 +492,7 @@ export const spanish: IAppStrings = {
minus: "-",
plus: "=",
slash: "/",
},
},
description: {
in: "Acercarse",
out: "Disminuir el zoom",
Expand All @@ -503,11 +503,11 @@ export const spanish: IAppStrings = {
keys: {
delete: "Delete",
backSpace: "Backspace",
},
},
description: {
delete: "Eliminar selección del mapa del documento o clave de selección de una etiqueta",
backSpace: "Eliminar selección del mapa del documento o clave de selección de una etiqueta",
},
},
},
drawnRegions: {
keys: {
Expand All @@ -523,7 +523,7 @@ export const spanish: IAppStrings = {
tips: {
quickLabeling: {
name: "Etiquetado rápido",
description: "Las teclas de acceso rápido de 1 a 0 y todas las letras se asignan a las primeras 36 etiquetas, después de seleccionar una o varias palabras de los elementos de texto resaltados, al presionar estas teclas de acceso rápido, puede etiquetar las palabras seleccionadas.",
description: "Las teclas de acceso rápido de 1 a 0 y todas las letras se asignan a las primeras 36 etiquetas, después de seleccionar una o varias palabras de los elementos de texto resaltados, al presionar estas teclas de acceso rápido, puede etiquetar las palabras seleccionadas.",
},
renameTag: {
name: "Rename Tag",
Expand Down Expand Up @@ -575,6 +575,10 @@ export const spanish: IAppStrings = {
message: `Se ha producido un error al eliminar el proyecto.
Validar el archivo de proyecto y el token de seguridad existen e inténtelo de nuevo`,
},
projectDeleteErrorSecurityTokenNotFound: {
title: 'No se encontró el token de seguridad al eliminar el proyecto',
message: "Token de seguridad no encontrado. El proyecto [$ {project.name}] se ha eliminado de la herramienta FoTT."
},
projectNotFound: {
title: "",
message: "",
Expand Down Expand Up @@ -672,6 +676,10 @@ export const spanish: IAppStrings = {
title: "Modelo no encontrado",
message: "Modelo \"${modelID}\" no encontrado. Por favor use otro modelo.",
},
connectionNotExistError: {
title: "La conexión no existe",
message: "La conexión no existe."
},
getOcrError: {
title: "No se puede cargar el archivo OCR",
message: "Error al cargar desde el archivo OCR. Verifique su conexión o configuración de red."
Expand Down
2 changes: 2 additions & 0 deletions src/common/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ export interface IAppStrings {
projectInvalidSecurityToken: IErrorMetadata,
projectUploadError: IErrorMetadata,
projectDeleteError: IErrorMetadata,
projectDeleteErrorSecurityTokenNotFound: IErrorMetadata,
projectNotFound: IErrorMetadata,
genericRenderError: IErrorMetadata,
securityTokenNotFound: IErrorMetadata,
Expand All @@ -571,6 +572,7 @@ export interface IAppStrings {
modelCountLimitExceeded: IErrorMetadata,
requestSendError: IErrorMetadata,
modelNotFound: IErrorMetadata,
connectionNotExistError: IErrorMetadata,
getOcrError: IErrorMetadata,
};
shareProject: {
Expand Down
11 changes: 10 additions & 1 deletion src/react/components/pages/homepage/homePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,16 @@ export default class HomePage extends React.Component<IHomePageProps, IHomePageS
}

private deleteProject = async (project: IProject) => {
await this.props.actions.deleteProject(project);
try {
await this.props.actions.deleteProject(project);
} catch (error) {
if(error instanceof AppError && error.errorCode === ErrorCode.SecurityTokenNotFound){
toast.error(error.message, {autoClose:false});
}
else{
throw error;
}
}
}

private onProjectFileUpload = async (e, project) => {
Expand Down
4 changes: 2 additions & 2 deletions src/redux/actions/projectActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ export function deleteProject(project: IProject)
.find((securityToken) => securityToken.name === project.securityToken);

if (!projectToken) {
throw new AppError(ErrorCode.SecurityTokenNotFound, "Security Token Not Found");
dispatch(deleteProjectAction(project));
throw new AppError(ErrorCode.SecurityTokenNotFound, interpolate(strings.errors.projectDeleteErrorSecurityTokenNotFound.message, {project}));
}

const decryptedProject = await projectService.load(project, projectToken);

await projectService.delete(decryptedProject);
dispatch(deleteProjectAction(decryptedProject));
};
Expand Down

0 comments on commit 730e196

Please sign in to comment.