in src/app/app.js [111:160]
async initialize(dashboardApi) {
const [{projects}, {homeUrl: hubUrl, name: hubServiceName}, config] = await Promise.all([
dashboardApi.fetchHub(
'api/rest/projects', {
query: {
fields: 'id,name',
orderBy: 'name',
$top: -1
}
}
),
dashboardApi.fetchHub(
`api/rest/services/${HUB_SERVICE_ID}`, {
query: {
fields: 'homeUrl,name'
}
}
),
dashboardApi.readConfig()
]);
const isStandaloneHub = hubServiceName !== 'YouTrack Administration';
this.setState({projects, isStandaloneHub});
if (isStandaloneHub) {
this.setState({homeUrl: hubUrl}, () => this.updateTitle());
} else {
dashboardApi.fetchHub('api/rest/services', {query: {
fields: 'id,name,applicationName,homeUrl',
query: 'applicationName:YouTrack'
}}).
then(response => {
const youTrackService = (response.services || []).filter(service => service.homeUrl)[0];
return (youTrackService || {}).homeUrl || hubUrl.replace('/hub', '/youtrack');
}).
then(homeUrl => this.setState({homeUrl}), () => this.updateTitle());
}
if (!config) {
dashboardApi.enterConfigMode();
this.setState({isConfiguring: true});
return;
}
const {selectedProject} = config;
this.setState({selectedProject});
this.loadProjectTeam(selectedProject.key);
}