Skip to content

Commit

Permalink
[req-changes] Miscellaneous changes
Browse files Browse the repository at this point in the history
- Changed getUserRadiusUsage refresh interval to 2 minutes
- Don't show "Wifi Session Logged in" message if the user has exhausted there plan
- Only show plan exhausted message if the subscription module is in use
  • Loading branch information
pandafy committed Jan 16, 2024
1 parent 7107f74 commit ee39d09
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 46 deletions.
62 changes: 20 additions & 42 deletions client/components/status/__snapshots__/status.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ exports[`<Status /> interactions should show user's plan when subscription modul
used
</p>
<p
className="exhausted"
>
<strong>
USAGE_LIMIT_EXHAUSTED_TXT
</strong>
</p>
</div>
<div
key="Max-Daily-Session-Traffic"
Expand Down Expand Up @@ -107,22 +114,10 @@ exports[`<Status /> interactions should show user's plan when subscription modul
className="inner"
>
<p
className="status-content"
key="WiFi Login Successful!"
>
WiFi Login Successful!
</p>
<p
className="status-content"
key="You can now use the internet."
>
You can now use the internet.
</p>
<p
className="status-content"
key="You may leave this page open in case you want to log out."
className="status-contentplan-exhausted-message"
key="STATUS_EXHAUSTED_CONTENT"
>
You may leave this page open in case you want to log out.
STATUS_EXHAUSTED_CONTENT
</p>
<p
className="status-content"
Expand Down Expand Up @@ -244,12 +239,6 @@ exports[`<Status /> interactions should show user's plan when subscription modul
type="hidden"
value=""
/>
<input
name="mac_address"
readOnly={true}
type="text"
value="4e:ed:11:2b:17:ae"
/>
</form>
<iframe
className="hidden"
Expand Down Expand Up @@ -396,6 +385,13 @@ exports[`<Status /> interactions should show user's plan when subscription modul
used
</p>
<p
className="exhausted"
>
<strong>
USAGE_LIMIT_EXHAUSTED_TXT
</strong>
</p>
</div>
<div
key="Max-Daily-Session-Traffic"
Expand Down Expand Up @@ -448,22 +444,10 @@ exports[`<Status /> interactions should show user's plan when subscription modul
className="inner"
>
<p
className="status-content"
key="WiFi Login Successful!"
>
WiFi Login Successful!
</p>
<p
className="status-content"
key="You can now use the internet."
>
You can now use the internet.
</p>
<p
className="status-content"
key="You may leave this page open in case you want to log out."
className="status-contentplan-exhausted-message"
key="STATUS_EXHAUSTED_CONTENT"
>
You may leave this page open in case you want to log out.
STATUS_EXHAUSTED_CONTENT
</p>
<p
className="status-content"
Expand Down Expand Up @@ -585,12 +569,6 @@ exports[`<Status /> interactions should show user's plan when subscription modul
type="hidden"
value=""
/>
<input
name="mac_address"
readOnly={true}
type="text"
value="4e:ed:11:2b:17:ae"
/>
</form>
<iframe
className="hidden"
Expand Down
16 changes: 12 additions & 4 deletions client/components/status/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export default class Status extends React.Component {
await this.getUserRadiusUsage();
this.getUserRadiusUsageIntervalId = setInterval(() => {
this.getUserRadiusUsage();
}, 60000);
}, 12000);
}

window.addEventListener("resize", this.updateScreenWidth);
Expand Down Expand Up @@ -326,7 +326,7 @@ export default class Status extends React.Component {
}

async getUserRadiusUsage() {
const {cookies, orgSlug, logout, userData} = this.props;
const {cookies, orgSlug, logout, userData, setPlanExhausted} = this.props;
const {showRadiusUsage} = this.state;
const url = getUserRadiusUsageUrl(orgSlug);
const auth_token = cookies.get(`${orgSlug}_auth_token`);
Expand All @@ -342,6 +342,13 @@ export default class Status extends React.Component {
url,
});
options.userChecks = response.data.checks;
if (options.userChecks) {
options.userChecks.forEach((check) => {
if (check.value === check.result) {
setPlanExhausted(true);
}
});
}
if (response.data.plan) {
options.userPlan = response.data.plan;
}
Expand Down Expand Up @@ -1021,8 +1028,9 @@ export default class Status extends React.Component {
)}{" "}
used
</p>
{userPlan.is_free &&
check.value === String(check.result) && (
{settings.subscriptions &&
userPlan.is_free &&
planExhausted && (
<p className="exhausted">
<strong>{t`USAGE_LIMIT_EXHAUSTED_TXT`}</strong>
</p>
Expand Down
2 changes: 2 additions & 0 deletions client/components/status/status.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1922,13 +1922,15 @@ describe("<Status /> interactions", () => {
prop.statusPage.links = links;
prop.statusPage.radius_usage_enabled = true;
prop.isAuthenticated = true;
prop.planExhausted = true;
prop.settings.subscriptions = true;
wrapper = shallow(<Status {...prop} />, {
context: {setLoading: jest.fn()},
});
wrapper.setState({showRadiusUsage: false});
await tick();
expect(wrapper).toMatchSnapshot();
expect(prop.setPlanExhausted).toHaveBeenCalledTimes(1);
wrapper.find("#plan-upgrade-btn").simulate("click");
await tick();
expect(wrapper).toMatchSnapshot();
Expand Down

0 comments on commit ee39d09

Please sign in to comment.