@planningcenter/topbar 10.20.5 → 11.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -922,6 +922,40 @@
922
922
  function navigateTo(location) {
923
923
  window.location = location;
924
924
  }
925
+ function setConnectedPeopleInStore(connectedPeople) {
926
+ store$1.setState({
927
+ ...store$1.getState(),
928
+ connectedPeople
929
+ });
930
+ }
931
+ function switchConnectedPerson(env, toId, returnPath) {
932
+ apiRequest(railsCsrfFetch, `${pcoUrl(env)("api")}/login/v2/me/switch_connected_person`, {
933
+ data: {
934
+ data: {
935
+ attributes: {
936
+ id: toId,
937
+ return_path: returnPath
938
+ }
939
+ }
940
+ },
941
+ method: "POST"
942
+ }).then(({
943
+ json
944
+ }) => {
945
+ var _a;
946
+ if ((_a = json === null || json === void 0 ? void 0 : json.meta) === null || _a === void 0 ? void 0 : _a.redirect_to) navigateTo(json.meta.redirect_to);
947
+ });
948
+ }
949
+ function unlinkConnectedPeople(env) {
950
+ apiRequest(railsCsrfFetch, `${pcoUrl(env)("api")}/login/v2/me/unlink`, {
951
+ method: "POST"
952
+ }).then(({
953
+ json
954
+ }) => {
955
+ var _a;
956
+ if ((_a = json === null || json === void 0 ? void 0 : json.meta) === null || _a === void 0 ? void 0 : _a.redirect_to) navigateTo(json.meta.redirect_to);
957
+ });
958
+ }
925
959
  class ConnectedPeopleProvider extends React.Component {
926
960
  constructor(props) {
927
961
  super(props);
@@ -936,44 +970,26 @@
936
970
  }) => {
937
971
  if (!ok || !json) return;
938
972
  const connectedPeople = json.data;
973
+ setConnectedPeopleInStore(connectedPeople);
939
974
  return this.setState({
940
975
  connectedPeople
941
976
  }, () => window.localStorage.setItem("Topbar:ConnectedPeople", JSON.stringify(connectedPeople)));
942
977
  });
943
978
  }
944
979
  unlink() {
945
- apiRequest(this.props.configuredFetch, `${pcoUrl(this.props.env)("api")}/login/v2/me/unlink`, {
946
- method: "POST"
947
- }).then(({
948
- json
949
- }) => {
950
- var _a;
951
- if ((_a = json === null || json === void 0 ? void 0 : json.meta) === null || _a === void 0 ? void 0 : _a.redirect_to) navigateTo(json.meta.redirect_to);
952
- });
980
+ unlinkConnectedPeople(this.props.env);
953
981
  }
954
982
  switch(toId, returnPath) {
955
- apiRequest(this.props.configuredFetch, `${pcoUrl(this.props.env)("api")}/login/v2/me/switch_connected_person`, {
956
- data: {
957
- data: {
958
- attributes: {
959
- id: toId,
960
- return_path: returnPath
961
- }
962
- }
963
- },
964
- method: "POST"
965
- }).then(({
966
- json
967
- }) => {
968
- var _a;
969
- if ((_a = json === null || json === void 0 ? void 0 : json.meta) === null || _a === void 0 ? void 0 : _a.redirect_to) navigateTo(json.meta.redirect_to);
970
- });
983
+ switchConnectedPerson(this.props.env, toId, returnPath);
971
984
  }
972
985
  componentDidMount() {
973
986
  const connectedPeople = JSON.parse(window.localStorage.getItem("Topbar:ConnectedPeople"));
974
- if (connectedPeople) return this.setState({
975
- connectedPeople
976
- });
987
+ if (connectedPeople && connectedPeople.length) {
988
+ setConnectedPeopleInStore(connectedPeople);
989
+ return this.setState({
990
+ connectedPeople
991
+ });
992
+ }
977
993
  return this.fetch();
978
994
  }
979
995
  render() {
@@ -2557,7 +2573,8 @@
2557
2573
  className: styles$3["profile-button"],
2558
2574
  onClick: () => {
2559
2575
  var _a, _b;
2560
- return (_b = (_a = window.topbar) === null || _a === void 0 ? void 0 : _a.openProfile) === null || _b === void 0 ? void 0 : _b.call(_a);
2576
+ props.requestConnectedPeopleFetch();
2577
+ (_b = (_a = window.topbar) === null || _a === void 0 ? void 0 : _a.openProfile) === null || _b === void 0 ? void 0 : _b.call(_a);
2561
2578
  }
2562
2579
  }, /*#__PURE__*/React.createElement(Avatar, {
2563
2580
  env: props.env,
@@ -2984,25 +3001,27 @@
2984
3001
  function UserProfile({
2985
3002
  appName,
2986
3003
  closeDrawer,
2987
- connectedPeople,
3004
+ env,
2988
3005
  hasConnectedPeople,
2989
3006
  linkToProfile,
2990
3007
  loginSettingsUrl,
2991
3008
  logoutUrl,
2992
3009
  profileUrl,
2993
3010
  requestClearAppsCache,
2994
- requestSwitchConnectedPerson,
2995
- requestUnlinkConnectedPeople,
2996
3011
  userAvatarPath
2997
3012
  }) {
3013
+ var _a;
3014
+ const storeState = useStore();
2998
3015
  const {
2999
3016
  mfaConfigured,
3000
3017
  name
3001
- } = useStore();
3018
+ } = storeState;
3019
+ const connectedPeople = (_a = storeState.connectedPeople) !== null && _a !== void 0 ? _a : [];
3002
3020
  return /*#__PURE__*/React.createElement(tapestryReact.StackView, {
3003
3021
  axis: "vertical",
3004
3022
  spacing: /*#__PURE__*/React.createElement(tapestryReact.Divider, null),
3005
- flexGrow: 1
3023
+ grow: 1,
3024
+ shrink: 1
3006
3025
  }, /*#__PURE__*/React.createElement(tapestryReact.GridView, {
3007
3026
  columns: "auto 1fr auto",
3008
3027
  alignment: "start",
@@ -3099,17 +3118,24 @@
3099
3118
  display: "none"
3100
3119
  }
3101
3120
  },
3102
- marginTop: "auto"
3121
+ marginTop: "auto",
3122
+ shrink: 1,
3123
+ minHeight: 0,
3124
+ overflow: "auto",
3125
+ position: "relative"
3103
3126
  }, /*#__PURE__*/React.createElement(tapestryReact.StackView, {
3104
3127
  backgroundColor: "var(--t-fill-color-neutral-060)",
3105
3128
  paddingVertical: 1.5,
3106
3129
  paddingHorizontal: 2,
3107
- borderBottom: `1px solid var(--t-border-color-default-base)`
3130
+ borderBottom: `1px solid var(--t-border-color)`,
3131
+ position: "sticky",
3132
+ top: 0,
3133
+ zIndex: 1
3108
3134
  }, /*#__PURE__*/React.createElement(tapestryReact.HeadingUppercase, {
3109
- color: "var(--t-text-color-default-secondary)",
3135
+ color: "var(--t-text-color-secondary)",
3110
3136
  fontWeight: 500
3111
3137
  }, "Linked Accounts")), /*#__PURE__*/React.createElement(tapestryReact.List, {
3112
- dividerColor: "var(--t-border-color-default-base)",
3138
+ dividerColor: "var(--t-border-color)",
3113
3139
  width: "100%"
3114
3140
  }, connectedPeopleMenuFormatter(connectedPeople).map(({
3115
3141
  id,
@@ -3119,10 +3145,11 @@
3119
3145
  onClick: e => {
3120
3146
  requestClearAppsCache();
3121
3147
  requestClearConnectedPeopleCache();
3122
- requestSwitchConnectedPerson(id, `${appName}/`);
3148
+ switchConnectedPerson(env, String(id), `${appName}/`);
3123
3149
  e.preventDefault();
3124
3150
  },
3125
- color: "var(--t-text-color-default-secondary)",
3151
+ color: "var(--t-text-color-secondary)",
3152
+ cursor: "pointer",
3126
3153
  padding: 2
3127
3154
  }, /*#__PURE__*/React.createElement(tapestryReact.Text, {
3128
3155
  truncate: true
@@ -3130,10 +3157,11 @@
3130
3157
  onClick: e => {
3131
3158
  requestClearAppsCache();
3132
3159
  requestClearConnectedPeopleCache();
3133
- requestUnlinkConnectedPeople();
3160
+ unlinkConnectedPeople(env);
3134
3161
  e.preventDefault();
3135
3162
  },
3136
3163
  color: "var(--t-text-color-status-error)",
3164
+ cursor: "pointer",
3137
3165
  padding: 2,
3138
3166
  underline: false
3139
3167
  }, /*#__PURE__*/React.createElement(tapestryReact.Text, {
@@ -4327,14 +4355,11 @@
4327
4355
  function Toolbar({
4328
4356
  appName,
4329
4357
  autoMountTool,
4330
- connectedPeople,
4331
4358
  env,
4332
4359
  helpdeskConfig = {},
4333
4360
  linkToProfile = true,
4334
4361
  onReceiveTasksWorker,
4335
4362
  requestClearAppsCache,
4336
- requestSwitchConnectedPerson,
4337
- requestUnlinkConnectedPeople,
4338
4363
  userAvatarPath,
4339
4364
  userName,
4340
4365
  _storeDataOverride
@@ -4488,15 +4513,13 @@
4488
4513
  Profile: {
4489
4514
  appName,
4490
4515
  closeDrawer,
4491
- connectedPeople: connectedPeople || [],
4516
+ env,
4492
4517
  hasConnectedPeople: (storeData === null || storeData === void 0 ? void 0 : storeData.hasConnectedPeople) || false,
4493
4518
  linkToProfile,
4494
4519
  loginSettingsUrl,
4495
4520
  logoutUrl,
4496
4521
  profileUrl,
4497
4522
  requestClearAppsCache: requestClearAppsCache || (() => {}),
4498
- requestSwitchConnectedPerson: requestSwitchConnectedPerson || (() => {}),
4499
- requestUnlinkConnectedPeople: requestUnlinkConnectedPeople || (() => {}),
4500
4523
  userAvatarPath
4501
4524
  },
4502
4525
  Tasks: {