X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/23b0c2abcd8913e6518f21c2c6a399751455cda0..d171dc7d61d9ab3d952bb5038b2d47dbeaaa8ba2:/src/store/current-token-dialog/current-token-dialog-actions.tsx?ds=sidebyside

diff --git a/src/store/current-token-dialog/current-token-dialog-actions.tsx b/src/store/current-token-dialog/current-token-dialog-actions.tsx
new file mode 100644
index 00000000..030b18e2
--- /dev/null
+++ b/src/store/current-token-dialog/current-token-dialog-actions.tsx
@@ -0,0 +1,26 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { dialogActions } from "~/store/dialog/dialog-actions";
+import { getProperty } from '../properties/properties';
+import { propertiesActions } from '~/store/properties/properties-actions';
+import { RootState } from '~/store/store';
+
+export const CURRENT_TOKEN_DIALOG_NAME = 'currentTokenDialog';
+const API_HOST_PROPERTY_NAME = 'apiHost';
+
+export interface CurrentTokenDialogData {
+    currentToken: string;
+    apiHost: string;
+}
+
+export const setCurrentTokenDialogApiHost = (apiHost: string) =>
+    propertiesActions.SET_PROPERTY({ key: API_HOST_PROPERTY_NAME, value: apiHost });
+
+export const getCurrentTokenDialogData = (state: RootState): CurrentTokenDialogData => ({
+    apiHost: getProperty<string>(API_HOST_PROPERTY_NAME)(state.properties) || '',
+    currentToken: state.auth.apiToken || '',
+});
+
+export const openCurrentTokenDialog = dialogActions.OPEN_DIALOG({ id: CURRENT_TOKEN_DIALOG_NAME, data: {} });
