Show a message on tokens list route when no token was created yet
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		@@ -10,6 +10,7 @@ import {
 | 
			
		||||
  TableContainer,
 | 
			
		||||
  TableHead,
 | 
			
		||||
  TableRow,
 | 
			
		||||
  Typography,
 | 
			
		||||
} from "@mui/material";
 | 
			
		||||
import React from "react";
 | 
			
		||||
import { useNavigate } from "react-router-dom";
 | 
			
		||||
@@ -58,70 +59,78 @@ export function TokensListRouteInner(p: {
 | 
			
		||||
        </RouterLink>
 | 
			
		||||
      }
 | 
			
		||||
    >
 | 
			
		||||
      <TableContainer component={Paper}>
 | 
			
		||||
        <Table>
 | 
			
		||||
          <TableHead>
 | 
			
		||||
            <TableRow>
 | 
			
		||||
              <TableCell>Name</TableCell>
 | 
			
		||||
              <TableCell>Description</TableCell>
 | 
			
		||||
              <TableCell>Created</TableCell>
 | 
			
		||||
              <TableCell>Updated</TableCell>
 | 
			
		||||
              <TableCell>Last used</TableCell>
 | 
			
		||||
              <TableCell>IP restriction</TableCell>
 | 
			
		||||
              <TableCell>Max inactivity</TableCell>
 | 
			
		||||
              <TableCell>Rights</TableCell>
 | 
			
		||||
              <TableCell>Actions</TableCell>
 | 
			
		||||
            </TableRow>
 | 
			
		||||
          </TableHead>
 | 
			
		||||
          <TableBody>
 | 
			
		||||
            {p.list.map((t) => {
 | 
			
		||||
              return (
 | 
			
		||||
                <TableRow
 | 
			
		||||
                  key={t.id}
 | 
			
		||||
                  hover
 | 
			
		||||
                  onDoubleClick={() => navigate(APITokenURL(t))}
 | 
			
		||||
                  style={{ backgroundColor: ExpiredAPIToken(t) ? "red" : "" }}
 | 
			
		||||
                >
 | 
			
		||||
                  <TableCell>
 | 
			
		||||
                    {t.name} {ExpiredAPIToken(t) && <i>(Expired)</i>}
 | 
			
		||||
                  </TableCell>
 | 
			
		||||
                  <TableCell>{t.description}</TableCell>
 | 
			
		||||
                  <TableCell>
 | 
			
		||||
                    <TimeWidget time={t.created} />
 | 
			
		||||
                  </TableCell>
 | 
			
		||||
                  <TableCell>
 | 
			
		||||
                    <TimeWidget time={t.updated} />
 | 
			
		||||
                  </TableCell>
 | 
			
		||||
                  <TableCell>
 | 
			
		||||
                    <TimeWidget time={t.last_used} />
 | 
			
		||||
                  </TableCell>
 | 
			
		||||
                  <TableCell>{t.ip_restriction}</TableCell>
 | 
			
		||||
                  <TableCell>
 | 
			
		||||
                    {t.max_inactivity && timeDiff(0, t.max_inactivity)}
 | 
			
		||||
                  </TableCell>
 | 
			
		||||
                  <TableCell>
 | 
			
		||||
                    {t.rights.map((r, n) => {
 | 
			
		||||
                      return (
 | 
			
		||||
                        <div key={n}>
 | 
			
		||||
                          {r.verb} {r.path}
 | 
			
		||||
                        </div>
 | 
			
		||||
                      );
 | 
			
		||||
                    })}
 | 
			
		||||
                  </TableCell>
 | 
			
		||||
      {p.list.length > 0 && (
 | 
			
		||||
        <TableContainer component={Paper}>
 | 
			
		||||
          <Table>
 | 
			
		||||
            <TableHead>
 | 
			
		||||
              <TableRow>
 | 
			
		||||
                <TableCell>Name</TableCell>
 | 
			
		||||
                <TableCell>Description</TableCell>
 | 
			
		||||
                <TableCell>Created</TableCell>
 | 
			
		||||
                <TableCell>Updated</TableCell>
 | 
			
		||||
                <TableCell>Last used</TableCell>
 | 
			
		||||
                <TableCell>IP restriction</TableCell>
 | 
			
		||||
                <TableCell>Max inactivity</TableCell>
 | 
			
		||||
                <TableCell>Rights</TableCell>
 | 
			
		||||
                <TableCell>Actions</TableCell>
 | 
			
		||||
              </TableRow>
 | 
			
		||||
            </TableHead>
 | 
			
		||||
            <TableBody>
 | 
			
		||||
              {p.list.map((t) => {
 | 
			
		||||
                return (
 | 
			
		||||
                  <TableRow
 | 
			
		||||
                    key={t.id}
 | 
			
		||||
                    hover
 | 
			
		||||
                    onDoubleClick={() => navigate(APITokenURL(t))}
 | 
			
		||||
                    style={{ backgroundColor: ExpiredAPIToken(t) ? "red" : "" }}
 | 
			
		||||
                  >
 | 
			
		||||
                    <TableCell>
 | 
			
		||||
                      {t.name} {ExpiredAPIToken(t) && <i>(Expired)</i>}
 | 
			
		||||
                    </TableCell>
 | 
			
		||||
                    <TableCell>{t.description}</TableCell>
 | 
			
		||||
                    <TableCell>
 | 
			
		||||
                      <TimeWidget time={t.created} />
 | 
			
		||||
                    </TableCell>
 | 
			
		||||
                    <TableCell>
 | 
			
		||||
                      <TimeWidget time={t.updated} />
 | 
			
		||||
                    </TableCell>
 | 
			
		||||
                    <TableCell>
 | 
			
		||||
                      <TimeWidget time={t.last_used} />
 | 
			
		||||
                    </TableCell>
 | 
			
		||||
                    <TableCell>{t.ip_restriction}</TableCell>
 | 
			
		||||
                    <TableCell>
 | 
			
		||||
                      {t.max_inactivity && timeDiff(0, t.max_inactivity)}
 | 
			
		||||
                    </TableCell>
 | 
			
		||||
                    <TableCell>
 | 
			
		||||
                      {t.rights.map((r, n) => {
 | 
			
		||||
                        return (
 | 
			
		||||
                          <div key={n}>
 | 
			
		||||
                            {r.verb} {r.path}
 | 
			
		||||
                          </div>
 | 
			
		||||
                        );
 | 
			
		||||
                      })}
 | 
			
		||||
                    </TableCell>
 | 
			
		||||
 | 
			
		||||
                  <TableCell>
 | 
			
		||||
                    <RouterLink to={APITokenURL(t)}>
 | 
			
		||||
                      <IconButton>
 | 
			
		||||
                        <VisibilityIcon />
 | 
			
		||||
                      </IconButton>
 | 
			
		||||
                    </RouterLink>
 | 
			
		||||
                  </TableCell>
 | 
			
		||||
                </TableRow>
 | 
			
		||||
              );
 | 
			
		||||
            })}
 | 
			
		||||
          </TableBody>
 | 
			
		||||
        </Table>
 | 
			
		||||
      </TableContainer>
 | 
			
		||||
                    <TableCell>
 | 
			
		||||
                      <RouterLink to={APITokenURL(t)}>
 | 
			
		||||
                        <IconButton>
 | 
			
		||||
                          <VisibilityIcon />
 | 
			
		||||
                        </IconButton>
 | 
			
		||||
                      </RouterLink>
 | 
			
		||||
                    </TableCell>
 | 
			
		||||
                  </TableRow>
 | 
			
		||||
                );
 | 
			
		||||
              })}
 | 
			
		||||
            </TableBody>
 | 
			
		||||
          </Table>
 | 
			
		||||
        </TableContainer>
 | 
			
		||||
      )}
 | 
			
		||||
 | 
			
		||||
      {p.list.length === 0 && (
 | 
			
		||||
        <Typography style={{ textAlign: "center" }}>
 | 
			
		||||
          No API token created yet.
 | 
			
		||||
        </Typography>
 | 
			
		||||
      )}
 | 
			
		||||
    </VirtWebRouteContainer>
 | 
			
		||||
  );
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user