-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhancement(Edit namespace skeleton): Add edit namespace skeleton (#86)
- Loading branch information
1 parent
b684dcd
commit 18455fa
Showing
27 changed files
with
987 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module.exports = { | ||
createOldCatalogs: true, // Save the \_old files | ||
|
||
indentation: 4, // Indentation of the catalog files | ||
|
||
keepRemoved: false, // Keep keys from the catalog that are no longer in code | ||
|
||
lexers: { | ||
js: ["JsxLexer"], | ||
ts: ["JsxLexer"], | ||
jsx: ["JsxLexer"], | ||
tsx: ["JsxLexer"], | ||
|
||
default: ["JsxLexer"], | ||
}, | ||
|
||
locales: ["es"], | ||
|
||
output: "public/locales/$LOCALE/$NAMESPACE.json", | ||
|
||
input: ["src/**/*.{js,jsx,ts,tsx}"], | ||
|
||
sort: true, | ||
verbose: true, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"actions": { | ||
"cancel": "Cancelar", | ||
"delete": "Eliminar" | ||
}, | ||
"modal": { | ||
"confirm-delete": { | ||
"body": "¿Estas seguro de querer eliminar este(a) <1>{{type}}</1>? Esta acción eliminará <3>{{name}}</3> permanentemente.", | ||
"title": "Eliminar {{what}}" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import i18n from "i18next"; | ||
import { initReactI18next } from "react-i18next"; | ||
import Backend from "i18next-http-backend"; | ||
|
||
i18n | ||
.use(Backend) | ||
.use(initReactI18next) | ||
.init({ | ||
lng: "es", | ||
fallbackLng: "es", | ||
debug: false, | ||
|
||
interpolation: { | ||
escapeValue: false, | ||
}, | ||
|
||
returnEmptyString: false, | ||
}); | ||
|
||
export default i18n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/webapp/src/pages/namespaces/edit-namespace/companies/companies.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React from "react"; | ||
|
||
export const Companies: React.FC = () => { | ||
return <>Companies</>; | ||
}; |
1 change: 1 addition & 0 deletions
1
src/main/webapp/src/pages/namespaces/edit-namespace/companies/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Companies as default } from "./companies"; |
147 changes: 147 additions & 0 deletions
147
src/main/webapp/src/pages/namespaces/edit-namespace/edit-namespace.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
import React, { lazy, Suspense } from "react"; | ||
import { Route, Switch, useHistory, useParams } from "react-router-dom"; | ||
import { useTranslation, Trans } from "react-i18next"; | ||
import { ButtonVariant, PageSection } from "@patternfly/react-core"; | ||
import { | ||
useConfirmationContext, | ||
SimplePlaceholder, | ||
} from "@project-openubl/lib-ui"; | ||
|
||
import { useDispatch } from "react-redux"; | ||
import { alertActions } from "store/alert"; | ||
|
||
import { PageHeader } from "shared/components"; | ||
|
||
import { | ||
useDeleteNamespaceMutation, | ||
useNamespaceQuery, | ||
} from "queries/namespaces"; | ||
|
||
import { formatPath, Paths } from "Paths"; | ||
import { getAxiosErrorMessage } from "utils/modelUtils"; | ||
|
||
const Overview = lazy(() => import("./overview")); | ||
const Sunat = lazy(() => import("./sunat")); | ||
const Keys = lazy(() => import("./keys")); | ||
const Companies = lazy(() => import("./companies")); | ||
|
||
export interface INamespaceParams { | ||
namespaceId: string; | ||
} | ||
|
||
export const EditNamespace: React.FC = () => { | ||
const { t } = useTranslation(); | ||
|
||
const dispatch = useDispatch(); | ||
const history = useHistory(); | ||
|
||
const routeParams = useParams<INamespaceParams>(); | ||
const confirmationModal = useConfirmationContext(); | ||
|
||
const namespace = useNamespaceQuery(routeParams.namespaceId); | ||
const deleteNamespace = useDeleteNamespaceMutation(); | ||
|
||
const onDeleteNs = () => { | ||
if (!namespace.data) { | ||
console.log("Can not delete null"); | ||
return; | ||
} | ||
|
||
confirmationModal.open({ | ||
title: t("modal.confirm-delete.title", { | ||
what: "namespace", | ||
}), | ||
titleIconVariant: "warning", | ||
message: ( | ||
<Trans | ||
i18nKey="modal.confirm-delete.body" | ||
values={{ type: "namespace", name: namespace.data.name }} | ||
> | ||
¿Estas seguro de querer eliminar este(a) <b>type</b>? Esta acción | ||
eliminará <b>name</b> permanentemente. | ||
</Trans> | ||
), | ||
confirmBtnVariant: ButtonVariant.danger, | ||
confirmBtnLabel: t("actions.delete"), | ||
cancelBtnLabel: t("actions.cancel"), | ||
onConfirm: () => { | ||
confirmationModal.enableProcessing(); | ||
deleteNamespace | ||
.mutateAsync(namespace.data) | ||
.catch((error) => { | ||
dispatch( | ||
alertActions.addAlert( | ||
"danger", | ||
"Error", | ||
getAxiosErrorMessage(error) | ||
) | ||
); | ||
}) | ||
.finally(() => { | ||
confirmationModal.close(); | ||
history.push(Paths.namespaces); | ||
}); | ||
}, | ||
}); | ||
}; | ||
|
||
return ( | ||
<> | ||
<PageSection variant="light" type="breadcrumb"> | ||
<PageHeader | ||
title={namespace.data?.name || ""} | ||
breadcrumbs={[ | ||
{ | ||
title: "Namespaces", | ||
path: Paths.namespaces, | ||
}, | ||
{ | ||
title: "editar", | ||
path: "", | ||
}, | ||
]} | ||
menuActions={[{ label: "Eliminar", callback: onDeleteNs }]} | ||
navItems={[ | ||
{ | ||
title: "General", | ||
path: formatPath(Paths.namespaces_edit, { | ||
namespaceId: namespace.data?.id, | ||
}), | ||
}, | ||
{ | ||
title: "SUNAT", | ||
path: formatPath(Paths.namespaces_edit_sunat, { | ||
namespaceId: namespace.data?.id, | ||
}), | ||
}, | ||
{ | ||
title: "Certificados", | ||
path: formatPath(Paths.namespaces_edit_keys, { | ||
namespaceId: namespace.data?.id, | ||
}), | ||
}, | ||
{ | ||
title: "Empresas", | ||
path: formatPath(Paths.namespaces_edit_companies, { | ||
namespaceId: namespace.data?.id, | ||
}), | ||
}, | ||
]} | ||
/> | ||
</PageSection> | ||
<PageSection> | ||
<Suspense fallback={<SimplePlaceholder />}> | ||
<Switch> | ||
<Route path={Paths.namespaces_edit} component={Overview} exact /> | ||
<Route path={Paths.namespaces_edit_sunat} component={Sunat} /> | ||
<Route path={Paths.namespaces_edit_keys} component={Keys} /> | ||
<Route | ||
path={Paths.namespaces_edit_companies} | ||
component={Companies} | ||
/> | ||
</Switch> | ||
</Suspense> | ||
</PageSection> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { EditNamespace as default } from "./edit-namespace"; |
1 change: 1 addition & 0 deletions
1
src/main/webapp/src/pages/namespaces/edit-namespace/keys/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Keys as default } from "./keys"; |
5 changes: 5 additions & 0 deletions
5
src/main/webapp/src/pages/namespaces/edit-namespace/keys/keys.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React from "react"; | ||
|
||
export const Keys: React.FC = () => { | ||
return <>Keys</>; | ||
}; |
1 change: 1 addition & 0 deletions
1
src/main/webapp/src/pages/namespaces/edit-namespace/overview/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Overview as default } from "./overview"; |
5 changes: 5 additions & 0 deletions
5
src/main/webapp/src/pages/namespaces/edit-namespace/overview/overview.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React from "react"; | ||
|
||
export const Overview: React.FC = () => { | ||
return <>overview</>; | ||
}; |
1 change: 1 addition & 0 deletions
1
src/main/webapp/src/pages/namespaces/edit-namespace/sunat/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Sunat as default } from "./sunat"; |
5 changes: 5 additions & 0 deletions
5
src/main/webapp/src/pages/namespaces/edit-namespace/sunat/sunat.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React from "react"; | ||
|
||
export const Sunat: React.FC = () => { | ||
return <>Sunat</>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.