Skip to content

Commit

Permalink
Merge branch 'feat/setup-wizard-back-step' of github.com:RocketChat/R…
Browse files Browse the repository at this point in the history
…ocket.Chat into feat/setup-wizard-back-step
  • Loading branch information
tiagoevanp committed Oct 11, 2023
2 parents c31273f + c973af0 commit fada849
Show file tree
Hide file tree
Showing 32 changed files with 222 additions and 112 deletions.
5 changes: 5 additions & 0 deletions .changeset/eleven-gorillas-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fix trying to upload same file again and again.
5 changes: 5 additions & 0 deletions .changeset/gentle-radios-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed DM room with "guest" user kept as "read only" after reactivating user
5 changes: 5 additions & 0 deletions .changeset/heavy-ads-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fix: Change plan name from Enterprise to Premium on marketplace filtering
5 changes: 5 additions & 0 deletions .changeset/odd-hounds-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

chore: Change plan name Enterprise to Premium on marketplace
5 changes: 5 additions & 0 deletions .changeset/proud-shrimps-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fix: Unable to send attachments via email as an omni-agent
5 changes: 5 additions & 0 deletions .changeset/shiny-pillows-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fix: cloud alerts not working
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export async function getWorkspaceLicense(): Promise<{ updated: boolean; license

const payload = await fetchCloudWorkspaceLicensePayload({ token });

if (Date.parse(payload.updatedAt) <= currentLicense._updatedAt.getTime()) {
if (currentLicense.value && Date.parse(payload.updatedAt) <= currentLicense._updatedAt.getTime()) {
return fromCurrentLicense();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export async function announcementSync() {
} catch (err) {
SystemLogger.error({
msg: 'Failed to sync with Rocket.Chat Cloud',
url: '/sync',
url: '/comms/workspace',
err,
});
}
Expand Down
6 changes: 4 additions & 2 deletions apps/meteor/app/cloud/server/functions/syncWorkspace/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SystemLogger } from '../../../../../server/lib/logger/system';
import { CloudWorkspaceAccessTokenError } from '../getWorkspaceAccessToken';
import { getCachedSupportedVersionsToken } from '../supportedVersionsToken/supportedVersionsToken';
import { announcementSync } from './announcementSync';
Expand All @@ -7,10 +8,11 @@ export async function syncWorkspace() {
try {
await syncCloudData();
await announcementSync();
} catch (error) {
if (error instanceof CloudWorkspaceAccessTokenError) {
} catch (err) {
if (err instanceof CloudWorkspaceAccessTokenError) {
// TODO: Remove License if there is no access token
}
SystemLogger.error({ msg: 'Error during workspace sync', err });
}

await getCachedSupportedVersionsToken.reset();
Expand Down
22 changes: 10 additions & 12 deletions apps/meteor/app/version-check/server/functions/getNewUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,16 @@ export const getNewUpdates = async () => {
infoUrl: String,
}),
],
alerts: [
Match.Optional([
Match.ObjectIncluding({
id: String,
title: String,
text: String,
textArguments: [Match.Any],
modifiers: [String] as [StringConstructor],
infoUrl: String,
}),
]),
],
alerts: Match.Optional([
Match.ObjectIncluding({
id: String,
title: String,
text: String,
textArguments: [Match.Any],
modifiers: [String] as [StringConstructor],
infoUrl: String,
}),
]),
}),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const GenericUpsellModal = ({
<Modal.Header>
{icon && <Modal.Icon name={icon} />}
<Modal.HeaderText>
<Modal.Tagline color='font-annotation'>{tagline ?? t('Enterprise_capability')}</Modal.Tagline>
<Modal.Tagline color='font-annotation'>{tagline ?? t('Premium_capability')}</Modal.Tagline>
<Modal.Title>{title}</Modal.Title>
</Modal.HeaderText>
<Modal.Close aria-label={t('Close')} onClick={onClose} />
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/lib/chats/ChatAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export type ChatAPI = {
ActionManager: any;

readonly flows: {
readonly uploadFiles: (files: readonly File[]) => Promise<void>;
readonly uploadFiles: (files: readonly File[], resetFileInput?: () => void) => Promise<void>;
readonly sendMessage: ({ text, tshow }: { text: string; tshow?: boolean; previewUrls?: string[] }) => Promise<boolean>;
readonly processSlashCommand: (message: IMessage, userId: string | null) => Promise<boolean>;
readonly processTooLongMessage: (message: IMessage) => Promise<boolean>;
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/client/lib/chats/flows/uploadFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { imperativeModal } from '../../imperativeModal';
import { prependReplies } from '../../utils/prependReplies';
import type { ChatAPI } from '../ChatAPI';

export const uploadFiles = async (chat: ChatAPI, files: readonly File[]): Promise<void> => {
export const uploadFiles = async (chat: ChatAPI, files: readonly File[], resetFileInput?: () => void): Promise<void> => {
const replies = chat.composer?.quotedMessages.get() ?? [];

const msg = await prependReplies('', replies);
Expand Down Expand Up @@ -52,4 +52,5 @@ export const uploadFiles = async (chat: ChatAPI, files: readonly File[]): Promis
};

uploadNextFile();
resetFileInput?.();
};
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const AppsFilters = ({

const appsSearchPlaceholders: { [key: string]: string } = {
explore: t('Search_Apps'),
enterprise: t('Search_Enterprise_Apps'),
enterprise: t('Search_Premium_Apps'),
installed: t('Search_Installed_Apps'),
requested: t('Search_Requested_Apps'),
private: t('Search_Private_apps'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const AppsPageContent = (): ReactElement => {
{ id: 'all', label: t('All_Prices'), checked: true },
{ id: 'free', label: t('Free_Apps'), checked: false },
{ id: 'paid', label: t('Paid_Apps'), checked: false },
{ id: 'enterprise', label: t('Enterprise'), checked: false },
{ id: 'premium', label: t('Premium'), checked: false },
],
});
const freePaidFilterOnSelected = useRadioToggle(setFreePaidFilterStructure);
Expand Down Expand Up @@ -89,7 +89,7 @@ const AppsPageContent = (): ReactElement => {

const getAppsData = useCallback((): appsDataType => {
switch (context) {
case 'enterprise':
case 'premium':
case 'explore':
case 'requested':
return marketplaceApps;
Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/client/views/marketplace/BundleChips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ const BundleChips = ({ bundledIn }: BundleChipsProps): ReactElement => {

return (
<>
{bundledIn.map((bundle) => (
{bundledIn.map(({ bundleId, bundleName }) => (
<Tag
key={bundle.bundleId}
key={bundleId}
variant='featured'
title={t('this_app_is_included_with_subscription', {
bundleName: bundle.bundleName,
bundleName,
})}
>
{bundle.bundleName}
{bundleName}
</Tag>
))}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const EnabledAppsCount = ({
percentage: number;
limit: number;
enabled: number;
context: 'private' | 'explore' | 'installed' | 'enterprise' | 'requested';
context: 'private' | 'explore' | 'installed' | 'premium' | 'requested';
}): ReactElement | null => {
const t = useTranslation();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import EnabledAppsCount from './EnabledAppsCount';
const MarketplaceHeader = ({ title }: { title: string }): ReactElement | null => {
const t = useTranslation();
const isAdmin = usePermission('manage-apps');
const context = (useRouteParameter('context') || 'explore') as 'private' | 'explore' | 'installed' | 'enterprise' | 'requested';
const context = (useRouteParameter('context') || 'explore') as 'private' | 'explore' | 'installed' | 'premium' | 'requested';
const route = useRoute('marketplace');
const setModal = useSetModal();
const result = useAppsCountQuery(context);
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/views/marketplace/hooks/useAppInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const useAppInfo = (appId: string, context: string): AppInfo | undefined
}

let appResult: App | undefined;
const marketplaceAppsContexts = ['explore', 'enterprise', 'requested'];
const marketplaceAppsContexts = ['explore', 'premium', 'requested'];

if (marketplaceAppsContexts.includes(context)) appResult = marketplaceApps.value?.apps.find((app) => app.id === appId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const getProgressBarValues = (numberOfEnabledApps: number, enabledAppsLimit: num
percentage: Math.round((numberOfEnabledApps / enabledAppsLimit) * 100),
});

export type MarketplaceRouteContext = 'private' | 'explore' | 'installed' | 'enterprise' | 'requested';
export type MarketplaceRouteContext = 'private' | 'explore' | 'installed' | 'premium' | 'requested';

export function isMarketplaceRouteContext(context: string): context is MarketplaceRouteContext {
return ['private', 'explore', 'installed', 'enterprise', 'requested'].includes(context);
return ['private', 'explore', 'installed', 'premium', 'requested'].includes(context);
}

export const useAppsCountQuery = (context: MarketplaceRouteContext) => {
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/views/marketplace/hooks/useFilteredApps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const useFilteredApps = ({
const filterByPurchaseType: Record<string, (apps: App[]) => App[]> = {
all: fallback,
paid: (apps: App[]) => apps.filter(filterAppsByPaid),
enterprise: (apps: App[]) => apps.filter(filterAppsByEnterprise),
premium: (apps: App[]) => apps.filter(filterAppsByEnterprise),
free: (apps: App[]) => apps.filter(filterAppsByFree),
};

Expand All @@ -80,7 +80,7 @@ export const useFilteredApps = ({
explore: fallback,
installed: fallback,
private: fallback,
enterprise: (apps: App[]) => apps.filter(({ categories }) => categories.includes('Enterprise')),
premium: (apps: App[]) => apps.filter(({ categories }) => categories.includes('Premium')),
requested: (apps: App[]) => apps.filter(({ appRequestStats, installed }) => Boolean(appRequestStats) && !installed),
};

Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/views/marketplace/sidebarItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export const {
permissionGranted: (): boolean => hasAtLeastOnePermission(['access-marketplace', 'manage-apps']),
},
{
href: '/marketplace/enterprise',
href: '/marketplace/premium',
icon: 'lightning',
i18nLabel: 'Enterprise',
i18nLabel: 'Premium',
permissionGranted: (): boolean => hasAtLeastOnePermission(['access-marketplace', 'manage-apps']),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ const FileUploadAction = ({ collapsed, chatContext, disabled, ...props }: FileUp
const fileInputRef = useRef<HTMLInputElement>(null);
const chat = useChat() ?? chatContext;

const resetFileInput = () => {
if (!fileInputRef.current) {
return;
}

fileInputRef.current.value = '';
};

const handleUploadChange = async (e: ChangeEvent<HTMLInputElement>) => {
const { mime } = await import('../../../../../../../app/utils/lib/mimeTypes');
const filesToUpload = Array.from(e.target.files ?? []).map((file) => {
Expand All @@ -26,8 +34,7 @@ const FileUploadAction = ({ collapsed, chatContext, disabled, ...props }: FileUp
});
return file;
});

chat?.flows.uploadFiles(filesToUpload);
chat?.flows.uploadFiles(filesToUpload, resetFileInput);
};

const handleUpload = () => {
Expand Down
49 changes: 7 additions & 42 deletions apps/meteor/ee/app/license/server/settings.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { License } from '@rocket.chat/license';
import { Settings } from '@rocket.chat/models';
import { Meteor } from 'meteor/meteor';

import { settings, settingsRegistry } from '../../../../app/settings/server';
import { settingsRegistry } from '../../../../app/settings/server';

Meteor.startup(async () => {
await settingsRegistry.addGroup('Enterprise', async function () {
Expand All @@ -11,6 +9,12 @@ Meteor.startup(async () => {
type: 'string',
i18nLabel: 'Enterprise_License',
});
await this.add('Enterprise_License_Data', '', {
type: 'string',
hidden: true,
blocked: true,
public: false,
});
await this.add('Enterprise_License_Status', '', {
readonly: true,
type: 'string',
Expand All @@ -19,42 +23,3 @@ Meteor.startup(async () => {
});
});
});

settings.watch<string>('Enterprise_License', async (license) => {
if (!license || String(license).trim() === '') {
return;
}

if (license === process.env.ROCKETCHAT_LICENSE) {
return;
}

try {
if (!(await License.setLicense(license))) {
await Settings.updateValueById('Enterprise_License_Status', 'Invalid');
return;
}
} catch (_error) {
// do nothing
}

await Settings.updateValueById('Enterprise_License_Status', 'Valid');
});

if (process.env.ROCKETCHAT_LICENSE) {
try {
await License.setLicense(process.env.ROCKETCHAT_LICENSE);
} catch (_error) {
// do nothing
}

Meteor.startup(async () => {
if (settings.get('Enterprise_License')) {
console.warn(
'Rocket.Chat Enterprise: The license from your environment variable was ignored, please use only the admin setting from now on.',
);
return;
}
await Settings.updateValueById('Enterprise_License', process.env.ROCKETCHAT_LICENSE);
});
}
Loading

0 comments on commit fada849

Please sign in to comment.