@planningcenter/topbar 10.20.4 → 10.20.5-qa-735.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.
package/dist/topbar.js CHANGED
@@ -935,6 +935,40 @@ function remove() {
935
935
  function navigateTo(location) {
936
936
  window.location = location;
937
937
  }
938
+ function setConnectedPeopleInStore(connectedPeople) {
939
+ store$1.setState({
940
+ ...store$1.getState(),
941
+ connectedPeople
942
+ });
943
+ }
944
+ function switchConnectedPerson(env, toId, returnPath) {
945
+ apiRequest(railsCsrfFetch, `${pcoUrl(env)("api")}/login/v2/me/switch_connected_person`, {
946
+ data: {
947
+ data: {
948
+ attributes: {
949
+ id: toId,
950
+ return_path: returnPath
951
+ }
952
+ }
953
+ },
954
+ method: "POST"
955
+ }).then(({
956
+ json
957
+ }) => {
958
+ var _a;
959
+ 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);
960
+ });
961
+ }
962
+ function unlinkConnectedPeople(env) {
963
+ apiRequest(railsCsrfFetch, `${pcoUrl(env)("api")}/login/v2/me/unlink`, {
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
+ });
971
+ }
938
972
  class ConnectedPeopleProvider extends React.Component {
939
973
  constructor(props) {
940
974
  super(props);
@@ -949,44 +983,26 @@ class ConnectedPeopleProvider extends React.Component {
949
983
  }) => {
950
984
  if (!ok || !json) return;
951
985
  const connectedPeople = json.data;
986
+ setConnectedPeopleInStore(connectedPeople);
952
987
  return this.setState({
953
988
  connectedPeople
954
989
  }, () => window.localStorage.setItem("Topbar:ConnectedPeople", JSON.stringify(connectedPeople)));
955
990
  });
956
991
  }
957
992
  unlink() {
958
- apiRequest(this.props.configuredFetch, `${pcoUrl(this.props.env)("api")}/login/v2/me/unlink`, {
959
- method: "POST"
960
- }).then(({
961
- json
962
- }) => {
963
- var _a;
964
- 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);
965
- });
993
+ unlinkConnectedPeople(this.props.env);
966
994
  }
967
995
  switch(toId, returnPath) {
968
- apiRequest(this.props.configuredFetch, `${pcoUrl(this.props.env)("api")}/login/v2/me/switch_connected_person`, {
969
- data: {
970
- data: {
971
- attributes: {
972
- id: toId,
973
- return_path: returnPath
974
- }
975
- }
976
- },
977
- method: "POST"
978
- }).then(({
979
- json
980
- }) => {
981
- var _a;
982
- 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);
983
- });
996
+ switchConnectedPerson(this.props.env, toId, returnPath);
984
997
  }
985
998
  componentDidMount() {
986
999
  const connectedPeople = JSON.parse(window.localStorage.getItem("Topbar:ConnectedPeople"));
987
- if (connectedPeople) return this.setState({
988
- connectedPeople
989
- });
1000
+ if (connectedPeople && connectedPeople.length) {
1001
+ setConnectedPeopleInStore(connectedPeople);
1002
+ return this.setState({
1003
+ connectedPeople
1004
+ });
1005
+ }
990
1006
  return this.fetch();
991
1007
  }
