From ef04443fcaedd563997046d2ed0f7b9c7c14b568 Mon Sep 17 00:00:00 2001 From: Ryan Srofe Date: Sun, 5 May 2024 11:11:05 -0400 Subject: [PATCH 1/4] adding save to version historty --- widget-src/components/log/LogEditing.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/widget-src/components/log/LogEditing.tsx b/widget-src/components/log/LogEditing.tsx index 2f087af..eb56c98 100644 --- a/widget-src/components/log/LogEditing.tsx +++ b/widget-src/components/log/LogEditing.tsx @@ -11,9 +11,15 @@ import { AddLink } from './AddLink'; import { ActionCloseIcon } from '../../svgs/ActionCloseIcon'; import { displayDate } from '../../utilities/Utils'; -const { widget } = figma; +const { widget, saveVersionHistoryAsync } = figma; const { AutoLayout, Text, useEffect } = widget; +async function saveToVersionHistory(name: string, description: string) { + await saveVersionHistoryAsync(name, description); + // console logging isnt working for some reason? + console.log('Version History Saved'); +} + interface ChangeLogEditingProps { changeLog: ChangeLog; updateChange: (changes: Partial) => void; @@ -164,6 +170,15 @@ export const ChangeLogEditing = ({ }, }); setUpdatedDate(Date.now()); + // ideally we should grab the name of the widget and the if there is a version + // grab that too and put them together, maybe even increment the version number automatically + // if its formatted properly or something? + // anyways put the widget name and version number together and use are title of version history + // then the changelog description as the description of the version history + saveChange !== '' && + saveToVersionHistory(saveChange, saveChange) + .then(val => console.log('Version History Saved', val)) + .catch(e => console.log('Error saving version history', e)); } }} /> From fb7681397a7e18d5b9b197de2be9c4deddc12300 Mon Sep 17 00:00:00 2001 From: Ryan Srofe Date: Wed, 15 Jan 2025 15:11:02 -0500 Subject: [PATCH 2/4] Update Figma Version History with FigLog Save lifts up the name and description values passes to header and changelogs to use in history update --- widget-src/Widget.tsx | 8 ++++++++ widget-src/components/ChangeLogList.tsx | 3 +++ widget-src/components/ChangeLogRow.tsx | 3 +++ widget-src/components/Header.tsx | 12 ++++++++++-- widget-src/components/log/LogEditing.tsx | 4 +++- 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/widget-src/Widget.tsx b/widget-src/Widget.tsx index 12257a8..5156d8b 100644 --- a/widget-src/Widget.tsx +++ b/widget-src/Widget.tsx @@ -26,6 +26,9 @@ function Widget() { // Change Logs const [changeIds, setChangeIds] = useSyncedState('changeKeys', []); const changeLogs = useSyncedMap('changes'); + // Name and Description + const [nameText, setNameText] = useSyncedState('nameText', ''); + const [descriptionText, setDescriptionText] = useSyncedState('descriptionText', ''); const updateOtherStates = (currentChangeId: string, changes: Partial) => { changeIds.map((id: string) => { @@ -190,6 +193,10 @@ function Widget() { showVersion={showVersion} addChange={addChange} isLocked={isLocked} + nameText={nameText} + setNameText={setNameText} + descriptionText={descriptionText} + setDescriptionText={setDescriptionText} /> {changeIds.length === 0 ? ( @@ -203,6 +210,7 @@ function Widget() { showTypes={showLogTypes} showAvatars={showAvatars} isLocked={isLocked} + nameText={nameText} /> )} {showBranding &&