Skip to content

Commit

Permalink
Fixes #332
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Nov 26, 2024
1 parent 695bd84 commit 0ebb039
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
1 change: 1 addition & 0 deletions client/src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ const en = {
secretValue: "One-way hashed token",
secretTooltip: "The value to use in the X-API-TOKEN header",
description: "Description",
superUserToken: "Super User token",
descriptionPlaceHolder: "Description for this API token",
descriptionTooltip: "A description explaining the use of this API token",
deleteFlash: "API token has been deleted",
Expand Down
11 changes: 9 additions & 2 deletions client/src/tabs/Tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {useAppStore} from "../stores/AppStore";
import React, {useCallback, useEffect, useState} from "react";
import {Entities} from "../components/Entities";
import I18n from "../locale/I18n";
import {Button, ButtonType, Loader} from "@surfnet/sds";
import {Button, ButtonType, Checkbox, Loader} from "@surfnet/sds";
import {useNavigate} from "react-router-dom";
import {apiTokens, createToken, deleteToken, generateToken} from "../api";
import {dateFromEpoch} from "../utils/Date";
Expand Down Expand Up @@ -140,9 +140,16 @@ export const Tokens = () => {
},
{
key: "description",
class: `description ${user.superUser ? "small" : ""} `,
header: I18n.t("tokens.description"),
mapper: token => <span className={"cut-of-lines"}>{token.description}</span>
},
user.superUser ?
{
key: "superUserToken",
header: I18n.t("tokens.superUserToken"),
mapper: token => <div className="container"><Checkbox value={token.superUserToken} name={""} onChange={() => true} readOnly={true}/></div>
} : null,
{
key: "created_at",
header: I18n.t("tokens.createdAt"),
Expand All @@ -157,7 +164,7 @@ export const Tokens = () => {
<TrashIcon/>
</span>
},
]
].filter(column => column !== null)

if (loading) {
return <Loader/>
Expand Down
27 changes: 25 additions & 2 deletions client/src/tabs/Tokens.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@ div.mod-tokens {
thead {
th {
&.secret, &.hashed_token {
width: 30%;
width: 20%;
}

&.description {
width: 40%;
width: 50%;

&.small {
width: 25%;
}
}

&.superUserToken {
width: 25%;
text-align: center;
}

&.created_at {
Expand All @@ -24,6 +33,20 @@ div.mod-tokens {

}
}

tbody {
td.superUserToken {
text-align: center;
.container {
display: flex;
.sds--checkbox-container {
margin: auto;
}
}
}


}
}

.page.new-token {
Expand Down
2 changes: 1 addition & 1 deletion server/src/main/java/access/api/APITokenController.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public APITokenController(APITokenRepository apiTokenRepository) {
public ResponseEntity<List<APIToken>> apiTokensByInstitution(@Parameter(hidden = true) User user) {
LOG.debug("/tokens");
UserPermissions.assertInstitutionAdmin(user);
List<APIToken> apiTokens = user.isSuperUser() ? apiTokenRepository.findBySuperUserTokenTrue() : apiTokenRepository.findByOrganizationGUID(user.getOrganizationGUID());
List<APIToken> apiTokens = user.isSuperUser() ? apiTokenRepository.findAll() : apiTokenRepository.findByOrganizationGUID(user.getOrganizationGUID());
return ResponseEntity.ok(apiTokens);
}

Expand Down

0 comments on commit 0ebb039

Please sign in to comment.