Add support for storing SSH keys on user accounts
This commit is contained in:
parent
5705d7dbdd
commit
97280a62a2
20 changed files with 678 additions and 6 deletions
|
@ -2,8 +2,23 @@ import { Actions, useStoreActions } from 'easy-peasy';
|
|||
import { FlashStore } from '@/state/flashes';
|
||||
import { ApplicationStore } from '@/state';
|
||||
|
||||
interface KeyedFlashStore {
|
||||
clearFlashes: () => void;
|
||||
clearAndAddHttpError: (error?: Error | string | null) => void;
|
||||
}
|
||||
|
||||
const useFlash = (): Actions<FlashStore> => {
|
||||
return useStoreActions((actions: Actions<ApplicationStore>) => actions.flashes);
|
||||
};
|
||||
|
||||
const useFlashKey = (key: string): KeyedFlashStore => {
|
||||
const { clearFlashes, clearAndAddHttpError } = useFlash();
|
||||
|
||||
return {
|
||||
clearFlashes: () => clearFlashes(key),
|
||||
clearAndAddHttpError: (error) => clearAndAddHttpError({ key, error }),
|
||||
};
|
||||
};
|
||||
|
||||
export { useFlashKey };
|
||||
export default useFlash;
|
||||
|
|
12
resources/scripts/plugins/useUserSWRContentKey.ts
Normal file
12
resources/scripts/plugins/useUserSWRContentKey.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { useStoreState } from '@/state/hooks';
|
||||
|
||||
export default (context: string | string[]) => {
|
||||
const key = Array.isArray(context) ? context.join(':') : context;
|
||||
const uuid = useStoreState(state => state.user.data?.uuid);
|
||||
|
||||
if (!key.trim().length) {
|
||||
throw new Error('Must provide a valid context key to "useUserSWRContextKey".');
|
||||
}
|
||||
|
||||
return `swr::${uuid || 'unknown'}:${key.trim()}`;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue