ToolJet/frontend/src/Editor/AppVersionsManager/EditVersionModal.jsx

103 lines
3 KiB
React
Raw Normal View History

2023-02-02 15:28:06 +00:00
import React, { useState } from 'react';
import { appVersionService } from '@/_services';
import AlertDialog from '@/_ui/AlertDialog';
import { toast } from 'react-hot-toast';
import { useTranslation } from 'react-i18next';
export const EditVersion = ({
appId,
value: editingVersionId,
setAppVersions,
setShowEditAppVersion,
showEditAppVersion,
appVersions,
}) => {
const [isEditingVersion, setIsEditingVersion] = useState(false);
const editingVersion = appVersions?.find((version) => version.id === editingVersionId);
const [versionName, setVersionName] = useState(editingVersion?.name || '');
const { t } = useTranslation();
React.useEffect(() => {
setVersionName(editingVersion?.name);
}, [editingVersion?.name]);
const editVersion = () => {
if (versionName.trim() === '') {
toast.error('Version name should not be empty');
return;
}
setIsEditingVersion(true);
appVersionService
.save(appId, editingVersionId, { name: versionName })
.then(() => {
toast.success('Version name updated');
appVersionService.getAll(appId).then((data) => {
const versions = data.versions;
setAppVersions(versions);
});
setIsEditingVersion(false);
setShowEditAppVersion(false);
})
.catch((error) => {
setIsEditingVersion(false);
toast.error(error?.error);
});
};
return (
<AlertDialog
show={showEditAppVersion}
closeModal={() => {
setVersionName(editingVersion?.name || '');
setShowEditAppVersion(false);
}}
title={t('editor.appVersionManager.editVersion', 'Edit Version')}
>
<form
onSubmit={(e) => {
e.preventDefault();
editVersion();
}}
>
<div className="row mb-3">
Feat :: Editor UI revamp (#7275) * temp commit :: editor redesign * fix :: components panel ui * style updates * fix :: arrangement widget list * fix :: light mode widget list * style fixes query manager * updates * updates heaer styles * global settings fix * left sidebar states and icon change * cleanup * minor fixes :: review * fix opacity mode toggle * detailing in hover states , bugfixes * fix :: coloring whole app , debugger ui * cleanup * fix :: revert some changes , fix statistics widget * feat :: navbar with new layout * fix :: lint warnings * cleanup * cleanup * minor fixes * fix :: reusing serchbox * removed unwanted prop * Revert "cleanup" This reverts commit b18abe19fbd82246611153634c79934ad9012101. * fix :: icons sidebar * fix :: padding searchbar * style fix * radix :: dark theme for portals * fix :: icon styles * fix :: all codehinter styles * update :: base bg color app * fix :: viewer color * minor fixes :: icon left sidebar * typo * fix :: styling save message header * icon :: fix for layout and inspector queries * fix :: canvas and editor bg * fix :: release btn style * fix :: navbar border * undo redo tooltip * fix :: page input * remove released btn icon * fix :: for icon not loading proper in inspector * fix :: dark mode toggle icon size * fix :: share app ui * fix :: style fixes , inspector runpy icon * fix :: ui runpy codehinter * fix :: inputs in gds connection * cleanup * fix :: copilot codehinter ui * fix :: share modal button * fix :: canvas bg text * style fix debugger * fix :: whole dahsboard layout and border for all codehinters * fix :: icon fills * fix :: icon fill color sidebar * darkmode fill color * minor style fix * Widget inspector redesign (#7355) * Setup Storybook * Update storybook config * Add tab and toggle group component * Created list component * Properties tab * update codehinter dropdown components * Refactor styling * Inspector header changes * Fix es lint issue * Fix * feat :: styling color picker styles panel * Fix color picker alignment * feat :: remove alpha * Fix UI bugs * fix :: color picker * Ui fix * Backward compatible pagination changes * fix * Feedback changes * UI feedback * Check fix * Fix * fix :: canvas bg popover * Styles fix * Fix conflct issues * minor style fix style tab * Fix * review comments fix :: hovering in color picker * Code review and design feedback * UI feedback * Fix UI styles * Fix pagination issue * fix :: dark mode issues in select , number input * fix :: remove extra boreder * fix :: table column popover ui and component popover inspector * fix :: datepickre input table column * fix :: colopicker in table column inspector * fix :: link column type ui in table * fix :: column delete ui and delete not triggering * Fix list item not dragging * fix :: closing of popover on link column select * style fix table popover * Pass dark mode to Event manager button * fix :: ux event manager * cleanup * cleanup * fix :: delete page modal ui --------- Co-authored-by: stepinfwd <stepinfwd@gmail.com> * style fixes --------- Co-authored-by: Nakul Nagargade <133095394+nakulnagargade@users.noreply.github.com>
2023-09-04 08:00:39 +00:00
<div className="col modal-main tj-app-input">
<input
type="text"
onChange={(e) => setVersionName(e.target.value)}
className="form-control"
2023-03-20 05:13:08 +00:00
data-cy="edit-version-name-input-field"
placeholder={t('editor.appVersionManager.enterVersionName', 'Enter version name')}
disabled={isEditingVersion}
value={versionName}
maxLength={25}
/>
</div>
</div>
<div className="row">
<div className="col d-flex justify-content-end">
2023-03-20 05:13:08 +00:00
<button
className="btn mx-2"
data-cy="cancel-button"
onClick={() => {
setVersionName(editingVersion?.name || '');
setShowEditAppVersion(false);
}}
2023-03-20 05:13:08 +00:00
type="button"
>
{t('globals.cancel', 'Cancel')}
</button>
2023-03-20 05:13:08 +00:00
<button
className={`btn btn-primary ${isEditingVersion ? 'btn-loading' : ''}`}
data-cy="save-button"
type="submit"
>
{t('globals.save', 'Save')}
</button>
</div>
</div>
</form>
</AlertDialog>
);
};