2018-09-26 06:45:04 -05:00
|
|
|
|
import { ApiKeysState } from 'app/types';
|
|
|
|
|
|
2021-12-16 05:46:09 -06:00
|
|
|
|
export const getApiKeysCount = (state: ApiKeysState) =>
|
|
|
|
|
state.includeExpired ? state.keysIncludingExpired.length : state.keys.length;
|
2018-10-10 18:05:50 -05:00
|
|
|
|
|
2018-09-26 06:45:04 -05:00
|
|
|
|
export const getApiKeys = (state: ApiKeysState) => {
|
|
|
|
|
const regex = RegExp(state.searchQuery, 'i');
|
2021-12-16 05:46:09 -06:00
|
|
|
|
const keysToFilter = state.includeExpired ? state.keysIncludingExpired : state.keys;
|
2018-09-26 06:45:04 -05:00
|
|
|
|
|
2021-12-16 05:46:09 -06:00
|
|
|
|
return keysToFilter.filter((key) => {
|
2018-09-26 06:45:04 -05:00
|
|
|
|
return regex.test(key.name) || regex.test(key.role);
|
|
|
|
|
});
|
|
|
|
|
};
|
2021-12-16 05:46:09 -06:00
|
|
|
|
|
|
|
|
|
export const getIncludeExpired = (state: ApiKeysState) => state.includeExpired;
|
|
|
|
|
|
|
|
|
|
export const getIncludeExpiredDisabled = (state: ApiKeysState) =>
|
|
|
|
|
state.keys.length === 0 && state.keysIncludingExpired.length > 0;
|