Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bufferapp/analyze-profile-selector

Package Overview
Dependencies
Maintainers
31
Versions
210
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bufferapp/analyze-profile-selector - npm Package Compare versions

Comparing version 1.77.4 to 2.0.0-beta-10

types/index.d.ts

76

components/ProfileSelectorDropdown/index.jsx

@@ -1,11 +0,11 @@

import React from "react";
import PropTypes from "prop-types";
import styled from "styled-components";
import { ProfileBadge } from "@bufferapp/analyze-shared-components";
import { Text } from "@bufferapp/components";
import Select from "@bufferapp/ui/Select";
import ChevronDown from "@bufferapp/ui/Icon/Icons/ChevronDown";
import { white, grayDark, grayDarker } from "@bufferapp/ui/style/colors";
import { fontFamily, lineHeight } from "@bufferapp/ui/style/fonts";
import reactDOM from "react-dom/server";
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { ProfileBadge } from '@bufferapp/analyze-shared-components';
import { Text } from '@bufferapp/components';
import Select from '@bufferapp/ui/Select';
import ChevronDown from '@bufferapp/ui/Icon/Icons/ChevronDown';
import { white, grayDark, grayDarker } from '@bufferapp/ui/style/colors';
import { fontFamily, lineHeight } from '@bufferapp/ui/style/fonts';
import reactDOM from 'react-dom/server';

