Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Evaluate translation only once per render
dominik-zeglenf840daa30381
diff --git a/saleor/static/dashboard-next/siteSettings/components/SiteSettingsKeyDialog/SiteSettingsKeyDialog.tsx b/saleor/static/dashboard-next/siteSettings/components/SiteSettingsKeyDialog/SiteSettingsKeyDialog.tsxindex ee56bbe649..6fa72e0b0a 100644--- a/saleor/static/dashboard-next/siteSettings/components/SiteSettingsKeyDialog/SiteSettingsKeyDialog.tsx+++ b/saleor/static/dashboard-next/siteSettings/components/SiteSettingsKeyDialog/SiteSettingsKeyDialog.tsx@@ -30,72 +30,73 @@ export interface SiteSettingsKeyDialogPropsconst SiteSettingsKeyDialog: React.StatelessComponent<SiteSettingsKeyDialogProps-> = ({ errors, initial, open, onClose, onSubmit }) => (- <Dialog maxWidth="xs" open={open}>- <Form initial={initial} onSubmit={onSubmit} errors={errors}>- {({ change, data, errors }) => (- <>- <DialogTitle>- {i18n.t("Add New Authorization Key", {- context: "modal title"- })}- </DialogTitle>- <DialogContent>- <SingleSelectField- choices={Object.keys(translatedAuthorizationKeyTypes()).map(- key => ({- label: translatedAuthorizationKeyTypes()[key],- value: key- })- )}- error={!!errors.keyType}- label={i18n.t("Authentication type", {- context: "input label"- })}- hint={errors.keyType}- name="type"- onChange={change}- value={data.type}- />- <FormSpacer />- <TextField- error={!!errors.key}- fullWidth- label={i18n.t("Key", {- context: "input label"- })}- helperText={errors.key}- name="key"- onChange={change}- value={data.key}- />- <FormSpacer />- <TextField- error={!!errors.password}- fullWidth- label={i18n.t("Password", {- context: "input label"+> = ({ errors, initial, open, onClose, onSubmit }) => {+ const keyTypes = translatedAuthorizationKeyTypes();+ return (+ <Dialog maxWidth="xs" open={open}>+ <Form initial={initial} onSubmit={onSubmit} errors={errors}>+ {({ change, data, errors }) => (+ <>+ <DialogTitle>+ {i18n.t("Add New Authorization Key", {+ context: "modal title"})}- helperText={errors.password}- name="password"- onChange={change}- value={data.password}- />- </DialogContent>- <DialogActions>- <Button onClick={onClose}>- {i18n.t("Cancel", { context: "button" })}- </Button>- <Button color="secondary" type="submit" variant="contained">- {i18n.t("Add authentication", {- context: "button"- })}- </Button>- </DialogActions>- </>- )}- </Form>- </Dialog>-);+ </DialogTitle>+ <DialogContent>+ <SingleSelectField+ choices={Object.keys(keyTypes).map(key => ({+ label: keyTypes[key],+ value: key+ }))}+ error={!!errors.keyType}+ label={i18n.t("Authentication type", {+ context: "input label"+ })}+ hint={errors.keyType}+ name="type"+ onChange={change}+ value={data.type}+ />+ <FormSpacer />+ <TextField+ error={!!errors.key}+ fullWidth+ label={i18n.t("Key", {+ context: "input label"+ })}+ helperText={errors.key}+ name="key"+ onChange={change}+ value={data.key}+ />+ <FormSpacer />+ <TextField+ error={!!errors.password}+ fullWidth+ label={i18n.t("Password", {+ context: "input label"+ })}+ helperText={errors.password}+ name="password"+ onChange={change}+ value={data.password}+ />+ </DialogContent>+ <DialogActions>+ <Button onClick={onClose}>+ {i18n.t("Cancel", { context: "button" })}+ </Button>+ <Button color="secondary" type="submit" variant="contained">+ {i18n.t("Add authentication", {+ context: "button"+ })}+ </Button>+ </DialogActions>+ </>+ )}+ </Form>+ </Dialog>+ );+};SiteSettingsKeyDialog.displayName = "SiteSettingsKeyDialog";export default SiteSettingsKeyDialog;diff --git a/saleor/static/dashboard-next/siteSettings/components/SiteSettingsKeys/SiteSettingsKeys.tsx b/saleor/static/dashboard-next/siteSettings/components/SiteSettingsKeys/SiteSettingsKeys.tsxindex 6bc4af271e..6fa2ddc7e4 100644--- a/saleor/static/dashboard-next/siteSettings/components/SiteSettingsKeys/SiteSettingsKeys.tsx+++ b/saleor/static/dashboard-next/siteSettings/components/SiteSettingsKeys/SiteSettingsKeys.tsx@@ -37,67 +37,71 @@ const decorate = withStyles(theme => ({}}));const SiteSettingsKeys = decorate<SiteSettingsKeysProps>(- ({ classes, disabled, keys, onAdd, onRemove }) => (- <Card>- <CardTitle- title={i18n.t("Authentication Keys", {- context: "card title"- })}- toolbar={- <Button- color="secondary"- disabled={disabled}- variant="flat"- onClick={onAdd}- >- {i18n.t("Add key", {- context: "button"- })}- </Button>- }- />- <Table>- <TableHead>- <TableRow>- <TableCell>- {i18n.t("Authentication Type", { context: "table header" })}- </TableCell>- <TableCell>{i18n.t("Key", { context: "table header" })}</TableCell>- <TableCell />- </TableRow>- </TableHead>- <TableBody>- {renderCollection(- keys,- key => (- <TableRow hover={!(disabled || !key)} key={maybe(() => key.name)}>- <TableCell>- {maybe(() => key.name) ? (- translatedAuthorizationKeyTypes()[key.name]- ) : (- <Skeleton />- )}- </TableCell>- <TableCell>- {maybe(() => key.key) ? key.key : <Skeleton />}- </TableCell>- <TableCell className={classes.iconCell}>- <IconButton onClick={() => onRemove(key.name)}>- <DeleteIcon color="secondary" />- </IconButton>- </TableCell>- </TableRow>- ),- () => (- <TableRow>- <TableCell colSpan={3}>{i18n.t("No keys")}</TableCell>- </TableRow>- )- )}- </TableBody>- </Table>- </Card>- )+ ({ classes, disabled, keys, onAdd, onRemove }) => {+ const keyTypes = translatedAuthorizationKeyTypes();+ return (+ <Card>+ <CardTitle+ title={i18n.t("Authentication Keys", {+ context: "card title"+ })}+ toolbar={+ <Button+ color="secondary"+ disabled={disabled}+ variant="flat"+ onClick={onAdd}+ >+ {i18n.t("Add key", {+ context: "button"+ })}+ </Button>+ }+ />+ <Table>+ <TableHead>+ <TableRow>+ <TableCell>+ {i18n.t("Authentication Type", { context: "table header" })}+ </TableCell>+ <TableCell>+ {i18n.t("Key", { context: "table header" })}+ </TableCell>+ <TableCell />+ </TableRow>+ </TableHead>+ <TableBody>+ {renderCollection(+ keys,+ key => (+ <TableRow+ hover={!(disabled || !key)}+ key={maybe(() => key.name)}+ >+ <TableCell>+ {maybe(() => key.name) ? keyTypes[key.name] : <Skeleton />}+ </TableCell>+ <TableCell>+ {maybe(() => key.key) ? key.key : <Skeleton />}+ </TableCell>+ <TableCell className={classes.iconCell}>+ <IconButton onClick={() => onRemove(key.name)}>+ <DeleteIcon color="secondary" />+ </IconButton>+ </TableCell>+ </TableRow>+ ),+ () => (+ <TableRow>+ <TableCell colSpan={3}>{i18n.t("No keys")}</TableCell>+ </TableRow>+ )+ )}+ </TableBody>+ </Table>+ </Card>+ );+ });SiteSettingsKeys.displayName = "SiteSettingsKeys";export default SiteSettingsKeys;