2022-12-29 11:48:24 +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';
|
|
|
|
|
import Select from '@/_ui/Select';
|
2023-06-29 10:00:10 +00:00
|
|
|
import { useAppVersionStore } from '@/_stores/appVersionStore';
|
|
|
|
|
import { shallow } from 'zustand/shallow';
|
2022-12-29 11:48:24 +00:00
|
|
|
|
|
|
|
|
export const CreateVersion = ({
|
|
|
|
|
appId,
|
|
|
|
|
appVersions,
|
|
|
|
|
setAppVersions,
|
|
|
|
|
setAppDefinitionFromVersion,
|
|
|
|
|
showCreateAppVersion,
|
|
|
|
|
setShowCreateAppVersion,
|
|
|
|
|
}) => {
|
|
|
|
|
const [isCreatingVersion, setIsCreatingVersion] = useState(false);
|
|
|
|
|
const [versionName, setVersionName] = useState('');
|
|
|
|
|
const { t } = useTranslation();
|
2023-06-29 10:00:10 +00:00
|
|
|
const { editingVersion } = useAppVersionStore(
|
|
|
|
|
(state) => ({
|
|
|
|
|
editingVersion: state.editingVersion,
|
|
|
|
|
}),
|
|
|
|
|
shallow
|
|
|
|
|
);
|
2023-07-18 07:41:31 +00:00
|
|
|
|
2022-12-29 11:48:24 +00:00
|
|
|
const createVersion = () => {
|
|
|
|
|
if (versionName.trim().length > 25) {
|
2023-01-04 07:58:55 +00:00
|
|
|
toast.error('Version name should not be longer than 25 characters');
|
2022-12-29 11:48:24 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (versionName.trim() == '') {
|
2023-01-04 07:58:55 +00:00
|
|
|
toast.error('Version name should not be empty');
|
2022-12-29 11:48:24 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setIsCreatingVersion(true);
|
|
|
|
|
appVersionService
|
|
|
|
|
.create(appId, versionName, editingVersion.id)
|
|
|
|
|
.then(() => {
|
|
|
|
|
toast.success('Version Created');
|
|
|
|
|
appVersionService.getAll(appId).then((data) => {
|
|
|
|
|
setVersionName('');
|
|
|
|
|
setIsCreatingVersion(false);
|
|
|
|
|
setAppVersions(data.versions);
|
|
|
|
|
const latestVersion = data.versions.at(0);
|
|
|
|
|
setAppDefinitionFromVersion(latestVersion);
|
|
|
|
|
setShowCreateAppVersion(false);
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
toast.error(error?.error);
|
|
|
|
|
setIsCreatingVersion(false);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const options = appVersions.map((version) => {
|
|
|
|
|
return { label: version.name, value: version };
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<AlertDialog
|
2023-06-29 10:00:10 +00:00
|
|
|
show={showCreateAppVersion}
|
2023-01-04 12:11:40 +00:00
|
|
|
closeModal={() => {
|
2023-05-11 07:02:21 +00:00
|
|
|
setVersionName('');
|
2023-01-04 12:11:40 +00:00
|
|
|
setShowCreateAppVersion(false);
|
|
|
|
|
}}
|
2022-12-29 11:48:24 +00:00
|
|
|
title={t('editor.appVersionManager.createVersion', 'Create new version')}
|
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 2150c8ec0ce9cedda4f4676211faa3321d4af7f8.
* 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 06:15:48 +00:00
|
|
|
checkForBackground={true}
|
2022-12-29 11:48:24 +00:00
|
|
|
>
|
2023-01-05 09:06:39 +00:00
|
|
|
<form
|
|
|
|
|
onSubmit={(e) => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
createVersion();
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div className="mb-3 pb-2">
|
|
|
|
|
<div className="col">
|
2023-03-20 05:13:08 +00:00
|
|
|
<label className="form-label" data-cy="version-name-label">
|
|
|
|
|
{t('editor.appVersionManager.versionName', 'Version Name')}
|
|
|
|
|
</label>
|
2023-01-05 09:06:39 +00:00
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
onChange={(e) => setVersionName(e.target.value)}
|
|
|
|
|
className="form-control"
|
2023-02-02 09:11:25 +00:00
|
|
|
data-cy="version-name-input-field"
|
2023-01-05 09:06:39 +00:00
|
|
|
placeholder={t('editor.appVersionManager.enterVersionName', 'Enter version name')}
|
|
|
|
|
disabled={isCreatingVersion}
|
|
|
|
|
value={versionName}
|
|
|
|
|
autoFocus={true}
|
|
|
|
|
minLength="1"
|
|
|
|
|
maxLength="25"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2022-12-29 11:48:24 +00:00
|
|
|
</div>
|
|
|
|
|
|
2023-05-11 07:02:21 +00:00
|
|
|
<div className="mb-4 pb-2 version-select">
|
2023-02-02 09:11:25 +00:00
|
|
|
<label className="form-label" data-cy="create-version-from-label">
|
|
|
|
|
{t('editor.appVersionManager.createVersionFrom', 'Create version from')}
|
|
|
|
|
</label>
|
|
|
|
|
<div className="ts-control" data-cy="create-version-from-input-field">
|
2023-01-05 09:06:39 +00:00
|
|
|
<Select
|
|
|
|
|
options={options}
|
2023-05-11 07:02:21 +00:00
|
|
|
defaultValue={options.find((option) => option?.value?.id === editingVersion?.id)}
|
2023-01-05 09:06:39 +00:00
|
|
|
onChange={(version) => {
|
2023-03-31 14:29:06 +00:00
|
|
|
setAppDefinitionFromVersion(version, false);
|
2023-01-05 09:06:39 +00:00
|
|
|
}}
|
|
|
|
|
useMenuPortal={false}
|
|
|
|
|
width="100%"
|
|
|
|
|
maxMenuHeight={100}
|
2023-05-11 07:02:21 +00:00
|
|
|
customWrap={true}
|
2023-01-05 09:06:39 +00:00
|
|
|
/>
|
|
|
|
|
</div>
|
2022-12-29 11:48:24 +00:00
|
|
|
</div>
|
|
|
|
|
|
2023-01-05 09:06:39 +00:00
|
|
|
<div className="mb-3">
|
|
|
|
|
<div className="col d-flex justify-content-end">
|
|
|
|
|
<button
|
|
|
|
|
className="btn mx-2"
|
2023-02-02 09:11:25 +00:00
|
|
|
data-cy="cancel-button"
|
2023-01-05 09:06:39 +00:00
|
|
|
onClick={() => {
|
2023-05-11 07:02:21 +00:00
|
|
|
setVersionName('');
|
2023-01-05 09:06:39 +00:00
|
|
|
setShowCreateAppVersion(false);
|
|
|
|
|
}}
|
|
|
|
|
type="button"
|
2022-12-29 11:48:24 +00:00
|
|
|
>
|
2023-01-05 09:06:39 +00:00
|
|
|
{t('globals.cancel', 'Cancel')}
|
|
|
|
|
</button>
|
2023-02-02 09:11:25 +00:00
|
|
|
<button
|
|
|
|
|
className={`btn btn-primary ${isCreatingVersion ? 'btn-loading' : ''}`}
|
|
|
|
|
data-cy="create-new-version-button"
|
|
|
|
|
type="submit"
|
|
|
|
|
>
|
2023-01-05 09:06:39 +00:00
|
|
|
<svg
|
|
|
|
|
className="icon"
|
|
|
|
|
width="21"
|
|
|
|
|
height="21"
|
|
|
|
|
viewBox="0 0 21 21"
|
|
|
|
|
fill="none"
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
>
|
|
|
|
|
<path
|
|
|
|
|
fillRule="evenodd"
|
|
|
|
|
clipRule="evenodd"
|
|
|
|
|
d="M6.34375 4.42643C5.88351 4.42643 5.51042 4.79953 5.51042 5.25977C5.51042 5.72 5.88351 6.0931 6.34375 6.0931C6.80399 6.0931 7.17708 5.72 7.17708 5.25977C7.17708 4.79953 6.80399 4.42643 6.34375 4.42643ZM3.84375 5.25977C3.84375 3.87905 4.96304 2.75977 6.34375 2.75977C7.72446 2.75977 8.84375 3.87905 8.84375 5.25977C8.84375 6.34828 8.14808 7.27431 7.17708 7.61751V12.902C7.88743 13.1531 8.45042 13.7161 8.7015 14.4264H13.0104C13.2314 14.4264 13.4434 14.3386 13.5997 14.1824C13.756 14.0261 13.8438 13.8141 13.8438 13.5931V11.4383L12.7663 12.5157C12.4409 12.8411 11.9133 12.8411 11.5878 12.5157C11.2624 12.1903 11.2624 11.6626 11.5878 11.3372L14.0878 8.83718C14.4133 8.51174 14.9409 8.51174 15.2663 8.83718L17.7663 11.3372C18.0918 11.6626 18.0918 12.1903 17.7663 12.5157C17.4409 12.8411 16.9133 12.8411 16.5878 12.5157L15.5104 11.4383V13.5931C15.5104 14.2561 15.247 14.892 14.7782 15.3609C14.3093 15.8297 13.6735 16.0931 13.0104 16.0931H8.7015C8.3583 17.0641 7.43227 17.7598 6.34375 17.7598C4.96304 17.7598 3.84375 16.6405 3.84375 15.2598C3.84375 14.1712 4.53942 13.2452 5.51042 12.902V7.61751C4.53942 7.27431 3.84375 6.34828 3.84375 5.25977ZM14.6771 4.42643C14.2168 4.42643 13.8438 4.79953 13.8438 5.25977C13.8438 5.72 14.2168 6.0931 14.6771 6.0931C15.1373 6.0931 15.5104 5.72 15.5104 5.25977C15.5104 4.79953 15.1373 4.42643 14.6771 4.42643ZM12.1771 5.25977C12.1771 3.87905 13.2964 2.75977 14.6771 2.75977C16.0578 2.75977 17.1771 3.87905 17.1771 5.25977C17.1771 6.64048 16.0578 7.75977 14.6771 7.75977C13.2964 7.75977 12.1771 6.64048 12.1771 5.25977ZM6.34375 14.4264C5.88351 14.4264 5.51042 14.7995 5.51042 15.2598C5.51042 15.72 5.88351 16.0931 6.34375 16.0931C6.80399 16.0931 7.17708 15.72 7.17708 15.2598C7.17708 14.7995 6.80399 14.4264 6.34375 14.4264Z"
|
|
|
|
|
fill="#FDFDFE"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
2022-12-29 11:48:24 +00:00
|
|
|
|
2023-01-05 09:06:39 +00:00
|
|
|
{t('editor.appVersionManager.createVersion', 'Create Version')}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2022-12-29 11:48:24 +00:00
|
|
|
</div>
|
2023-01-05 09:06:39 +00:00
|
|
|
</form>
|
2022-12-29 11:48:24 +00:00
|
|
|
</AlertDialog>
|
|
|
|
|
);
|
|
|
|
|
};
|