Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.
PHP ai-agentsblueskyfacebookinstagramlaravellinkedinmastodonmcpmcp-serveropen-sourcerest-apiself-hostedsocial-mediasocial-media-managementsocial-media-schedulerthreadstiktokvuejsxyoutube
Hide TikTok and Pinterest content type badges on post cards (#392)
Paulo Castellano403cf52d7fe1
diff --git a/resources/js/composables/usePlatformLogo.ts b/resources/js/composables/usePlatformLogo.tsindex 4250b46f6..39a059176 100644--- a/resources/js/composables/usePlatformLogo.ts+++ b/resources/js/composables/usePlatformLogo.ts@@ -58,6 +58,13 @@ const PLATFORM_CONTENT_TYPES: Record<string, string[]> = {google_business: ['google_business_post'],};+const PLATFORM_CONTENT_TYPE_BADGES: Record<string, string[]> = {+ instagram: ['instagram_reel', 'instagram_story'],+ 'instagram-facebook': ['instagram_reel', 'instagram_story'],+ facebook: ['facebook_reel', 'facebook_story'],+ threads: ['threads_ghost_post'],+};+export interface ContentTypeOption {value: string;labelKey: string;@@ -101,11 +108,11 @@ export const getPickableContentTypeOptions = (export const hasMultipleContentTypes = (platform: string): boolean =>getContentTypeOptions(platform).length > 1;-/**- * Translation key for the badge that names a published format, or null for a- * platform's default format: tagging a regular post would just add noise.- */-export const getContentTypeBadgeKey = (platform: string, contentType: string | null): string | null =>- contentType && hasMultipleContentTypes(platform) && contentType !== PLATFORM_CONTENT_TYPES[platform]?.[0]+/** Translation key for a format explicitly shown as a badge on post cards. */+export const getContentTypeBadgeKey = (+ platform: string,+ contentType: string | null,+): string | null =>+ contentType && PLATFORM_CONTENT_TYPE_BADGES[platform]?.includes(contentType)? translationKeyFor(contentType): null;diff --git a/tests/Browser/ImportedPostCardTest.php b/tests/Browser/ImportedPostCardTest.phpindex 24576ada8..38c1b3b32 100644--- a/tests/Browser/ImportedPostCardTest.php+++ b/tests/Browser/ImportedPostCardTest.php@@ -167,6 +167,68 @@ test('an imported sent card looks like a sent post and offers only the allowed a$page->assertNoJavaScriptErrors();});+test('content type badges follow the display rules for each platform', function (Platform $platform, array $formats) {+ [$user, $workspace] = importedCardSetup();+ $account = SocialAccount::factory()->create([+ 'workspace_id' => $workspace->id,+ 'platform' => $platform,+ ]);+ $expectations = [];++ foreach ($formats as [$contentType, $showsBadge]) {+ $post = Post::factory()->published()->create([+ 'workspace_id' => $workspace->id,+ 'user_id' => $user->id,+ ]);+ PostPlatform::factory()->published()->create([+ 'post_id' => $post->id,+ 'social_account_id' => $account->id,+ 'platform' => $platform,+ 'content_type' => $contentType,+ ]);+ $expectations[] = [$post, $contentType, $showsBadge];+ }++ $this->actingAs($user);+ $page = visit(route('app.posts.index', ['tab' => 'sent']));++ foreach ($expectations as [$post, $contentType, $showsBadge]) {+ waitForImportedCardTestId($page, "post-card-{$post->id}");+ $page->assertPresent("@post-card-{$post->id}");++ if ($showsBadge) {+ $page->assertSeeIn("@post-content-type-{$post->id}", __("posts.content_types.{$contentType->value}.label"));+ } else {+ $page->assertMissing("@post-content-type-{$post->id}");+ }+ }++ $page->assertNoJavaScriptErrors();+})->with([+ 'Instagram via Facebook' => [Platform::InstagramFacebook, [+ [ContentType::InstagramFeed, false],+ [ContentType::InstagramReel, true],+ [ContentType::InstagramStory, true],+ ]],+ 'Facebook' => [Platform::Facebook, [+ [ContentType::FacebookPost, false],+ [ContentType::FacebookReel, true],+ [ContentType::FacebookStory, true],+ ]],+ 'Threads' => [Platform::Threads, [+ [ContentType::ThreadsPost, false],+ [ContentType::ThreadsGhostPost, true],+ ]],+ 'Pinterest' => [Platform::Pinterest, [+ [ContentType::PinterestPin, false],+ [ContentType::PinterestVideoPin, false],+ [ContentType::PinterestCarousel, false],+ ]],+ 'YouTube' => [Platform::YouTube, [[ContentType::YouTubeShort, false]]],+ 'LinkedIn' => [Platform::LinkedIn, [[ContentType::LinkedInPost, false]]],+ 'X' => [Platform::X, [[ContentType::XPost, false]]],+]);+test('on a phone an imported sent card hides the published via line and right-aligns its actions', function () {[$user, $workspace, $account] = importedCardSetup();$post = importedCardPost($workspace, $account);@@ -294,13 +356,29 @@ test('a draft shows no metrics band in its details', function () {->assertNoJavaScriptErrors();});-test('the content type badge has an icon for stories and reels and is hidden for a regular post', function () {+test('the content type badge has an icon for stories and reels and is hidden for regular posts and TikTok', function () {[$user, $workspace, $account] = importedCardSetup();$expectations = [[importedCardPost($workspace, $account, ContentType::InstagramStory), 'posts.content_types.instagram_story.label'],[importedCardPost($workspace, $account, ContentType::InstagramReel), 'posts.content_types.instagram_reel.label'],[importedCardPost($workspace, $account, ContentType::InstagramFeed), null],];+ $tiktok = SocialAccount::factory()->tiktok()->create(['workspace_id' => $workspace->id]);++ foreach ([ContentType::TikTokPhoto, ContentType::TikTokVideo] as $contentType) {+ $post = Post::factory()->published()->create([+ 'workspace_id' => $workspace->id,+ 'user_id' => $user->id,+ ]);+ PostPlatform::factory()->published()->create([+ 'post_id' => $post->id,+ 'social_account_id' => $tiktok->id,+ 'platform' => Platform::TikTok,+ 'content_type' => $contentType,+ ]);+ $expectations[] = [$post, null];+ }+$this->actingAs($user);$page = visit(route('app.posts.index', ['tab' => 'sent']));