Skip to content

Commit

Permalink
rename system to browser
Browse files Browse the repository at this point in the history
  • Loading branch information
Weiko committed Jul 29, 2024
1 parent c4b20f3 commit 26efbf2
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 42 deletions.
10 changes: 5 additions & 5 deletions packages/twenty-front/src/generated/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1018,19 +1018,19 @@ export type WorkspaceMember = {
timeZone?: Maybe<Scalars['String']>;
};

/** Date format as Month first, Day first, Year first or system as default */
/** Date format as Month first, Day first, Year first or browser as default */
export enum WorkspaceMemberDateFormatEnum {
Browser = 'BROWSER',
DayFirst = 'DAY_FIRST',
MonthFirst = 'MONTH_FIRST',
System = 'SYSTEM',
YearFirst = 'YEAR_FIRST'
}

/** Time time as Military, Standard or system as default */
/** Time time as Military, Standard or browser as default */
export enum WorkspaceMemberTimeFormatEnum {
Browser = 'BROWSER',
Hour_12 = 'HOUR_12',
Hour_24 = 'HOUR_24',
System = 'SYSTEM'
Hour_24 = 'HOUR_24'
}

export type Field = {
Expand Down
2 changes: 1 addition & 1 deletion packages/twenty-front/src/modules/auth/hooks/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const useAuth = () => {
// TODO: factorize with UserProviderEffect
setDateTimeFormat({
timeZone:
workspaceMember.timeZone && workspaceMember.timeZone !== 'system'
workspaceMember.timeZone && workspaceMember.timeZone !== 'browser'
? workspaceMember.timeZone
: detectTimeZone(),
dateFormat: isDefined(user.workspaceMember.dateFormat)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export enum DateFormat {
SYSTEM = 'SYSTEM',
BROWSER = 'BROWSER',
MONTH_FIRST = 'MMM d, yyyy', // US
DAY_FIRST = 'd MMM, yyyy', // UK
YEAR_FIRST = 'yyyy MMM d',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export enum TimeFormat {
SYSTEM = 'SYSTEM',
BROWSER = 'SYSTEM',
HOUR_24 = 'HH:mm',
HOUR_12 = 'h:mm aa',
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const getDateFormatFromWorkspaceDateFormat = (
workspaceDateFormat: WorkspaceMemberDateFormatEnum,
) => {
switch (workspaceDateFormat) {
case WorkspaceMemberDateFormatEnum.System:
case WorkspaceMemberDateFormatEnum.Browser:
return detectDateFormat();
case WorkspaceMemberDateFormatEnum.MonthFirst:
return DateFormat.MONTH_FIRST;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const getTimeFormatFromWorkspaceTimeFormat = (
workspaceTimeFormat: WorkspaceMemberTimeFormatEnum,
) => {
switch (workspaceTimeFormat) {
case WorkspaceMemberTimeFormatEnum.System:
case WorkspaceMemberTimeFormatEnum.Browser:
return detectTimeFormat();
case WorkspaceMemberTimeFormatEnum.Hour_24:
return TimeFormat.HOUR_24;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export const getWorkspaceDateFormatFromDateFormat = (
dateFormat: DateFormat,
) => {
switch (dateFormat) {
case DateFormat.SYSTEM:
return WorkspaceMemberDateFormatEnum.System;
case DateFormat.BROWSER:
return WorkspaceMemberDateFormatEnum.Browser;
case DateFormat.MONTH_FIRST:
return WorkspaceMemberDateFormatEnum.MonthFirst;
case DateFormat.DAY_FIRST:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export const getWorkspaceTimeFormatFromTimeFormat = (
timeFormat: TimeFormat,
) => {
switch (timeFormat) {
case TimeFormat.SYSTEM:
return WorkspaceMemberTimeFormatEnum.System;
case TimeFormat.BROWSER:
return WorkspaceMemberTimeFormatEnum.Browser;
case TimeFormat.HOUR_24:
return WorkspaceMemberTimeFormatEnum.Hour_24;
case TimeFormat.HOUR_12:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const UserProviderEffect = () => {
// TODO: factorize
setDateTimeFormat({
timeZone:
workspaceMember.timeZone && workspaceMember.timeZone !== 'system'
workspaceMember.timeZone && workspaceMember.timeZone !== 'browser'
? workspaceMember.timeZone
: detectTimeZone(),
dateFormat: isDefined(workspaceMember.dateFormat)
Expand Down Expand Up @@ -87,6 +87,7 @@ export const UserProviderEffect = () => {
setWorkspaces,
queryData?.currentUser,
setIsCurrentUserLoaded,
setDateTimeFormat,
]);

return <></>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ export const DateTimeSettings = () => {
switch (settingName) {
case 'timeZone': {
workspaceMember[settingName] = value;
dateTime[settingName] = value === 'system' ? detectTimeZone() : value;
dateTime[settingName] = value === 'browser' ? detectTimeZone() : value;
break;
}
case 'dateFormat': {
workspaceMember[settingName] = getWorkspaceDateFormatFromDateFormat(
value as DateFormat,
);
dateTime[settingName] =
(value as DateFormat) === DateFormat.SYSTEM
(value as DateFormat) === DateFormat.BROWSER
? detectDateFormat()
: (value as DateFormat);
break;
Expand All @@ -86,7 +86,7 @@ export const DateTimeSettings = () => {
value as TimeFormat,
);
dateTime[settingName] =
(value as TimeFormat) === TimeFormat.SYSTEM
(value as TimeFormat) === TimeFormat.BROWSER
? detectTimeFormat()
: (value as TimeFormat);
break;
Expand All @@ -110,18 +110,18 @@ export const DateTimeSettings = () => {
};

const timeZone =
currentWorkspaceMember.timeZone === 'system'
? 'system'
currentWorkspaceMember.timeZone === 'browser'
? 'browser'
: dateTimeFormat.timeZone;

const dateFormat =
currentWorkspaceMember.dateFormat === WorkspaceMemberDateFormatEnum.System
? DateFormat.SYSTEM
currentWorkspaceMember.dateFormat === WorkspaceMemberDateFormatEnum.Browser
? DateFormat.BROWSER
: dateTimeFormat.dateFormat;

const timeFormat =
currentWorkspaceMember.timeFormat === WorkspaceMemberTimeFormatEnum.System
? TimeFormat.SYSTEM
currentWorkspaceMember.timeFormat === WorkspaceMemberTimeFormatEnum.Browser
? TimeFormat.BROWSER
: dateTimeFormat.timeFormat;

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const DateTimeSettingsDateFormatSelect = ({
timeZone,
value,
}: DateTimeSettingsDateFormatSelectProps) => {
const setTimeZone = timeZone === 'system' ? detectTimeZone() : timeZone;
const setTimeZone = timeZone === 'browser' ? detectTimeZone() : timeZone;
return (
<Select
dropdownId="datetime-settings-date-format"
Expand All @@ -25,8 +25,8 @@ export const DateTimeSettingsDateFormatSelect = ({
value={value}
options={[
{
label: `System settings`,
value: DateFormat.SYSTEM,
label: `Browser settings`,
value: DateFormat.BROWSER,
},
{
label: `${formatInTimeZone(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const DateTimeSettingsTimeFormatSelect = ({
timeZone,
value,
}: DateTimeSettingsTimeFormatSelectProps) => {
const setTimeZone = timeZone === 'system' ? detectTimeZone() : timeZone;
const setTimeZone = timeZone === 'browser' ? detectTimeZone() : timeZone;
return (
<Select
dropdownId="datetime-settings-time-format"
Expand All @@ -26,7 +26,7 @@ export const DateTimeSettingsTimeFormatSelect = ({
options={[
{
label: 'System settings',
value: TimeFormat.SYSTEM,
value: TimeFormat.BROWSER,
},
{
label: `24h (${formatInTimeZone(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export const DateTimeSettingsTimeZoneSelect = ({
label="Time zone"
fullWidth
value={
value === 'system'
? 'System settings'
value === 'browser'
? 'Browser settings'
: findAvailableTimeZoneOption(value)?.value
}
options={[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,27 @@ import { AuditLogWorkspaceEntity } from 'src/modules/timeline/standard-objects/a
import { TimelineActivityWorkspaceEntity } from 'src/modules/timeline/standard-objects/timeline-activity.workspace-entity';

export enum WorkspaceMemberDateFormatEnum {
SYSTEM = 'SYSTEM',
BROWSER = 'BROWSER',
MONTH_FIRST = 'MONTH_FIRST',
DAY_FIRST = 'DAY_FIRST',
YEAR_FIRST = 'YEAR_FIRST',
}

export enum WorkspaceMemberTimeFormatEnum {
SYSTEM = 'SYSTEM',
BROWSER = 'BROWSER',
HOUR_12 = 'HOUR_12',
HOUR_24 = 'HOUR_24',
}

registerEnumType(WorkspaceMemberTimeFormatEnum, {
name: 'WorkspaceMemberTimeFormatEnum',
description: 'Time time as Military, Standard or system as default',
description: 'Time time as Military, Standard or browser as default',
});

registerEnumType(WorkspaceMemberDateFormatEnum, {
name: 'WorkspaceMemberDateFormatEnum',
description:
'Date format as Month first, Day first, Year first or system as default',
'Date format as Month first, Day first, Year first or browser as default',
});

@WorkspaceEntity({
Expand Down Expand Up @@ -273,7 +273,7 @@ export class WorkspaceMemberWorkspaceEntity extends BaseWorkspaceEntity {
standardId: WORKSPACE_MEMBER_STANDARD_FIELD_IDS.timeZone,
type: FieldMetadataType.TEXT,
label: 'Time zone',
defaultValue: "'system'",
defaultValue: "'browser'",
description: 'User time zone',
icon: 'IconTimezone',
})
Expand All @@ -287,8 +287,8 @@ export class WorkspaceMemberWorkspaceEntity extends BaseWorkspaceEntity {
icon: 'IconCalendarEvent',
options: [
{
value: WorkspaceMemberDateFormatEnum.SYSTEM,
label: 'System',
value: WorkspaceMemberDateFormatEnum.BROWSER,
label: 'Browser',
position: 0,
color: 'turquoise',
},
Expand All @@ -311,7 +311,7 @@ export class WorkspaceMemberWorkspaceEntity extends BaseWorkspaceEntity {
color: 'sky',
},
],
defaultValue: `'${WorkspaceMemberDateFormatEnum.SYSTEM}'`,
defaultValue: `'${WorkspaceMemberDateFormatEnum.BROWSER}'`,
})
dateFormat: string;

Expand All @@ -323,8 +323,8 @@ export class WorkspaceMemberWorkspaceEntity extends BaseWorkspaceEntity {
icon: 'IconClock2',
options: [
{
value: WorkspaceMemberTimeFormatEnum.SYSTEM,
label: 'System',
value: WorkspaceMemberTimeFormatEnum.BROWSER,
label: 'Browser',
position: 0,
color: 'sky',
},
Expand All @@ -341,7 +341,7 @@ export class WorkspaceMemberWorkspaceEntity extends BaseWorkspaceEntity {
color: 'purple',
},
],
defaultValue: `'${WorkspaceMemberTimeFormatEnum.SYSTEM}'`,
defaultValue: `'${WorkspaceMemberTimeFormatEnum.BROWSER}'`,
})
timeFormat: string;
}

0 comments on commit 26efbf2

Please sign in to comment.