mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-12 13:48:35 +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",
|
"name": "unleash-frontend",
|
||||||
"description": "unleash your features",
|
"description": "unleash your features",
|
||||||
"version": "3.14.0",
|
"version": "3.14.1",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"unleash",
|
"unleash",
|
||||||
"feature toggle",
|
"feature toggle",
|
||||||
|
@ -9,8 +9,7 @@ import ApiHowTo from './api-howto';
|
|||||||
|
|
||||||
function ApiKeyList({ location, fetchApiKeys, removeKey, addKey, keys, hasPermission }) {
|
function ApiKeyList({ location, fetchApiKeys, removeKey, addKey, keys, hasPermission }) {
|
||||||
const deleteKey = async key => {
|
const deleteKey = async key => {
|
||||||
const shouldDelte = confirm('Are you sure?');
|
if (confirm('Are you sure?')) {
|
||||||
if (shouldDelte) {
|
|
||||||
await removeKey(key);
|
await removeKey(key);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -44,14 +43,14 @@ function ApiKeyList({ location, fetchApiKeys, removeKey, addKey, keys, hasPermis
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{keys.map(item => (
|
{keys.map(item => (
|
||||||
<tr key={item.key}>
|
<tr key={item.secret}>
|
||||||
<td style={{ textAlign: 'left' }}>
|
<td style={{ textAlign: 'left' }}>
|
||||||
{formatFullDateTimeWithLocale(item.created, location.locale)}
|
{formatFullDateTimeWithLocale(item.createdAt, location.locale)}
|
||||||
</td>
|
</td>
|
||||||
<td style={{ textAlign: 'left' }}>{item.username}</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' }}>
|
<td style={{ textAlign: 'left' }}>
|
||||||
<Secret value={item.key} />
|
<Secret value={item.secret} />
|
||||||
</td>
|
</td>
|
||||||
{hasPermission('ADMIN') ? (
|
{hasPermission('ADMIN') ? (
|
||||||
<td style={{ textAlign: 'right' }}>
|
<td style={{ textAlign: 'right' }}>
|
||||||
@ -59,7 +58,7 @@ function ApiKeyList({ location, fetchApiKeys, removeKey, addKey, keys, hasPermis
|
|||||||
href=""
|
href=""
|
||||||
onClick={e => {
|
onClick={e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
deleteKey(item.key);
|
deleteKey(item.secret);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon name="delete" />
|
<Icon name="delete" />
|
||||||
@ -82,7 +81,7 @@ ApiKeyList.propTypes = {
|
|||||||
fetchApiKeys: PropTypes.func.isRequired,
|
fetchApiKeys: PropTypes.func.isRequired,
|
||||||
removeKey: PropTypes.func.isRequired,
|
removeKey: PropTypes.func.isRequired,
|
||||||
addKey: PropTypes.func.isRequired,
|
addKey: PropTypes.func.isRequired,
|
||||||
keys: PropTypes.object.isRequired,
|
keys: PropTypes.array.isRequired,
|
||||||
hasPermission: PropTypes.func.isRequired,
|
hasPermission: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,17 +17,17 @@ export function fetchApiKeys() {
|
|||||||
.then(value =>
|
.then(value =>
|
||||||
dispatch({
|
dispatch({
|
||||||
type: RECIEVE_KEYS,
|
type: RECIEVE_KEYS,
|
||||||
keys: value,
|
tokens: value.tokens,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.catch(dispatchAndThrow(dispatch, ERROR_FETCH_KEYS));
|
.catch(dispatchAndThrow(dispatch, ERROR_FETCH_KEYS));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeKey(key) {
|
export function removeKey(secret) {
|
||||||
return dispatch =>
|
return dispatch =>
|
||||||
api
|
api
|
||||||
.remove(key)
|
.remove(secret)
|
||||||
.then(() => dispatch({ type: REMOVE_KEY, key }))
|
.then(() => dispatch({ type: REMOVE_KEY, secret }))
|
||||||
.catch(dispatchAndThrow(dispatch, REMOVE_KEY));
|
.catch(dispatchAndThrow(dispatch, REMOVE_KEY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,11 +4,11 @@ import { RECIEVE_KEYS, ADD_KEY, REMOVE_KEY } from './actions';
|
|||||||
const store = (state = new List(), action) => {
|
const store = (state = new List(), action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case RECIEVE_KEYS:
|
case RECIEVE_KEYS:
|
||||||
return new List(action.keys);
|
return new List(action.tokens);
|
||||||
case ADD_KEY:
|
case ADD_KEY:
|
||||||
return state.push(action.token);
|
return state.push(action.token);
|
||||||
case REMOVE_KEY:
|
case REMOVE_KEY:
|
||||||
return state.filter(v => v.key !== action.key);
|
return state.filter(v => v.secret !== action.secret);
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user