mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
SignupInvitedPage: Show orgName
(#94940)
* no orgname * format code * update unit test * delete contextSrv * fix unit test * run prettier --------- Co-authored-by: Laura Benz <laura.benz@grafana.com>
This commit is contained in:
parent
022297f359
commit
008c51b5b1
@ -17,6 +17,7 @@ type InviteInfo struct {
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
InvitedBy string `json:"invitedBy"`
|
InvitedBy string `json:"invitedBy"`
|
||||||
|
OrgName string `json:"orgName"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CompleteInviteForm struct {
|
type CompleteInviteForm struct {
|
||||||
|
@ -220,11 +220,22 @@ func (hs *HTTPServer) GetInviteInfoByCode(c *contextmodel.ReqContext) response.R
|
|||||||
return response.Error(http.StatusNotFound, "Invite not found", nil)
|
return response.Error(http.StatusNotFound, "Invite not found", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
orgResult, err := hs.orgService.GetByID(c.Req.Context(), &org.GetOrgByIDQuery{
|
||||||
|
ID: invite.OrgID,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, org.ErrOrgNotFound) {
|
||||||
|
return response.Error(http.StatusNotFound, "org not found", nil)
|
||||||
|
}
|
||||||
|
return response.Error(http.StatusInternalServerError, "Failed to get org", err)
|
||||||
|
}
|
||||||
|
|
||||||
return response.JSON(http.StatusOK, dtos.InviteInfo{
|
return response.JSON(http.StatusOK, dtos.InviteInfo{
|
||||||
Email: invite.Email,
|
Email: invite.Email,
|
||||||
Name: invite.Name,
|
Name: invite.Name,
|
||||||
Username: invite.Email,
|
Username: invite.Email,
|
||||||
InvitedBy: util.StringsFallback3(invite.InvitedByName, invite.InvitedByLogin, invite.InvitedByEmail),
|
InvitedBy: util.StringsFallback3(invite.InvitedByName, invite.InvitedByLogin, invite.InvitedByEmail),
|
||||||
|
OrgName: orgResult.Name,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ const defaultGet = {
|
|||||||
name: 'Some User',
|
name: 'Some User',
|
||||||
invitedBy: 'Invited By User',
|
invitedBy: 'Invited By User',
|
||||||
username: 'someuser',
|
username: 'someuser',
|
||||||
|
orgName: 'Some Org',
|
||||||
};
|
};
|
||||||
|
|
||||||
async function setupTestContext({ get = defaultGet }: { get?: typeof defaultGet | null } = {}) {
|
async function setupTestContext({ get = defaultGet }: { get?: typeof defaultGet | null } = {}) {
|
||||||
@ -83,7 +84,7 @@ describe('SignupInvitedPage', () => {
|
|||||||
/has invited you to join grafana and the organization please complete the following and choose a password to accept your invitation and continue:/i
|
/has invited you to join grafana and the organization please complete the following and choose a password to accept your invitation and continue:/i
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(within(view).getByText(/invited to org name/i)).toBeInTheDocument();
|
expect(within(view).getByText(/some org/i)).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('then the form should include form data', async () => {
|
it('then the form should include form data', async () => {
|
||||||
@ -98,7 +99,9 @@ describe('SignupInvitedPage', () => {
|
|||||||
|
|
||||||
describe('when user submits the form and the required fields are not filled in', () => {
|
describe('when user submits the form and the required fields are not filled in', () => {
|
||||||
it('then required fields should show error messages and nothing should be posted', async () => {
|
it('then required fields should show error messages and nothing should be posted', async () => {
|
||||||
const { postSpy } = await setupTestContext({ get: { email: '', invitedBy: '', name: '', username: '' } });
|
const { postSpy } = await setupTestContext({
|
||||||
|
get: { email: '', invitedBy: '', name: '', username: '', orgName: '' },
|
||||||
|
});
|
||||||
|
|
||||||
await userEvent.click(screen.getByRole('button', { name: /sign up/i }));
|
await userEvent.click(screen.getByRole('button', { name: /sign up/i }));
|
||||||
|
|
||||||
@ -123,6 +126,7 @@ describe('SignupInvitedPage', () => {
|
|||||||
username: 'some.user@localhost',
|
username: 'some.user@localhost',
|
||||||
password: 'pass@word1',
|
password: 'pass@word1',
|
||||||
inviteCode: 'some code',
|
inviteCode: 'some code',
|
||||||
|
orgName: 'Some Org',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -9,7 +9,6 @@ import { Button, Field, Input, useStyles2 } from '@grafana/ui';
|
|||||||
import { Form } from 'app/core/components/Form/Form';
|
import { Form } from 'app/core/components/Form/Form';
|
||||||
import { Page } from 'app/core/components/Page/Page';
|
import { Page } from 'app/core/components/Page/Page';
|
||||||
import { getConfig } from 'app/core/config';
|
import { getConfig } from 'app/core/config';
|
||||||
import { contextSrv } from 'app/core/core';
|
|
||||||
|
|
||||||
import { w3cStandardEmailValidator } from '../admin/utils';
|
import { w3cStandardEmailValidator } from '../admin/utils';
|
||||||
|
|
||||||
@ -18,6 +17,7 @@ interface FormModel {
|
|||||||
name?: string;
|
name?: string;
|
||||||
username: string;
|
username: string;
|
||||||
password?: string;
|
password?: string;
|
||||||
|
orgName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const navModel = {
|
const navModel = {
|
||||||
@ -46,6 +46,7 @@ export const SignupInvitedPage = () => {
|
|||||||
email: invite.email,
|
email: invite.email,
|
||||||
name: invite.name,
|
name: invite.name,
|
||||||
username: invite.email,
|
username: invite.email,
|
||||||
|
orgName: invite.orgName,
|
||||||
});
|
});
|
||||||
|
|
||||||
setGreeting(invite.name || invite.email || invite.username);
|
setGreeting(invite.name || invite.email || invite.username);
|
||||||
@ -68,7 +69,7 @@ export const SignupInvitedPage = () => {
|
|||||||
|
|
||||||
<div className={cx('modal-tagline', styles.tagline)}>
|
<div className={cx('modal-tagline', styles.tagline)}>
|
||||||
<em>{invitedBy || 'Someone'}</em> has invited you to join Grafana and the organization{' '}
|
<em>{invitedBy || 'Someone'}</em> has invited you to join Grafana and the organization{' '}
|
||||||
<span className="highlight-word">{contextSrv.user.orgName}</span>
|
<span className="highlight-word">{initFormModel.orgName}</span>
|
||||||
<br />
|
<br />
|
||||||
Please complete the following and choose a password to accept your invitation and continue:
|
Please complete the following and choose a password to accept your invitation and continue:
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user