992
1008
  render() {
@@ -2570,7 +2586,8 @@ const SmallTopbar = ({
2570
2586
  className: styles$3["profile-button"],
2571
2587
  onClick: () => {
2572
2588
  var _a, _b;
2573
- return (_b = (_a = window.topbar) === null || _a === void 0 ? void 0 : _a.openProfile) === null || _b === void 0 ? void 0 : _b.call(_a);
2589
+ props.requestConnectedPeopleFetch();
2590
+ (_b = (_a = window.topbar) === null || _a === void 0 ? void 0 : _a.openProfile) === null || _b === void 0 ? void 0 : _b.call(_a);
2574
2591
  }
2575
2592
  }, /*#__PURE__*/React.createElement(Avatar, {
2576
2593
  env: props.env,
@@ -2997,25 +3014,27 @@ const requestClearConnectedPeopleCache = () => remove();
2997
3014
  function UserProfile({
2998
3015
  appName,
2999
3016
  closeDrawer,
3000
- connectedPeople,
3017
+ env,
3001
3018
  hasConnectedPeople,
3002
3019
  linkToProfile,
3003
3020
  loginSettingsUrl,
3004
3021
  logoutUrl,
3005
3022
  profileUrl,
3006
3023
  requestClearAppsCache,
3007
- requestSwitchConnectedPerson,
3008
- requestUnlinkConnectedPeople,
3009
3024
  userAvatarPath
3010
3025
  }) {
3026
+ var _a;
3027
+ const storeState = useStore();
3011
3028
  const {
3012
3029
  mfaConfigured,
3013
3030
  name
3014
- } = useStore();
3031
+ } = storeState;
3032
+ const connectedPeople = (_a = storeState.connectedPeople) !== null && _a !== void 0 ? _a : [];
3015
3033
  return /*#__PURE__*/React.createElement(tapestryReact.StackView, {
3016
3034
  axis: "vertical",
3017
3035
  spacing: /*#__PURE__*/React.createElement(tapestryReact.Divider, null),
3018
- flexGrow: 1
3036
+ grow: 1,
3037
+ shrink: 1
3019
3038
  }, /*#__PURE__*/React.createElement(tapestryReact.GridView, {
3020
3039
  columns: "auto 1fr auto",
3021
3040
  alignment: "start",
@@ -3112,17 +3131,24 @@ function UserProfile({
3112
3131
  display: "none"
3113
3132
  }
3114
3133
  },
3115
- marginTop: "auto"
3134
+ marginTop: "auto",
3135
+ shrink: 1,
3136
+ minHeight: 0,
3137
+ overflow: "auto",
3138
+ position: "relative"
3116
3139
  }, /*#__PURE__*/React.createElement(tapestryReact.StackView, {
3117
3140
  backgroundColor: "var(--t-fill-color-neutral-060)",
3118
3141
  paddingVertical: 1.5,
3119
3142
  paddingHorizontal: 2,
3120
- borderBottom: `1px solid var(--t-border-color-default-base)`
3143
+ borderBottom: `1px solid var(--t-border-color)`,
3144
+ position: "sticky",
3145
+ top: 0,
3146
+ zIndex: 1
3121
3147
  }, /*#__PURE__*/React.createElement(tapestryReact.HeadingUppercase, {
3122
- color: "var(--t-text-color-default-secondary)",
3148
+ color: "var(--t-text-color-secondary)",
3123
3149
  fontWeight: 500
3124
3150
  }, "Linked Accounts")), /*#__PURE__*/React.createElement(tapestryReact.List, {
3125
- dividerColor: "var(--t-border-color-default-base)",
3151
+ dividerColor: "var(--t-border-color)",
3126
3152
  width: "100%"
3127
3153
  }, connectedPeopleMenuFormatter(connectedPeople).map(({
3128
3154
  id,
@@ -3132,10 +3158,11 @@ function UserProfile({
3132
3158
  onClick: e => {
3133
3159
  requestClearAppsCache();
3134
3160
  requestClearConnectedPeopleCache();
3135
- requestSwitchConnectedPerson(id, `${appName}/`);
3161
+ switchConnectedPerson(env, String(id), `${appName}/`);
3136
3162
  e.preventDefault();
3137
3163
  },
3138
- color: "var(--t-text-color-default-secondary)",
3164
+ color: "var(--t-text-color-secondary)",
3165
+ cursor: "pointer",
3139
3166
  padding: 2
3140
3167
  }, /*#__PURE__*/React.createElement(tapestryReact.Text, {
3141
3168
  truncate: true
@@ -3143,10 +3170,11 @@ function UserProfile({
3143
3170
  onClick: e => {
3144
3171
  requestClearAppsCache();
3145
3172
  requestClearConnectedPeopleCache();
3146
- requestUnlinkConnectedPeople();
3173
+ unlinkConnectedPeople(env);
3147
3174
  e.preventDefault();
3148
3175
  },
3149
3176
  color: "var(--t-text-color-status-error)",
3177
+ cursor: "pointer",
3150
3178
  padding: 2,
3151
3179
  underline: false
3152
3180
  }, /*#__PURE__*/React.createElement(tapestryReact.Text, {
@@ -4340,14 +4368,11 @@ function toolIsRoutable(tool) {
4340
4368
  function Toolbar({
4341
4369
  appName,
4342
4370
  autoMountTool,
4343
- connectedPeople,
4344
4371
  env,
4345
4372
  helpdeskConfig = {},
4346
4373
  linkToProfile = true,
4347
4374
  onReceiveTasksWorker,
4348
4375
  requestClearAppsCache,
4349
- requestSwitchConnectedPerson,
4350
- requestUnlinkConnectedPeople,
4351
4376
  userAvatarPath,
4352
4377
  userName,
4353
4378
  _storeDataOverride
@@ -4501,15 +4526,13 @@ function Toolbar({
4501
4526
  Profile: {
4502
4527
  appName,
4503
4528
  closeDrawer,
4504
- connectedPeople: connectedPeople || [],
4529
+ env,
4505
4530
  hasConnectedPeople: (storeData === null || storeData === void 0 ? void 0 : storeData.hasConnectedPeople) || false,
4506
4531
  linkToProfile,
4507
4532
  loginSettingsUrl,
4508
4533
  logoutUrl,
4509
4534
  profileUrl,
4510
4535
  requestClearAppsCache: requestClearAppsCache || (() => {}),
4511
- requestSwitchConnectedPerson: requestSwitchConnectedPerson || (() => {}),
4512
- requestUnlinkConnectedPeople: requestUnlinkConnectedPeople || (() => {}),
4513
4536
  userAvatarPath
4514
4537
  },
4515
4538
  Tasks: {