gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant-backoffice] branch master updated (bce0789 -> 9952a82)


From: gnunet
Subject: [taler-merchant-backoffice] branch master updated (bce0789 -> 9952a82)
Date: Tue, 07 Dec 2021 15:58:29 +0100

This is an automated email from the git hooks/post-receive script.

sebasjm pushed a change to branch master
in repository merchant-backoffice.

    from bce0789  Hello World euFin bank.
     new 5260dcf  -formatted with prettier
     new 19767d7  login input as password
     new 955b03a  feat #7034
     new 5a48bd0  -formatted with prettier
     new 9952a82  do not show hours if itcannot be modified

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 contrib/split-formatting-vs-content-in-commit.sh   |   3 +
 .../src/components/exception/login.tsx             | 155 +++++++++++-------
 .../src/components/form/InputDate.tsx              | 175 ++++++++++++++-------
 3 files changed, 217 insertions(+), 116 deletions(-)
 mode change 100644 => 100755 contrib/split-formatting-vs-content-in-commit.sh

diff --git a/contrib/split-formatting-vs-content-in-commit.sh 
b/contrib/split-formatting-vs-content-in-commit.sh
old mode 100644
new mode 100755
index 74d973e..af9c833
--- a/contrib/split-formatting-vs-content-in-commit.sh
+++ b/contrib/split-formatting-vs-content-in-commit.sh
@@ -1,3 +1,6 @@
+#!/bin/bash
+# This Makefile has been placed in the public domain.
+
 FILES=$(git status --short --untracked-files=no --porcelain | colrm 1 3)
 git stash
 pnpx prettier $FILES -w
diff --git a/packages/merchant-backoffice/src/components/exception/login.tsx 
b/packages/merchant-backoffice/src/components/exception/login.tsx
index fca81ae..498d994 100644
--- a/packages/merchant-backoffice/src/components/exception/login.tsx
+++ b/packages/merchant-backoffice/src/components/exception/login.tsx
@@ -15,9 +15,9 @@
  */
 
 /**
-*
-* @author Sebastian Javier Marchano (sebasjm)
-*/
+ *
+ * @author Sebastian Javier Marchano (sebasjm)
+ */
 
 import { h, VNode } from "preact";
 import { useState } from "preact/hooks";
@@ -32,69 +32,112 @@ interface Props {
 }
 
 function getTokenValuePart(t?: string): string | undefined {
-  if (!t) return t
+  if (!t) return t;
   const match = /secret-token:(.*)/.exec(t);
   if (!match || !match[1]) return undefined;
-  return match[1]
+  return match[1];
 }
 
+function normalizeToken(r: string | undefined): string | undefined {
+  return r ? `secret-token:${encodeURIComponent(r)}` : undefined;
+}
 
 export function LoginModal({ onConfirm, withMessage }: Props): VNode {
-  const { url: backendUrl, token: baseToken } = useBackendContext()
-  const { admin, token: instanceToken } = useInstanceContext()
-  const currentToken = getTokenValuePart(!admin ? baseToken : instanceToken || 
'')
-  const [token, setToken] = useState(currentToken)
-  
-  const [url, setURL] = useState(backendUrl)
-  const i18n = useTranslator()
+  const { url: backendUrl, token: baseToken } = useBackendContext();
+  const { admin, token: instanceToken } = useInstanceContext();
+  const currentToken = getTokenValuePart(
+    !admin ? baseToken : instanceToken || ""
+  );
+  const [token, setToken] = useState(currentToken);
 
-  return <div class="columns is-centered">
-    <div class="column is-two-thirds " >
-      <div class="modal-card" style={{ width: '100%', margin: 0 }}>
-        <header class="modal-card-head" style={{ border: '1px solid', 
borderBottom: 0 }}>
-          <p class="modal-card-title">{i18n`Login required`}</p>
-        </header>
-        <section class="modal-card-body" style={{ border: '1px solid', 
borderTop: 0, borderBottom: 0 }}>
-          <Translate>Please enter your access token.</Translate>
-          <div class="field is-horizontal">
-            <div class="field-label is-normal">
-              <label class="label">URL</label>
-            </div>
-            <div class="field-body">
-              <div class="field">
-                <p class="control is-expanded">
-                  <input class="input" type="text" placeholder="set new url" 
name="id"
-                    value={url}
-                    onKeyPress={e => e.keyCode === 13 ? onConfirm(url, token ? 
`secret-token:${token}` : undefined) : null}
-                    onInput={(e): void => setURL(e?.currentTarget.value)}
-                  />
-                </p>
+  const [url, setURL] = useState(backendUrl);
+  const i18n = useTranslator();
+
+  return (
+    <div class="columns is-centered">
+      <div class="column is-two-thirds ">
+        <div class="modal-card" style={{ width: "100%", margin: 0 }}>
+          <header
+            class="modal-card-head"
+            style={{ border: "1px solid", borderBottom: 0 }}
+          >
+            <p class="modal-card-title">{i18n`Login required`}</p>
+          </header>
+          <section
+            class="modal-card-body"
+            style={{ border: "1px solid", borderTop: 0, borderBottom: 0 }}
+          >
+            <Translate>Please enter your access token.</Translate>
+            <div class="field is-horizontal">
+              <div class="field-label is-normal">
+                <label class="label">URL</label>
+              </div>
+              <div class="field-body">
+                <div class="field">
+                  <p class="control is-expanded">
+                    <input
+                      class="input"
+                      type="text"
+                      placeholder="set new url"
+                      name="id"
+                      value={url}
+                      onKeyPress={(e) =>
+                        e.keyCode === 13
+                          ? onConfirm(url, normalizeToken(token))
+                          : null
+                      }
+                      onInput={(e): void => setURL(e?.currentTarget.value)}
+                    />
+                  </p>
+                </div>
               </div>
             </div>
-          </div>
-          <div class="field is-horizontal">
-            <div class="field-label is-normal">
-              <label class="label"><Translate>Access Token</Translate></label>
-            </div>
-            <div class="field-body">
-              <div class="field">
-                <p class="control is-expanded">
-                  <input class="input" type="text" placeholder={"set new 
access token"} name="token"
-                    onKeyPress={e => e.keyCode === 13 ? onConfirm(url, token ? 
`secret-token:${token}` : undefined) : null}
-                    value={token} 
-                    onInput={(e): void => setToken(e?.currentTarget.value)}
-                  />
-                </p>
+            <div class="field is-horizontal">
+              <div class="field-label is-normal">
+                <label class="label">
+                  <Translate>Access Token</Translate>
+                </label>
+              </div>
+              <div class="field-body">
+                <div class="field">
+                  <p class="control is-expanded">
+                    <input
+                      class="input"
+                      type="password"
+                      placeholder={"set new access token"}
+                      name="token"
+                      onKeyPress={(e) =>
+                        e.keyCode === 13
+                          ? onConfirm(url, normalizeToken(token))
+                          : null
+                      }
+                      value={token}
+                      onInput={(e): void => setToken(e?.currentTarget.value)}
+                    />
+                  </p>
+                </div>
               </div>
             </div>
-          </div>
-        </section>
-        <footer class="modal-card-foot " style={{ justifyContent: 'flex-end', 
border: '1px solid', borderTop: 0 }} >
-          <button class="button is-info" onClick={(): void => {
-            onConfirm(url, token ? `secret-token:${token}` : undefined);
-          }} ><Translate>Confirm</Translate></button>
-        </footer>
+          </section>
+          <footer
+            class="modal-card-foot "
+            style={{
+              justifyContent: "flex-end",
+              border: "1px solid",
+              borderTop: 0,
+            }}
+          >
+            <button
+              class="button is-info"
+              onClick={(): void => {
+                onConfirm(url, normalizeToken(token));
+              }}
+            >
+              <Translate>Confirm</Translate>
+            </button>
+          </footer>
+        </div>
       </div>
     </div>
-  </div>
-}
\ No newline at end of file
+  );
+}
diff --git a/packages/merchant-backoffice/src/components/form/InputDate.tsx 
b/packages/merchant-backoffice/src/components/form/InputDate.tsx
index 75f955f..c4517c2 100644
--- a/packages/merchant-backoffice/src/components/form/InputDate.tsx
+++ b/packages/merchant-backoffice/src/components/form/InputDate.tsx
@@ -15,9 +15,9 @@
  */
 
 /**
-*
-* @author Sebastian Javier Marchano (sebasjm)
-*/
+ *
+ * @author Sebastian Javier Marchano (sebasjm)
+ */
 import { format } from "date-fns";
 import { h, VNode } from "preact";
 import { useState } from "preact/hooks";
@@ -32,73 +32,128 @@ export interface Props<T> extends InputProps<T> {
   withTimestampSupport?: boolean;
 }
 
-export function InputDate<T>({ name, readonly, label, placeholder, help, 
tooltip, expand, withTimestampSupport }: Props<keyof T>): VNode {
-  const [opened, setOpened] = useState(false)
-  const i18n = useTranslator()
+export function InputDate<T>({
+  name,
+  readonly,
+  label,
+  placeholder,
+  help,
+  tooltip,
+  expand,
+  withTimestampSupport,
+}: Props<keyof T>): VNode {
+  const [opened, setOpened] = useState(false);
+  const i18n = useTranslator();
 
   const { error, required, value, onChange } = useField<T>(name);
 
-  let strValue = ''
+  let strValue = "";
   if (!value) {
-    strValue = withTimestampSupport ? 'unknown' : ''
+    strValue = withTimestampSupport ? "unknown" : "";
   } else if (value instanceof Date) {
-    strValue = format(value, 'yyyy/MM/dd HH:mm:ss')
+    strValue = format(value, "yyyy/MM/dd");
   } else if (value.t_ms) {
-    strValue = value.t_ms === 'never' ?
-      (withTimestampSupport ? 'never' : '') :
-      format(new Date(value.t_ms), 'yyyy/MM/dd HH:mm:ss')
+    strValue =
+      value.t_ms === "never"
+        ? withTimestampSupport
+          ? "never"
+          : ""
+        : format(new Date(value.t_ms), "yyyy/MM/dd");
   }
 
-  return <div class="field is-horizontal">
-    <div class="field-label is-normal">
-      <label class="label">
-        {label}
-        {tooltip && <span class="icon has-tooltip-right" 
data-tooltip={tooltip}>
-          <i class="mdi mdi-information" />
-        </span>}
-      </label>
-    </div>
-    <div class="field-body is-flex-grow-3">
-      <div class="field">
-        <div class="field has-addons">
-          <p class={expand ? "control is-expanded has-icons-right" : "control 
has-icons-right"}>
-            <input class="input" type="text"
-              readonly value={strValue}
-              placeholder={placeholder}
-              onClick={() => { if (!readonly) setOpened(true) }}
-            />
-          { required && <span class="icon has-text-danger is-right">
-              <i class="mdi mdi-alert" />
-            </span> }
-            {help}
-          </p>
-          <div class="control" onClick={() => { if (!readonly) setOpened(true) 
}}>
-            <a class="button is-static" >
-              <span class="icon"><i class="mdi mdi-calendar" /></span>
-            </a>
+  return (
+    <div class="field is-horizontal">
+      <div class="field-label is-normal">
+        <label class="label">
+          {label}
+          {tooltip && (
+            <span class="icon has-tooltip-right" data-tooltip={tooltip}>
+              <i class="mdi mdi-information" />
+            </span>
+          )}
+        </label>
+      </div>
+      <div class="field-body is-flex-grow-3">
+        <div class="field">
+          <div class="field has-addons">
+            <p
+              class={
+                expand
+                  ? "control is-expanded has-icons-right"
+                  : "control has-icons-right"
+              }
+            >
+              <input
+                class="input"
+                type="text"
+                readonly
+                value={strValue}
+                placeholder={placeholder}
+                onClick={() => {
+                  if (!readonly) setOpened(true);
+                }}
+              />
+              {required && (
+                <span class="icon has-text-danger is-right">
+                  <i class="mdi mdi-alert" />
+                </span>
+              )}
+              {help}
+            </p>
+            <div
+              class="control"
+              onClick={() => {
+                if (!readonly) setOpened(true);
+              }}
+            >
+              <a class="button is-static">
+                <span class="icon">
+                  <i class="mdi mdi-calendar" />
+                </span>
+              </a>
+            </div>
           </div>
+          {error && <p class="help is-danger">{error}</p>}
         </div>
-        {error && <p class="help is-danger">{error}</p>}
-      </div>
 
-      {!readonly && <span data-tooltip={withTimestampSupport ? i18n`change 
value to unknown date` : i18n`change value to empty`}>
-        <button class="button is-info mr-3" onClick={() => onChange(undefined 
as any)} ><Translate>clear</Translate></button>
-      </span>}
-      {withTimestampSupport && <span data-tooltip={i18n`change value to 
never`}>
-        <button class="button is-info" onClick={() => onChange({ t_ms: 'never' 
} as any)}><Translate>never</Translate></button>
-      </span>}
+        {!readonly && (
+          <span
+            data-tooltip={
+              withTimestampSupport
+                ? i18n`change value to unknown date`
+                : i18n`change value to empty`
+            }
+          >
+            <button
+              class="button is-info mr-3"
+              onClick={() => onChange(undefined as any)}
+            >
+              <Translate>clear</Translate>
+            </button>
+          </span>
+        )}
+        {withTimestampSupport && (
+          <span data-tooltip={i18n`change value to never`}>
+            <button
+              class="button is-info"
+              onClick={() => onChange({ t_ms: "never" } as any)}
+            >
+              <Translate>never</Translate>
+            </button>
+          </span>
+        )}
+      </div>
+      <DatePicker
+        opened={opened}
+        closeFunction={() => setOpened(false)}
+        dateReceiver={(d) => {
+          if (withTimestampSupport) {
+            onChange({ t_ms: d.getTime() } as any);
+          } else {
+            onChange(d as any);
+          }
+        }}
+      />
     </div>
-    <DatePicker
-      opened={opened}
-      closeFunction={() => setOpened(false)}
-      dateReceiver={(d) => {
-        if (withTimestampSupport) {
-          onChange({ t_ms: d.getTime() } as any)
-        } else {
-          onChange(d as any)
-        }
-      }}
-    />
-  </div>;
+  );
 }
-

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]