Skip to content

Commit 14ab960

Browse files
fix: update rotating key state management to use envId for better tracking
1 parent bd3233e commit 14ab960

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

web/src/pages/Environments.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import ConfirmDialog from "../components/ui/confirm-dialog";
2222
export default function Environments() {
2323
const [isAddingVariable, setIsAddingVariable] = useState(false);
2424
const [isAddingEnv, setIsAddingEnv] = useState(false);
25-
const [isRotatingKey, setIsRotatingKey] = useState(false);
25+
const [isRotatingKey, setIsRotatingKey] = useState(null);
2626
const [isEditingVariable, setIsEditingVariable] = useState(false);
2727
const [isTogglingVariable, setIsToggligVariable] = useState(null);
2828
const [isDeletingVariable, setIsDeletingVariable] = useState(null);
@@ -148,14 +148,14 @@ function openDeleteProjectDialog() {
148148
// 🔹 Rotate Key
149149
async function rotate(envId) {
150150
if(isRotatingKey) return;
151-
setIsRotatingKey(true);
151+
setIsRotatingKey(envId);
152152
try {
153153
const res = await api.post(`/api/environments/${envId}/rotate-key`, {}, token);
154154
setRotatedKey(res.apiKey);
155155
} catch (error) {
156156

157157
}finally {
158-
setIsRotatingKey(false);
158+
setIsRotatingKey(null);
159159
}
160160

161161
}
@@ -339,8 +339,8 @@ function openDeleteProjectDialog() {
339339
</div>
340340
<div className="flex gap-2 flex-row flex-wrap">
341341
<Button onClick={() => rotate(env._id)} variant="outline" size="sm" className="gap-2">
342-
{isRotatingKey && <><RotateCcw className="w-4 h-4 animate-spin" /> Rotate Key </>}
343-
{!isRotatingKey && <><RotateCcw className="w-4 h-4" /> Rotate Key </>}
342+
{isRotatingKey === env._id && <><RotateCcw className="w-4 h-4 animate-spin" /> Rotating Key </>}
343+
{isRotatingKey !== env._id && <><RotateCcw className="w-4 h-4" /> Rotate Key </>}
344344
</Button>
345345
<Button onClick={() => toggleEnv(env._id)} variant="outline" size="sm" className="gap-2">
346346
{selectedEnv === env._id ? (

0 commit comments

Comments
 (0)