Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove all avatar/logo references #14532

Merged
merged 39 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
61f51e7
chore: Remove all avatar/logo references
emrysal Apr 11, 2024
08b1cff
Updated user profile to only use avatarUrl
emrysal Apr 11, 2024
dad51c2
fix: minor style issue
emrysal Apr 11, 2024
f7b987b
Merge branch 'main' into chore/remove-logo-and-avatar-references
emrysal Apr 12, 2024
7c50b72
Merge branch 'main' into chore/remove-logo-and-avatar-references
emrysal Apr 12, 2024
8947d44
chore: Remove redundant includeTeamLogo
emrysal Apr 15, 2024
5792cdf
fix: Use right avatar default in event type list
emrysal Apr 15, 2024
fc3463f
fix: placeholder avatar team profile, target
emrysal Apr 15, 2024
270c66a
chore: Add logoUrl/avatarUrl to JWT
emrysal Apr 15, 2024
efeeb0f
fix: Bunch of org avatar issues, fix members list
emrysal Apr 15, 2024
6d75fdb
Merge branch 'main' into chore/remove-logo-and-avatar-references
emrysal Apr 15, 2024
4313e52
Merge branch 'main' into chore/remove-logo-and-avatar-references
emrysal Apr 15, 2024
2a9caa7
Fix logoUrl on org pages
emrysal Apr 15, 2024
2790596
More type fixes
emrysal Apr 15, 2024
6bb9c45
Hopefully final type fixes
emrysal Apr 15, 2024
f603d1a
Another round of type fixes
emrysal Apr 15, 2024
e17ffc6
fix: UserForm ts
emrysal Apr 15, 2024
0e274d2
fix: Handle as return types, not input types
emrysal Apr 15, 2024
12f656f
fix: Remove profile and add avatarUrl
emrysal Apr 15, 2024
59c9be2
fix: notFound as const
emrysal Apr 15, 2024
813b401
fix: Seeder avatarUrl params
emrysal Apr 15, 2024
ea7fc59
Merge branch 'main' into chore/remove-logo-and-avatar-references
emrysal Apr 15, 2024
392349d
revert: Migration changes for easier recovery
emrysal Apr 15, 2024
e27b735
Merge branch 'chore/remove-logo-and-avatar-references' of github.com:…
emrysal Apr 15, 2024
0d09082
fix: Add explicit type to builder as avatar is now set
emrysal Apr 15, 2024
d025202
Add logoUrl to unpublished entity
emrysal Apr 16, 2024
ea98519
Merge branch 'main' into chore/remove-logo-and-avatar-references
emrysal Apr 16, 2024
7ec30c8
Avatar test out of scope here
emrysal Apr 16, 2024
e121dc9
Merge branch 'main' into chore/remove-logo-and-avatar-references
emrysal Apr 16, 2024
65caa33
fix: Use the new avatarUrl after save
emrysal Apr 16, 2024
84e4ab4
Merge branch 'chore/remove-logo-and-avatar-references' of github.com:…
emrysal Apr 16, 2024
78f78bd
chore: Removed getOrgAvatarUrl/getTeamAvatarUrl
emrysal Apr 16, 2024
23cbb34
Merge branch 'main' into chore/remove-logo-and-avatar-references
emrysal Apr 18, 2024
5ef2e43
fix: Update sidebar image immediately after change
emrysal Apr 18, 2024
a4e8fe7
Merge branch 'main' into chore/remove-logo-and-avatar-references
emrysal Apr 18, 2024
4460dad
Unable to safe unnamed user, so default
emrysal Apr 18, 2024
2451ae2
fix: Unpublished page, add organization test
emrysal Apr 18, 2024
269bd85
Merge branch 'main' into chore/remove-logo-and-avatar-references
emrysal Apr 18, 2024
d51aad9
Add more tests
emrysal Apr 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/web/components/apps/AppList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const AppList = ({ data, handleDisconnect, variant, listClassName }: AppL
...app,
credentialOwner: {
name: team.name,
avatar: team.logo,
avatar: team.logoUrl,
teamId: team.teamId,
credentialId: team.credentialId,
readOnly: !team.isAdmin,
Expand Down
6 changes: 3 additions & 3 deletions apps/web/components/apps/InstallAppButtonChild.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import useAddAppMutation from "@calcom/app-store/_utils/useAddAppMutation";
import { doesAppSupportTeamInstall } from "@calcom/app-store/utils";
import { Spinner } from "@calcom/features/calendars/weeklyview/components/spinner/Spinner";
import type { UserAdminTeams } from "@calcom/features/ee/teams/lib/getUserAdminTeams";
import { WEBAPP_URL } from "@calcom/lib/constants";
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { RouterOutputs } from "@calcom/trpc/react";
import type { AppFrontendPayload } from "@calcom/types/App";
Expand Down Expand Up @@ -124,8 +124,8 @@ export const InstallAppButtonChild = ({
disabled={isInstalled}
CustomStartIcon={
<Avatar
alt={team.logo || ""}
imageSrc={team.logo || `${WEBAPP_URL}/${team.logo}/avatar.png`} // if no image, use default avatar
alt={team.logoUrl || ""}
imageSrc={getPlaceholderAvatar(team.logoUrl, team.name)} // if no image, use default avatar
size="sm"
/>
}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/eventtype/EventAppsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const EventAppsTab = ({ eventType }: { eventType: EventType }) => {
// credentialIds: team?.credentialId ? [team.credentialId] : [],
credentialOwner: {
name: team.name,
avatar: team.logo,
avatar: team.logoUrl,
teamId: team.teamId,
credentialId: team.credentialId,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const UserProfile = () => {

const mutation = trpc.viewer.updateProfile.useMutation({
onSuccess: async (_data, context) => {
if (context.avatar) {
if (context.avatarUrl) {
showToast(t("your_user_profile_updated_successfully"), "success");
await utils.viewer.me.refetch();
} else
Expand Down Expand Up @@ -74,7 +74,7 @@ const UserProfile = () => {
event.preventDefault();
const enteredAvatar = avatarRef.current?.value;
mutation.mutate({
avatar: enteredAvatar,
avatarUrl: enteredAvatar,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
select: {
id: true,
name: true,
logo: true,
logoUrl: true,
},
},
},
Expand Down
1 change: 1 addition & 0 deletions apps/web/lib/team/[slug]/getServerSideProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
isPrivate: true,
isOrganization: true,
metadata: true,
logoUrl: true,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type UserPageProps = {
markdownStrippedBio: string;
safeBio: string;
entity: {
logoUrl?: string | null;
considerUnpublished: boolean;
orgSlug?: string | null;
name?: string | null;
Expand Down Expand Up @@ -98,12 +99,7 @@ export const getServerSideProps: GetServerSideProps<UserPageProps> = async (cont
orgSlug: isValidOrgDomain ? currentOrgDomain : null,
});

const usersWithoutAvatar = usersInOrgContext.map((user) => {
const { avatar: _1, ...rest } = user;
return rest;
});

const isDynamicGroup = usersWithoutAvatar.length > 1;
const isDynamicGroup = usersInOrgContext.length > 1;
log.debug(safeStringify({ usersInOrgContext, isValidOrgDomain, currentOrgDomain, isDynamicGroup }));

if (isDynamicGroup) {
Expand All @@ -114,40 +110,27 @@ export const getServerSideProps: GetServerSideProps<UserPageProps> = async (cont
permanent: false,
destination: destinationUrl,
},
} as {
redirect: {
permanent: false;
destination: string;
};
};
} as const;
}

const users = usersWithoutAvatar.map((user) => ({
...user,
avatar: `/${user.username}/avatar.png`,
}));

const isNonOrgUser = (user: { profile: UserProfile }) => {
return !user.profile?.organization;
};

const isThereAnyNonOrgUser = users.some(isNonOrgUser);
const isThereAnyNonOrgUser = usersInOrgContext.some(isNonOrgUser);

if (!users.length || (!isValidOrgDomain && !isThereAnyNonOrgUser)) {
if (!usersInOrgContext.length || (!isValidOrgDomain && !isThereAnyNonOrgUser)) {
return {
notFound: true,
} as {
notFound: true;
};
} as const;
}

const [user] = users; //to be used when dealing with single user, not dynamic group
const [user] = usersInOrgContext; //to be used when dealing with single user, not dynamic group

const profile = {
name: user.name || user.username || "",
image: getUserAvatarUrl({
...user,
profile: user.profile,
avatarUrl: user.avatarUrl,
}),
theme: user.theme,
brandColor: user.brandColor ?? DEFAULT_LIGHT_BRAND_COLOR,
Expand Down Expand Up @@ -183,11 +166,11 @@ export const getServerSideProps: GetServerSideProps<UserPageProps> = async (cont
const safeBio = markdownToSafeHTML(user.bio) || "";

const markdownStrippedBio = stripMarkdown(user?.bio || "");
const org = usersWithoutAvatar[0].profile.organization;
const org = usersInOrgContext[0].profile.organization;

return {
props: {
users: users.map((user) => ({
users: usersInOrgContext.map((user) => ({
name: user.name,
username: user.username,
bio: user.bio,
Expand All @@ -197,6 +180,7 @@ export const getServerSideProps: GetServerSideProps<UserPageProps> = async (cont
away: user.away,
})),
entity: {
...(org?.logoUrl ? { logoUrl: org?.logoUrl } : {}),
considerUnpublished: !isARedirectFromNonOrgLink && org?.slug === null,
orgSlug: currentOrgDomain,
name: org?.name ?? null,
Expand Down
4 changes: 0 additions & 4 deletions apps/web/modules/users/views/users-public-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import classNames from "classnames";
import type { InferGetServerSidePropsType } from "next";
import Link from "next/link";
import { useSearchParams } from "next/navigation";
import { Toaster } from "react-hot-toast";

import {
Expand All @@ -23,7 +22,6 @@ import { type getServerSideProps } from "./users-public-view.getServerSideProps"

export function UserPage(props: InferGetServerSidePropsType<typeof getServerSideProps>) {
const { users, profile, eventTypes, markdownStrippedBio, entity } = props;
const searchParams = useSearchParams();

const [user] = users; //To be used when we only have a single user, not dynamic group
useTheme(profile.theme);
Expand All @@ -43,8 +41,6 @@ export function UserPage(props: InferGetServerSidePropsType<typeof getServerSide
...query
} = useRouterQuery();

const isRedirect = searchParams?.get("redirected") === "true" || false;
const fromUserNameRedirected = searchParams?.get("username") || "";
/*
const telemetry = useTelemetry();
useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/pages/api/cron/monthlyDigestEmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
in: userIds as number[],
},
},
select: { id: true, name: true, email: true, avatar: true, username: true },
select: { id: true, name: true, email: true, avatarUrl: true, username: true },
});

const userHashMap = new Map();
Expand Down
154 changes: 0 additions & 154 deletions apps/web/pages/api/user/avatar.ts

This file was deleted.