mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-10 01:16:39 +02:00
feat: Adapt API keys to new endpoint (#259)
* 3.14.1 * more changs! * fix: cleanup UI to match API * fix
This commit is contained in:
parent
2c070bf88d
commit
b8b48b5726
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "unleash-frontend",
|
||||
"description": "unleash your features",
|
||||
"version": "3.14.0",
|
||||
"version": "3.14.1",
|
||||
"keywords": [
|
||||
"unleash",
|
||||
"feature toggle",
|
||||
|
@ -9,8 +9,7 @@ import ApiHowTo from './api-howto';
|
||||
|
||||
function ApiKeyList({ location, fetchApiKeys, removeKey, addKey, keys, hasPermission }) {
|
||||
const deleteKey = async key => {
|
||||
const shouldDelte = confirm('Are you sure?');
|
||||
if (shouldDelte) {
|
||||
if (confirm('Are you sure?')) {
|
||||
await removeKey(key);
|
||||
}
|
||||
};
|
||||
@ -44,14 +43,14 @@ function ApiKeyList({ location, fetchApiKeys, removeKey, addKey, keys, hasPermis
|
||||
</thead>
|
||||
<tbody>
|
||||
{keys.map(item => (
|
||||
<tr key={item.key}>
|
||||
<tr key={item.secret}>
|
||||
<td style={{ textAlign: 'left' }}>
|
||||
{formatFullDateTimeWithLocale(item.created, location.locale)}
|
||||
{formatFullDateTimeWithLocale(item.createdAt, location.locale)}
|
||||
</td>
|
||||
<td style={{ textAlign: 'left' }}>{item.username}</td>
|
||||
<td style={{ textAlign: 'left' }}>{item.priviliges[0]}</td>
|
||||
<td style={{ textAlign: 'left' }}>{item.type}</td>
|
||||
<td style={{ textAlign: 'left' }}>
|
||||
<Secret value={item.key} />
|
||||
<Secret value={item.secret} />
|
||||
</td>
|
||||
{hasPermission('ADMIN') ? (
|
||||
<td style={{ textAlign: 'right' }}>
|
||||
@ -59,7 +58,7 @@ function ApiKeyList({ location, fetchApiKeys, removeKey, addKey, keys, hasPermis
|
||||
href=""
|
||||
onClick={e => {
|
||||
e.preventDefault();
|
||||
deleteKey(item.key);
|
||||
deleteKey(item.secret);
|
||||
}}
|
||||
>
|
||||
<Icon name="delete" />
|
||||
@ -82,7 +81,7 @@ ApiKeyList.propTypes = {
|
||||
fetchApiKeys: PropTypes.func.isRequired,
|
||||
removeKey: PropTypes.func.isRequired,
|
||||
addKey: PropTypes.func.isRequired,
|
||||
keys: PropTypes.object.isRequired,
|
||||
keys: PropTypes.array.isRequired,
|
||||
hasPermission: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
|
@ -17,17 +17,17 @@ export function fetchApiKeys() {
|
||||
.then(value =>
|
||||
dispatch({
|
||||
type: RECIEVE_KEYS,
|
||||
keys: value,
|
||||
tokens: value.tokens,
|
||||
})
|
||||
)
|
||||
.catch(dispatchAndThrow(dispatch, ERROR_FETCH_KEYS));
|
||||
}
|
||||
|
||||
export function removeKey(key) {
|
||||
export function removeKey(secret) {
|
||||
return dispatch =>
|
||||
api
|
||||
.remove(key)
|
||||
.then(() => dispatch({ type: REMOVE_KEY, key }))
|
||||
.remove(secret)
|
||||
.then(() => dispatch({ type: REMOVE_KEY, secret }))
|
||||
.catch(dispatchAndThrow(dispatch, REMOVE_KEY));
|
||||
}
|
||||
|
||||
|
@ -4,11 +4,11 @@ import { RECIEVE_KEYS, ADD_KEY, REMOVE_KEY } from './actions';
|
||||
const store = (state = new List(), action) => {
|
||||
switch (action.type) {
|
||||
case RECIEVE_KEYS:
|
||||
return new List(action.keys);
|
||||
return new List(action.tokens);
|
||||
case ADD_KEY:
|
||||
return state.push(action.token);
|
||||
case REMOVE_KEY:
|
||||
return state.filter(v => v.key !== action.key);
|
||||
return state.filter(v => v.secret !== action.secret);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user