ToolJet/frontend/src/Editor/AppVersionsManager/EditVersionModal.jsx
Kiran Ashok 65259afeb2
Feature Homepage and settings redesign (#5763)
* adding colors

* feat :: add button

* feat :: added typography

* feat: init storybook

* removes browserlist

* feat :: adding button styles and button component

* feat :: added sass addon

* stories update

* feat :: replacing with radix colors

* danger variants

* updates buttin story

* fix :: removing default items

* cleanup

* fix icons update

* feat :: folder list component

* fix :: naming

* icon and split button :: init

* intermediate save :: app card component

* renaming

* updates

* update for module imports

* updates icon

* update :: homepage design updates

* design changes dashboard

* updates :: apps section

* workspace stting new design upate

* updates dasboard design

* style :: fixes

* feat :: added context for sidebar nav breadcrumb

* added all solid icons

* intermediate update

* change: conditions for fetching users

* sorybook updates

* design updates :: workspace settings page

* manage users page

* lint fixes

* fix :: styling

* stle fixes :: workspace settings

* homepage redesign

* fix :: all drawer colors and position ,teplate page revamp , database page header fixes

* imported all bulk icons

* svg to jsx : bulk icons

* minor :: cleanup

* fix :: manage users drawer

* fix :: searchboxes , userspage fixes

* fix :: all inputs and minor ui fixes

* database page ui fixes

* fix :: database and folder search functionality and iconlist in homecard

* fixed some db functionality and edge cases for longer texts

* fix :: user addition manage user page

* self review cleanup and change in bulk icon fill state

* fix :: homepage seacbar

* merging develop and resolving conflicts

* remove unwanted stories

* reverting merge with develop

* Revert "reverting merge with develop"

This reverts commit 2150c8ec0c.

* clearing out warnings

* lint fixes

* feat :: added org modal in database page

* fix :: sso loader theme

* fix :: broken styles select

* fixed icon warning and select ui

* fix :: upload bulk and user select dark mode

* merge styles  with develop

* feat :: integrated new ui for database

* removing storybook files

* fix :: all bugs related to users dropdown and cleanup

* fix: user search api for organization page

* cleanup and splitting dropzone component

* fix :: overflow issue in app card time

* fix for scrollbars in homepage

* PR review fixes

* updates :: fix d=global datasource design issues , homepage responsiveness

* tj db operations

* breadcrumb bug fixes

* lint fixes

* removing logs , removed fade in in datasource and database page

* marketplace page ui fix

* removing inital users table fetch

* Pr :: review changes

* remove logs

* fix :: popover bug

* minot style fix

* fix :: remove arrow from all popovers

* fix :: for loading states

* ux :: sidebar items reorder

* style :: fix

* style fix :: templates

* fix :: qa bugs

* fix :: Qa reported bugs

* removes :: folder fetch bug

* share link and datsource bg color fix

* fixes :: rename group ,

* removed logs

* pages popover background fix

* fix :: tj db table addition ui bug

* fix :: ui bug confirm modal password disable

* modal , revert name capitalize in lists, typos fix

* typos , users page route bugfix

* users page header bugfix

* workspace archive btn , datasources form style for select

* groups updated , delete, create flow updated

* avatar bug in profile page fix

* revert styles

* fix :: for create new table nav breadcrumb not being updated

* click state bug fix in avatar

* fix bug with appcard popover

* fix :: text capitalize issue

* fix :: lints and updated icon for filter delete

* fix warnings

---------

Co-authored-by: gandharv <gandharvkumargarg@gmail.com>
Co-authored-by: Vijaykant Yadav <vjy239@gmail.com>
2023-04-21 11:45:48 +05:30

92 lines
2.7 KiB
JavaScript

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,
editingVersion,
}) => {
const [isEditingVersion, setIsEditingVersion] = useState(false);
const [versionName, setVersionName] = useState(editingVersion?.name || '');
const { t } = useTranslation();
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={() => setShowEditAppVersion(false)}
title={t('editor.appVersionManager.editVersion', 'Edit Version')}
checkForBackground={true}
>
<form
onSubmit={(e) => {
e.preventDefault();
editVersion();
}}
>
<div className="row mb-3">
<div className="col modal-main">
<input
type="text"
onChange={(e) => setVersionName(e.target.value)}
className="form-control"
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">
<button
className="btn mx-2"
data-cy="cancel-button"
onClick={() => setShowEditAppVersion(false)}
type="button"
>
{t('globals.cancel', 'Cancel')}
</button>
<button
className={`btn btn-primary ${isEditingVersion ? 'btn-loading' : ''}`}
data-cy="save-button"
type="submit"
>
{t('globals.save', 'Save')}
</button>
</div>
</div>
</form>
</AlertDialog>
);
};