Skip to content

Commit

Permalink
Introducing "Save & Refresh"!
Browse files Browse the repository at this point in the history
  • Loading branch information
sharat87 committed Jul 21, 2023
1 parent c6a0688 commit 70e7236
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/client/src/ce/api/TenantApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type UpdateTenantConfigResponse = ApiResponse<{

export type UpdateTenantConfigRequest = {
tenantConfiguration: Record<string, string>;
needsRefresh?: boolean;
isOnlyTenantSettings: boolean;
};

Expand Down
1 change: 1 addition & 0 deletions app/client/src/ce/constants/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,7 @@ export const OIDC_AUTH_DESC = () =>
"Enable your workspace to sign in with your preferred OIDC compliant provider.";
export const SAVE_BUTTON = () => "Save";
export const SAVE_AND_RESTART_BUTTON = () => "Save & Restart";
export const SAVE_AND_REFRESH_BUTTON = () => "Save & Refresh";
export const RESET_BUTTON = () => "Reset";
export const BUSINESS_TAG = () => "Business";
export const ENTERPRISE_TAG = () => "Enterprise";
Expand Down
2 changes: 2 additions & 0 deletions app/client/src/ce/pages/AdminSettings/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export interface Category {
slug: string;
subText?: string;
isConnected?: boolean;
needsRefresh?: boolean;
children?: Category[];
icon?: string;
categoryType: string;
Expand Down Expand Up @@ -130,6 +131,7 @@ export type AdminConfigType = {
children?: AdminConfigType[];
canSave: boolean;
isConnected?: boolean;
needsRefresh?: boolean;
icon?: string;
needsUpgrade?: boolean;
categoryType: CategoryType;
Expand Down
4 changes: 4 additions & 0 deletions app/client/src/ce/sagas/tenantSagas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ export function* updateTenantConfigSaga(
kind: "success",
});
}

if (action.payload.needsRefresh) {
location.reload();
}
}
} catch (error) {
const errorObj = error as APIResponseError;
Expand Down
23 changes: 16 additions & 7 deletions app/client/src/pages/Settings/SaveSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import {
RESET_BUTTON,
SAVE_AND_REFRESH_BUTTON,
SAVE_AND_RESTART_BUTTON,
SAVE_BUTTON,
createMessage,
Expand Down Expand Up @@ -32,6 +33,7 @@ const SettingsButtonWrapper = styled.div`
type SaveAdminSettingsProps = {
isOnlyTenantConfig?: boolean;
isSaving?: boolean;
needsRefresh?: boolean;
onSave?: () => void;
onClear?: () => void;
settings: Record<string, string>;
Expand All @@ -43,13 +45,26 @@ const saveAdminSettings = (props: SaveAdminSettingsProps) => {
const {
isOnlyTenantConfig = false,
isSaving,
needsRefresh = false,
onClear,
onSave,
settings,
updatedTenantSettings,
valid,
} = props;

let saveButtonText = SAVE_AND_RESTART_BUTTON;

if (needsRefresh) {
saveButtonText = SAVE_AND_REFRESH_BUTTON;
} else if (
isOnlyTenantConfig ||
(updatedTenantSettings?.length === Object.keys(settings).length &&
updatedTenantSettings?.length !== 0)
) {
saveButtonText = SAVE_BUTTON;
}

return (
<SettingsButtonWrapper>
<Button
Expand All @@ -59,13 +74,7 @@ const saveAdminSettings = (props: SaveAdminSettingsProps) => {
onClick={onSave}
size="md"
>
{createMessage(
isOnlyTenantConfig ||
(updatedTenantSettings?.length === Object.keys(settings).length &&
updatedTenantSettings?.length !== 0)
? SAVE_BUTTON
: SAVE_AND_RESTART_BUTTON,
)}
{createMessage(saveButtonText)}
</Button>
<Button
className="t--admin-settings-reset-button"
Expand Down
2 changes: 2 additions & 0 deletions app/client/src/pages/Settings/SettingsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export function SettingsForm(
updateTenantConfig({
tenantConfiguration: config,
isOnlyTenantSettings: !isEnvAndTenantSettings,
needsRefresh: details?.needsRefresh,
}),
);
// both env and tenant settings
Expand Down Expand Up @@ -282,6 +283,7 @@ export function SettingsForm(
<SaveAdminSettings
isOnlyTenantConfig={isOnlyTenantConfig}
isSaving={props.isSaving}
needsRefresh={details?.needsRefresh}
onClear={onClear}
onSave={onSave}
settings={props.settings}
Expand Down
1 change: 1 addition & 0 deletions app/client/src/pages/Settings/config/ConfigFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class ConfigFactory {
categoryType: config.categoryType,
needsUpgrade: config.needsUpgrade,
isEnterprise: config.isEnterprise,
needsRefresh: config.needsRefresh,
children: config?.children?.map((child) =>
ConfigFactory.getCategory(child),
),
Expand Down
1 change: 1 addition & 0 deletions app/client/src/pages/Settings/config/googleMaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const config: AdminConfigType = {
controlType: SettingTypes.GROUP,
title: "Google Maps",
canSave: true,
needsRefresh: true,
settings: [
{
id: "APPSMITH_GOOGLE_MAPS_READ_MORE",
Expand Down

0 comments on commit 70e7236

Please sign in to comment.