Skip to content

Commit

Permalink
Merge pull request #9148 from ToolJet/release/platformv14.2
Browse files Browse the repository at this point in the history
* bump version

* copywrite update (#9075)

* Import higher version fix (#8922)

* Immport higher version issue

* Fix: import higher version

* toast error meassage

* typo fix

* toast error message

---------

Co-authored-by: Kritagya <kriks.iitk@.com>

* fix toggles on workspace login page (#9150)

* fix: drag and drop on bulk upload (#9143)

* Added fix for create organization key-down issue (#9151)

---------

Co-authored-by: Anantshree Chandola <anantshreechandola23@gmail.com>
Co-authored-by: kriks7iitk <34170719+kriks7iitk@users.noreply.github.com>
Co-authored-by: Kritagya <kriks.iitk@.com>
Co-authored-by: vjaris42 <vjy239@gmail.com>
Co-authored-by: Muhsin Shah C P <muhsinshah21@gmail.com>
  • Loading branch information
6 people committed Mar 21, 2024
2 parents 9b3af0c + d17561a commit d06ced2
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.33.2
2.33.3
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ describe("User permissions", () => {
common.navigateToWorkspaceVariable();
cy.get('[data-cy="alert-info-text"]>>.text-muted').verifyVisibleElement(
"have.text",
"There are no Workspace variables. Workspace variables are being deprecated soon, so please use Workspace constants instead."
"Workspace variables will no longer be supported after April 30, 2024. To maintain optimal performance, please make the switch to Workspace constants"
);
cy.get(
'[data-cy="go-to-workspace-constants-option-button"]'
Expand Down
2 changes: 1 addition & 1 deletion frontend/.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.33.2
2.33.3
3 changes: 2 additions & 1 deletion frontend/src/HomePage/HomePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import BulkIcon from '@/_ui/Icon/bulkIcons/index';
import { getWorkspaceId, pageTitles, setWindowTitle } from '@/_helpers/utils';
import { withRouter } from '@/_hoc/withRouter';
import FolderFilter from './FolderFilter';
import { APP_ERROR_TYPE } from '@/_helpers/error_constants';

const { iconList, defaultIcon } = configs;

Expand Down Expand Up @@ -259,7 +260,7 @@ class HomePageComponent extends React.Component {
if (error.statusCode === 409) {
return false;
}
toast.error("Couldn't import the app");
toast.error(error?.error || 'App import failed');
}
};

Expand Down
7 changes: 5 additions & 2 deletions frontend/src/ManageOrgUsers/FileDropzone.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ export function FileDropzone({ handleClick, hiddenFileInput, errors, handleFileC
const [fileData, setFileData] = useState();
const { getRootProps, getInputProps, isDragActive, acceptedFiles } = useDropzone({
accept: { parsedFileType: ['text/csv'] },
onDrop,
onDrop: (acceptedFiles) => {
onDrop(acceptedFiles);
const file = acceptedFiles[0];
setFileData(file);
},
noClick: true,
onDropRejected: (files) => {
if (files[0].size > 1048576) {
Expand Down Expand Up @@ -64,7 +68,6 @@ export function FileDropzone({ handleClick, hiddenFileInput, errors, handleFileC
<span className="file-upload-error" data-cy="file-error">
{errors['file']}
</span>
<ul>{acceptedFiles}</ul>
{fileData?.name && <ul data-cy="uploaded-file-data">{` ${fileData?.name} - ${fileData?.size} bytes`}</ul>}
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/ManageOrgVars/ManageOrgVars.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ class ManageOrgVarsComponent extends React.Component {
</div>
) : (
<div className="text-muted">
There are no Workspace variables. Workspace variables are being deprecated soon, so please use Workspace
constants instead.
Workspace variables will no longer be supported after April 30, 2024. To maintain optimal performance, please
make the switch to Workspace constants
</div>
);

Expand Down
11 changes: 4 additions & 7 deletions frontend/src/_components/OrganizationLogin/GithubSsoModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,16 @@ export function GithubSSOModal({ settings, onClose, onUpdateSSOSettings, isInsta

const handleClientIdChange = (newClientId) => {
setClientId(newClientId);
const changesMade = newClientId !== settings?.configs?.client_id;
checkChanges();
};

const handleHostNameChange = (newHostName) => {
setHostName(newHostName);
const changesMade = newHostName !== settings?.configs?.host_name;
checkChanges();
};

const handleClientSecretChange = (newClientSecret) => {
setClientSecret(newClientSecret);
const changesMade = newClientSecret !== settings?.configs?.client_secret;
checkChanges();
};

Expand All @@ -59,10 +56,10 @@ export function GithubSSOModal({ settings, onClose, onUpdateSSOSettings, isInsta
};

const checkChanges = () => {
const hasClientIdChanged = clientId !== settings?.configs?.client_id;
const hasEnabledChanged = enabled !== settings?.enabled;
const hasHostNameChanged = hostName !== settings?.configs?.host_name;
const hasClientSecretChanged = clientSecret != settings?.configs?.client_secret;
const hasClientIdChanged = clientId !== (settings?.configs?.client_id || '');
const hasEnabledChanged = enabled !== (settings?.enabled || false);
const hasHostNameChanged = hostName !== (settings?.configs?.host_name || '');
const hasClientSecretChanged = clientSecret != (settings?.configs?.client_secret || '');
setHasChanges(hasClientIdChanged || hasEnabledChanged || hasHostNameChanged || hasClientSecretChanged);
};

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/_components/OrganizationLogin/GoogleSsoModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export function GoogleSSOModal({ settings, onClose, onUpdateSSOSettings, isInsta
};

const checkChanges = () => {
const hasClientIdChanged = clientId !== settings?.configs?.client_id;
const hasEnabledChanged = enabled !== settings?.enabled;
const hasClientIdChanged = clientId !== (settings?.configs?.client_id || '');
const hasEnabledChanged = enabled !== (settings?.enabled || false);
setHasChanges(hasClientIdChanged || hasEnabledChanged);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class SSOConfiguration extends React.Component {
const isEnabledKey = `${key}Enabled`;
const enabledStatus = !this.state[isEnabledKey];

if (enabledStatus === false) {
if (!enabledStatus) {
try {
await this.handleToggleSSOOption(key);
toast.success(
Expand Down Expand Up @@ -238,7 +238,7 @@ class SSOConfiguration extends React.Component {

renderSSOOption = (key, name) => {
const isEnabledKey = `${key}Enabled`;
const isEnabled = this.state[isEnabledKey];
const isEnabled = this.state[isEnabledKey] || false;

return (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ export const CreateOrganization = ({ showCreateOrg, setShowCreateOrg }) => {
className={`form-control ${name?.error ? 'is-invalid' : 'is-valid'}`}
placeholder={t('header.organization.workspaceName', 'Workspace name')}
disabled={isCreating}
onKeyDown={handleKeyDown}
maxLength={50}
data-cy="workspace-name-input-field"
autoFocus
Expand Down Expand Up @@ -247,6 +246,7 @@ export const CreateOrganization = ({ showCreateOrg, setShowCreateOrg }) => {
disabled={isDisabled}
onClick={createOrganization}
data-cy="create-workspace-button"
type="submit"
isLoading={isCreating}
>
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/_helpers/error_constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const APP_ERROR_TYPE = {
IMPORT_EXPORT_SERVICE: {
UNSUPPORTED_VERSION_ERROR: "Can't import higher version application to lower version",
},
};
2 changes: 1 addition & 1 deletion server/.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.33.2
2.33.3
9 changes: 7 additions & 2 deletions server/src/controllers/import_export_resources.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller, Post, UseGuards, Body, ForbiddenException } from '@nestjs/common';
import { Controller, Post, UseGuards, Body, ForbiddenException, BadRequestException } from '@nestjs/common';
import { JwtAuthGuard } from '../../src/modules/auth/jwt-auth.guard';
import { User } from 'src/decorators/user.decorator';
import { ExportResourcesDto } from '@dto/export-resources.dto';
Expand All @@ -7,6 +7,8 @@ import { ImportExportResourcesService } from '@services/import_export_resources.
import { App } from 'src/entities/app.entity';
import { AppsAbilityFactory } from 'src/modules/casl/abilities/apps-ability.factory';
import { CloneResourcesDto } from '@dto/clone-resources.dto';
import { checkVersionCompatibility } from 'src/helpers/utils.helper';
import { APP_ERROR_TYPE } from 'src/helpers/error_type.constant';

@Controller({
path: 'resources',
Expand Down Expand Up @@ -41,7 +43,10 @@ export class ImportExportResourcesController {
if (!ability.can('cloneApp', App)) {
throw new ForbiddenException('You do not have permissions to perform this action');
}

const isNotCompatibleVersion = !checkVersionCompatibility(importResourcesDto.tooljet_version);
if (isNotCompatibleVersion) {
throw new BadRequestException(APP_ERROR_TYPE.IMPORT_EXPORT_SERVICE.UNSUPPORTED_VERSION_ERROR);
}
const imports = await this.importExportResourcesService.import(user, importResourcesDto);
return { imports, success: true };
}
Expand Down
5 changes: 5 additions & 0 deletions server/src/helpers/error_type.constant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const APP_ERROR_TYPE = {
IMPORT_EXPORT_SERVICE: {
UNSUPPORTED_VERSION_ERROR: "Can't import higher version application to lower version",
},
};
4 changes: 4 additions & 0 deletions server/src/helpers/utils.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ export function extractMajorVersion(version) {
return semver.valid(semver.coerce(version));
}

export function checkVersionCompatibility(importingVersion) {
return semver.gte(semver.coerce(globalThis.TOOLJET_VERSION), semver.coerce(importingVersion));
}

/**
* Checks if a given Tooljet version is compatible with normalized app definition schemas.
*
Expand Down

0 comments on commit d06ced2

Please sign in to comment.