mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 08:35:43 -06:00
* Configuration: Always display expired API keys * Use exclamation-triangle instead * Reintroduce toggle, move logic into store and call both endpoints * Handle apiKeys without TTL * Remove backend changes and make checks in frontend instead
19 lines
694 B
TypeScript
19 lines
694 B
TypeScript
import { ApiKeysState } from 'app/types';
|
|
|
|
export const getApiKeysCount = (state: ApiKeysState) =>
|
|
state.includeExpired ? state.keysIncludingExpired.length : state.keys.length;
|
|
|
|
export const getApiKeys = (state: ApiKeysState) => {
|
|
const regex = RegExp(state.searchQuery, 'i');
|
|
const keysToFilter = state.includeExpired ? state.keysIncludingExpired : state.keys;
|
|
|
|
return keysToFilter.filter((key) => {
|
|
return regex.test(key.name) || regex.test(key.role);
|
|
});
|
|
};
|
|
|
|
export const getIncludeExpired = (state: ApiKeysState) => state.includeExpired;
|
|
|
|
export const getIncludeExpiredDisabled = (state: ApiKeysState) =>
|
|
state.keys.length === 0 && state.keysIncludingExpired.length > 0;
|