@@ -60,5 +60,5 @@ const ButtonContainer = styled.div`

const { selectedProfileId, profiles } = this.props;
const selectedProfile = profiles.find((p) => p.id === selectedProfileId);
const selectedProfile = profiles.find(p => p.id === selectedProfileId);
let content = (
const content = (
<React.Fragment>

@@ -89,26 +89,22 @@ <LabelContainer>

filterProfilesByService(profiles, service) {
return profiles.filter((p) => p.service === service);
return profiles.filter(p => p.service === service);
}
formatProfiles(profiles) {
return profiles.map((profile) => {
return {
...profile,
disabled:
return profiles.map(profile => ({
...profile,
disabled:
profile.id === this.props.selectedProfileId ||
profile.service === this.props.disableNetwork,
selected: profile.id === this.props.selectedProfileId,
onItemClick: () => this.props.selectProfile(profile),
component: () => {
return reactDOM.renderToStaticMarkup(
<ProfileBadge
avatarUrl={profile.avatarUrl}
service={profile.service}
avatarSize={24}
socialIconSize={14}
/>
);
},
};
});
selected: profile.id === this.props.selectedProfileId,
onItemClick: () => this.props.selectProfile(profile),
component: () => reactDOM.renderToStaticMarkup(
<ProfileBadge
avatarUrl={profile.avatarUrl}
service={profile.service}
avatarSize={24}
socialIconSize={14}
/>,
),
}));
}

@@ -119,3 +115,3 @@

const selectedProfile = profiles.find((p) => p.id === selectedProfileId);
const selectedProfile = profiles.find(p => p.id === selectedProfileId);

@@ -127,4 +123,4 @@ let filteredProfiles;

profiles,
selectedProfile.service
).filter((p) => p.username.toLowerCase().match(profilesFilterString));
selectedProfile.service,
).filter(p => p.username.toLowerCase().match(profilesFilterString));
}

@@ -139,6 +135,6 @@

return (
<div style={{ width: "480px" }}>
<div style={{ width: '480px' }}>
<Select
onSelectClick={(selectedItem) => selectedItem.onItemClick()}
customButton={(onButtonClick) => this.renderButton(onButtonClick)}
onSelectClick={selectedItem => selectedItem.onItemClick()}
customButton={onButtonClick => this.renderButton(onButtonClick)}
label="Search Me"

@@ -149,4 +145,4 @@ onSearchChange={() => true}

keyMap={{
id: "id",
title: "username",
id: 'id',
title: 'username',
}}

@@ -170,3 +166,3 @@ items={formattedProfiles}

avatarUrl: PropTypes.string.isRequired,
})
}),
).isRequired,

@@ -173,0 +169,0 @@ selectProfile: PropTypes.func.isRequired,

import React from 'react';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
import configureMockStore from 'redux-mock-store';

@@ -5,0 +5,0 @@

import { push, LOCATION_CHANGE } from 'connected-react-router';
import { actions as fetchActions, actionTypes } from '@bufferapp/async-data-fetch';
import { actions as analyticsActions } from '@bufferapp/analytics-middleware';
import { isBackfilling, isEmpty } from '@bufferapp/analyze-shared-components/utils';
import { actions as profilesActions, actionTypes as profileActionTypes, getAllProfilesFromResult } from './reducer';
import { isBackfilling, isEmpty } from "@bufferapp/analyze-shared-components/utils";

@@ -98,7 +98,7 @@ const PROFILE_PAGES_PATH_REGEX = /^(.*)\/(.*)\/(.+$)/;

fetchActions.fetch({
name: "lastUpdated",
name: 'lastUpdated',
args: {
serviceIds: profiles.map((p) => p.serviceId),
serviceIds: profiles.map(p => p.serviceId),
},
})
}),
);

@@ -162,3 +162,3 @@ }

let channel = null;
let organizationId = getState().profiles.organizationId;
const organizationId = getState().profiles.organizationId;
let channelId = null;

@@ -165,0 +165,0 @@ let channelServiceId = null;

import {
actions as fetchActions,
actionTypes,
} from "@bufferapp/async-data-fetch";
import { actions as analyticsActions } from "@bufferapp/analytics-middleware";
import { push, LOCATION_CHANGE } from "react-router-redux";
} from '@bufferapp/async-data-fetch';
import { actions as analyticsActions } from '@bufferapp/analytics-middleware';
import { push, LOCATION_CHANGE } from 'react-router-redux';
import {
actionTypes as profileActionTypes,
actions as profilesActions,
} from "./reducer";
import middleware from "./middleware";
} from './reducer';
import middleware from './middleware';
import dayjs from 'dayjs';
const profileId = "120351988a";
const profileService = "facebook";
const profileId = '120351988a';
const profileService = 'facebook';
const navigationStart = dayjs().subtract(5, "minutes").unix() * 1000;
const navigationStart = dayjs().subtract(5, 'minutes').unix() * 1000;
global.performance = {

@@ -28,27 +28,27 @@ timing: {

{
id: "120351988a",
id: '120351988a',
avatarUrl:
"http://pbs.twimg.com/profile_images/711360318262218752/wdl3jY5t_normal.jpg",
service: "twitter",
timezone: "America/Los_Angeles",
username: "buffer",
serviceId: "120351988a_123"
'http://pbs.twimg.com/profile_images/711360318262218752/wdl3jY5t_normal.jpg',
service: 'twitter',
timezone: 'America/Los_Angeles',
username: 'buffer',
serviceId: '120351988a_123',
},
{
id: "122222222",
id: '122222222',
avatarUrl:
"http://pbs.twimg.com/profile_images/711360318262218752/wdl3jY5t_normal.jpg",
service: "facebook",
timezone: "America/Los_Angeles",
username: "buffer",
serviceId: "122222222_123",
'http://pbs.twimg.com/profile_images/711360318262218752/wdl3jY5t_normal.jpg',
service: 'facebook',
timezone: 'America/Los_Angeles',
username: 'buffer',
serviceId: '122222222_123',
},
{
id: "122222252",
id: '122222252',
avatarUrl:
"http://pbs.twimg.com/profile_images/711360318262218752/wdl3jY5t_normal.jpg",
service: "shopify",
timezone: "America/Los_Angeles",
username: "buffer",
serviceId: "122222252_123",
'http://pbs.twimg.com/profile_images/711360318262218752/wdl3jY5t_normal.jpg',
service: 'shopify',
timezone: 'America/Los_Angeles',
username: 'buffer',
serviceId: '122222252_123',
},

@@ -58,18 +58,18 @@ ],

{
id: "120351988a",
id: '120351988a',
avatarUrl:
"http://pbs.twimg.com/profile_images/711360318262218752/wdl3jY5t_normal.jpg",
service: "twitter",
timezone: "America/Los_Angeles",
username: "buffer",
serviceId: "120351988a_123",
'http://pbs.twimg.com/profile_images/711360318262218752/wdl3jY5t_normal.jpg',
service: 'twitter',
timezone: 'America/Los_Angeles',
username: 'buffer',
serviceId: '120351988a_123',
},
{
id: "122222222",
id: '122222222',
avatarUrl:
"http://pbs.twimg.com/profile_images/711360318262218752/wdl3jY5t_normal.jpg",
service: "facebook",
timezone: "America/Los_Angeles",
username: "buffer",
serviceId: "122222222_123"
'http://pbs.twimg.com/profile_images/711360318262218752/wdl3jY5t_normal.jpg',
service: 'facebook',
timezone: 'America/Los_Angeles',
username: 'buffer',
serviceId: '122222222_123',
},

@@ -79,9 +79,9 @@ ],

{
id: "122222252",
id: '122222252',
avatarUrl:
"http://pbs.twimg.com/profile_images/711360318262218752/wdl3jY5t_normal.jpg",
service: "shopify",
timezone: "America/Los_Angeles",
username: "buffer",
serviceId: "122222252_123"
'http://pbs.twimg.com/profile_images/711360318262218752/wdl3jY5t_normal.jpg',
service: 'shopify',
timezone: 'America/Los_Angeles',
username: 'buffer',
serviceId: '122222252_123',
},

@@ -94,18 +94,18 @@ ],

{
id: "120351988a",
id: '120351988a',
avatarUrl:
"http://pbs.twimg.com/profile_images/711360318262218752/wdl3jY5t_normal.jpg",
service: "twitter",
timezone: "America/Los_Angeles",
username: "buffer",
serviceId: "120351988a_123"
'http://pbs.twimg.com/profile_images/711360318262218752/wdl3jY5t_normal.jpg',
service: 'twitter',
timezone: 'America/Los_Angeles',
username: 'buffer',
serviceId: '120351988a_123',
},
{
id: "122222222",
id: '122222222',
avatarUrl:
"http://pbs.twimg.com/profile_images/711360318262218752/wdl3jY5t_normal.jpg",
service: "facebook",
timezone: "America/Los_Angeles",
username: "buffer",
serviceId: "122222222_123"
'http://pbs.twimg.com/profile_images/711360318262218752/wdl3jY5t_normal.jpg',
service: 'facebook',
timezone: 'America/Los_Angeles',
username: 'buffer',
serviceId: '122222222_123',
},

@@ -115,9 +115,9 @@ ],

{
id: "122222252",
id: '122222252',
avatarUrl:
"http://pbs.twimg.com/profile_images/711360318262218752/wdl3jY5t_normal.jpg",
service: "shopify",
timezone: "America/Los_Angeles",
username: "buffer",
serviceId: "122222252_123"
'http://pbs.twimg.com/profile_images/711360318262218752/wdl3jY5t_normal.jpg',
service: 'shopify',
timezone: 'America/Los_Angeles',
username: 'buffer',
serviceId: '122222252_123',
},

@@ -147,3 +147,3 @@ ],

location: {
pathname: "/",
pathname: '/',
},

@@ -160,15 +160,15 @@ },

const next = jest.fn();
const invoke = (action) => middleware(store)(next)(action);
const invoke = action => middleware(store)(next)(action);
return { store, next, invoke };
};
describe("middleware", () => {
it("should exist", () => {
describe('middleware', () => {
it('should exist', () => {
expect(middleware).toBeDefined();
});
it("should keep propagating the action through the chain", () => {
it('should keep propagating the action through the chain', () => {
const { next, invoke } = getMiddlewareElements();
const action = {
type: "TEST",
type: 'TEST',
};

@@ -179,3 +179,3 @@ invoke(action);

it("should select a profile after fetching all the profiles if the route contains a valid profileId", () => {
it('should select a profile after fetching all the profiles if the route contains a valid profileId', () => {
const { store, next, invoke } = getMiddlewareElements();

@@ -191,3 +191,3 @@ const action = {

it("should fetch lastUpdated for all profiles on profiles FETCH_SUCCESS", () => {
it('should fetch lastUpdated for all profiles on profiles FETCH_SUCCESS', () => {
const { store, next, invoke } = getMiddlewareElements();

@@ -201,7 +201,7 @@ const action = {

const lastUpdatedFetchAction = fetchActions.fetch({
name: "lastUpdated",
name: 'lastUpdated',
args: {
serviceIds: profilesResponse.social
.concat(profilesResponse.nonSocial)
.map((p) => p.serviceId),
.map(p => p.serviceId),
},

@@ -213,3 +213,3 @@ });

it.skip("should update current route whenever a profile has been selected", () => {
it.skip('should update current route whenever a profile has been selected', () => {
const { store, next, invoke } = getMiddlewareElements();

@@ -225,3 +225,3 @@ const action = {

expect(store.dispatch).toHaveBeenCalledWith(
push(`/${profileService}/overview/${profileId}`)
push(`/${profileService}/overview/${profileId}`),
);

@@ -231,5 +231,5 @@ expect(next).toHaveBeenCalledWith(action);

it("should not push a new route whenever a profile has been selected if current path does not contain a valid ProfileId", () => {
it('should not push a new route whenever a profile has been selected if current path does not contain a valid ProfileId', () => {
const { store, next, invoke } = getMiddlewareElements(
stateWithoutProfileRoute
stateWithoutProfileRoute,
);

@@ -244,3 +244,3 @@ const action = {

expect(store.dispatch).not.toHaveBeenCalledWith(
push(`/${profileService}/overview/${profileId}`)
push(`/${profileService}/overview/${profileId}`),
);

@@ -250,4 +250,4 @@ expect(next).toHaveBeenCalledWith(action);

describe("LOCATION_CHANGE", () => {
it.skip("should push a selectProfile action if there is a LOCATION_CHANGE with a valid profileId in the route and there is no profile selected", () => {
describe('LOCATION_CHANGE', () => {
it.skip('should push a selectProfile action if there is a LOCATION_CHANGE with a valid profileId in the route and there is no profile selected', () => {
const { store, next, invoke } = getMiddlewareElements();

@@ -264,3 +264,3 @@ const action = {

expect(store.dispatch).toHaveBeenCalledWith(
profilesActions.selectProfile(profiles.profiles[0], true)
profilesActions.selectProfile(profiles.profiles[0], true),
);

@@ -270,5 +270,5 @@ expect(next).toHaveBeenCalledWith(action);

it.skip("should push a selectProfile action if there is a LOCATION_CHANGE with a valid profileId in the route and selectedProfile is different", () => {
it.skip('should push a selectProfile action if there is a LOCATION_CHANGE with a valid profileId in the route and selectedProfile is different', () => {
const { store, next, invoke } = getMiddlewareElements(
stateWithProfileRouteAndSelectedProfile
stateWithProfileRouteAndSelectedProfile,
);

@@ -285,3 +285,3 @@ const action = {

expect(store.dispatch).toHaveBeenCalledWith(
profilesActions.selectProfile(profiles.profiles[1], true)
profilesActions.selectProfile(profiles.profiles[1], true),
);

@@ -291,5 +291,5 @@ expect(next).toHaveBeenCalledWith(action);

it("should select a profile when that is provided in the action payload", () => {
it('should select a profile when that is provided in the action payload', () => {
const { store, next, invoke } = getMiddlewareElements(
stateWithProfileRouteAndSelectedProfile
stateWithProfileRouteAndSelectedProfile,
);

@@ -300,3 +300,3 @@ const action = {

location: {
pathname: "/overview",
pathname: '/overview',
},

@@ -310,3 +310,3 @@ state: {

expect(store.dispatch).toHaveBeenCalledWith(
profilesActions.selectProfile(profiles.profiles[1])
profilesActions.selectProfile(profiles.profiles[1]),
);

@@ -316,7 +316,7 @@ expect(next).toHaveBeenCalledWith(action);

it("should track location changes with analytics-middleware", () => {
it('should track location changes with analytics-middleware', () => {
analyticsActions.pageChange = jest.fn();
const { next, invoke } = getMiddlewareElements(
stateWithProfileRouteAndSelectedProfile
stateWithProfileRouteAndSelectedProfile,
);

@@ -327,3 +327,3 @@ const action = {

location: {
pathname: "/aggregates/",
pathname: '/aggregates/',
},

@@ -337,7 +337,7 @@ },

channelServiceId: null,
name: "aggregates",
name: 'aggregates',
organizationId: undefined,
path: "/aggregates/",
title: "Buffer",
url: "/aggregates/",
path: '/aggregates/',
title: 'Buffer',
url: '/aggregates/',
});

@@ -348,5 +348,5 @@ expect(next).toHaveBeenCalledWith(action);

describe("Data updates notifications", () => {
describe('Data updates notifications', () => {
it('should fetch last updated after 5 seconds if backfilling', () => {
const twoDaysAgo = dayjs().subtract(2, "days").format();
const twoDaysAgo = dayjs().subtract(2, 'days').format();
jest.useFakeTimers();

@@ -358,3 +358,3 @@ const stateBackfilling = {

selectedProfile: profiles.profiles[0],
lastUpdated: twoDaysAgo
lastUpdated: twoDaysAgo,
},

@@ -385,3 +385,3 @@ };

it("should fetch last updated after 20 seconds if no data", () => {
it('should fetch last updated after 20 seconds if no data', () => {
jest.useFakeTimers();

@@ -393,3 +393,3 @@ const stateNoData = {

selectedProfile: profiles.profiles[0],
lastUpdated: {}
lastUpdated: {},
},

@@ -402,4 +402,4 @@ };

{
id: "5c93a6e8dcfa5a32015481d2",
serviceId: "17841400383014561",
id: '5c93a6e8dcfa5a32015481d2',
serviceId: '17841400383014561',
},

@@ -411,5 +411,5 @@ ],

const lastUpdatedFetchAction = fetchActions.fetch({
name: "lastUpdated",
name: 'lastUpdated',
args: {
serviceIds: profiles.profiles.map((p) => p.serviceId),
serviceIds: profiles.profiles.map(p => p.serviceId),
},

@@ -422,4 +422,4 @@ });

it("should fetch last updated after 5 minutes if old data", () => {
const twoHoursAgo = dayjs().subtract(2, "hours").format();
it('should fetch last updated after 5 minutes if old data', () => {
const twoHoursAgo = dayjs().subtract(2, 'hours').format();
jest.useFakeTimers();

@@ -431,3 +431,3 @@ const stateHasData = {

selectedProfile: profiles.profiles[0],
lastUpdated: twoHoursAgo
lastUpdated: twoHoursAgo,
},

@@ -440,4 +440,4 @@ };

{
id: "5c93a6e8dcfa5a32015481d2",
serviceId: "17841400383014561",
id: '5c93a6e8dcfa5a32015481d2',
serviceId: '17841400383014561',
},

@@ -449,5 +449,5 @@ ],

const lastUpdatedFetchAction = fetchActions.fetch({
name: "lastUpdated",
name: 'lastUpdated',
args: {
serviceIds: profiles.profiles.map((p) => p.serviceId),
serviceIds: profiles.profiles.map(p => p.serviceId),
},

@@ -454,0 +454,0 @@ });

{
"name": "@bufferapp/analyze-profile-selector",
"version": "1.77.4",
"version": "2.0.0-beta-10",
"description": "Profile selector dropdown",
"main": "index.jsx",
"types": "types/index.d.ts",
"scripts": {

@@ -13,13 +14,9 @@ "start": "start-storybook -p 9001",

"dependencies": {
"@bufferapp/analyze-shared-components": "^1.77.4",
"@bufferapp/components": "3.2.1"
"@bufferapp/analytics-middleware": "1.77.4",
"@bufferapp/analyze-shared-components": "1.77.4",
"@bufferapp/components": "3.2.1",
"@bufferapp/profile-loader": "1.77.4"
},
"author": "Federico Weber <federicoweber@gmail.com>",
"devDependencies": {
"@storybook/addon-storyshots": "3.1.4",
"@storybook/react": "3.1.3",
"redux-mock-store": "^1.2.3",
"storybook-addon-a11y": "3.0.0"
},
"gitHead": "5c01accb74544f933d0b108eb3564acbd3a952cf"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc