Skip to content

Commit

Permalink
Merge pull request #213 from uc-cdis/fix/name-token
Browse files Browse the repository at this point in the history
fix(label): change label and key
  • Loading branch information
philloooo authored Jan 26, 2018
2 parents c96ce86 + 4fd8d46 commit 56f13db
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
14 changes: 7 additions & 7 deletions src/Popup/SavePopup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const ButtonGroup = styled.div`
`;

export const saveToFile = (savingStr, filename) => {
const blob = new Blob([savingStr], { type: 'text/json;charset=utf-8' });
const blob = new Blob([savingStr], { type: 'text/json' });
FileSaver.saveAs(blob, filename);
};

Expand All @@ -35,13 +35,13 @@ const SavePopup = ({ message, display, savingStr, error, onClose, filename }) =>
{
display &&
<pre>
<b>Token id:</b><br />
<b>Key id:</b><br />
<code>
{display.token_id} <br />
{display.key_id} <br />
</code>
<b>Refresh token:</b><br />
<b>API key:</b><br />
<code>
{display.refresh_token}
{display.api_key}
</code>
</pre>
}
Expand All @@ -68,8 +68,8 @@ const SavePopup = ({ message, display, savingStr, error, onClose, filename }) =>

SavePopup.propTypes = {
display: PropTypes.shape({
token_id: PropTypes.string.isRequired,
refresh_token: PropTypes.string.isRequired,
key_id: PropTypes.string.isRequired,
api_key: PropTypes.string.isRequired,
}),
message: PropTypes.string,
savingStr: PropTypes.string,
Expand Down
8 changes: 4 additions & 4 deletions src/UserProfile/ReduxUserProfile.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const mockStore = configureMockStore(middleware);
describe('the userProfile component', () => {
it('can create, fetch, and list user access keys', () => {
const expectedData = {
token_id: 'f8733984-8164-4689-9c25-56707962d7e0',
refresh_token: {
key_id: 'f8733984-8164-4689-9c25-56707962d7e0',
api_key: {
sub: '1234567',
iss: 'dcfauth:56fc3842ccf2c1c7ec5c5d14',
iat: 1459458458,
Expand Down Expand Up @@ -89,8 +89,8 @@ describe('the userProfile component', () => {

it('updates the redux store', () => {
const expectedData = {
token_id: 'f8733984-8164-4689-9c25-56707962d7e0',
refresh_token: {
key_id: 'f8733984-8164-4689-9c25-56707962d7e0',
api_key: {
sub: '1234567',
iss: 'dcfauth:56fc3842ccf2c1c7ec5c5d14',
iat: 1459458458,
Expand Down
24 changes: 12 additions & 12 deletions src/UserProfile/UserProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import { button } from '../theme';
import { credentialCdisPath } from '../localconf';

const NO_ACCESS_MSG = 'You have no access to storage service. Please contact an admin to get it!';
const NO_ACCESS_KEY = 'You don\'t have any access key. Please create one!';
const NO_API_KEY = 'You don\'t have any API key. Please create one!';
const CONFIRM_DELETE_MSG = 'Are you sure you want to make this key inactive?';
const SECRET_KEY_MSG = 'This secret key is only displayed this time. Please save it!';
const DELETE_BTN = 'Delete';
const CREATE_ACCESS_KEY_BTN = 'Create access key';
const ACCESS_KEY_COLUMN = 'Access key(s)';
const CREATE_API_KEY_BTN = 'Create API key';
const API_KEY_COLUMN = 'API key(s)';
const EXPIRES_COLUMN = 'Expires';
const PROJECT_COLUMN = 'Project(s)';
const RIGHT_COLUMN = 'Right(s)';
const LIST_PROJECT_MSG = 'You have access to the following project(s)';
const LIST_ACCESS_KEY_MSG = 'You have the following access key(s)';
const LIST_API_KEY_MSG = 'You have the following API key(s)';


export const actionButton = css`
Expand Down Expand Up @@ -66,7 +66,7 @@ export const Header = styled.li`
font-weight: bold;
`;

export const AccessKeyHeader = styled(Header)`
export const APIKeyHeader = styled(Header)`
width: 40%;
`;

Expand Down Expand Up @@ -115,7 +115,7 @@ export const RightCell = styled(Cell)`
width: 70%;
`;

export const AccessKeyCell = styled(Cell)`
export const APIKeyCell = styled(Cell)`
width: 40%;
`;

Expand All @@ -140,7 +140,7 @@ const KeyPairsEntity = ({ keypairsApi, value, onUpdatePopup, onRequestDeleteKey
return (
<li>
<Bullet>
<AccessKeyCell>{value.jti}</AccessKeyCell>
<APIKeyCell>{value.jti}</APIKeyCell>
<ExpireCell>{TimestampToDateTime(value.exp)}</ExpireCell>
<ActionCell>
<DeleteButton onClick={onDelete}>
Expand Down Expand Up @@ -169,7 +169,7 @@ const KeyPairsEntities = ({ values, keypairsApi, onUpdatePopup, onRequestDeleteK
<ul>
{values.length > 0 &&
<div>
<AccessKeyHeader>{ACCESS_KEY_COLUMN}</AccessKeyHeader>
<APIKeyHeader>{API_KEY_COLUMN}</APIKeyHeader>
<ExpiresHeader>{EXPIRES_COLUMN}</ExpiresHeader>
</div>
}
Expand Down Expand Up @@ -239,22 +239,22 @@ const UserProfile = ({ user, userProfile, popups, submission, onCreateKey,
onUpdatePopup({ saveTokenPopup: false });
onClearCreationSession();
}}
filename={'accessKeys.json'}
filename={'credentials.json'}
/>
}
<RequestButton onClick={onCreate}>
{CREATE_ACCESS_KEY_BTN}
{CREATE_API_KEY_BTN}
</RequestButton>
{
userProfile.jtis.length === 0 &&
<div>
{NO_ACCESS_KEY}
{NO_API_KEY}
</div>
}
{
userProfile.jtis.length > 0 &&
<h5>
{LIST_ACCESS_KEY_MSG}
{LIST_API_KEY_MSG}
</h5>
}
{
Expand Down
4 changes: 2 additions & 2 deletions src/UserProfile/UserProfile.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { mount } from 'enzyme';
import { StaticRouter } from 'react-router-dom';

import UserProfile, { AccessKeyCell, DeleteButton, RequestButton } from './UserProfile';
import UserProfile, { APIKeyCell, DeleteButton, RequestButton } from './UserProfile';

describe('the UserProfile component', () => {
const testProps = {
Expand Down Expand Up @@ -41,7 +41,7 @@ describe('the UserProfile component', () => {
/>
</StaticRouter>,
);
expect($vdom.find(AccessKeyCell)).toHaveLength(testProps.userProfile.jtis.length);
expect($vdom.find(APIKeyCell)).toHaveLength(testProps.userProfile.jtis.length);
});

it('triggers create-key events', (done) => {
Expand Down

0 comments on commit 56f13db

Please sign in to comment.