mirror of https://github.com/abpframework/abp.git
11 changed files with 24 additions and 112 deletions
@ -1,17 +0,0 @@ |
|||||
@using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy.Components.TenantSwitch |
|
||||
@model TenantSwitchViewComponent.TenantSwitchViewModel |
|
||||
@if (!Model.CurrentUser.IsAuthenticated) |
|
||||
{ |
|
||||
<li class="nav-item"> |
|
||||
<a abp-button="Link" id="TenantSwitchToolbarLink" href="#"> |
|
||||
@if (Model.Tenant == null) |
|
||||
{ |
|
||||
<text>@@host</text> |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
<text>@@@Model.Tenant.Name</text> |
|
||||
} |
|
||||
</a> |
|
||||
</li> |
|
||||
} |
|
||||
@ -1,51 +0,0 @@ |
|||||
using System.Threading.Tasks; |
|
||||
using Microsoft.AspNetCore.Mvc; |
|
||||
using Volo.Abp.MultiTenancy; |
|
||||
using Volo.Abp.Users; |
|
||||
|
|
||||
namespace Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy.Components.TenantSwitch |
|
||||
{ |
|
||||
public class TenantSwitchViewComponent : AbpViewComponent |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// -1,000,000
|
|
||||
/// </summary>
|
|
||||
public const int Order = -1_000_000; |
|
||||
|
|
||||
protected ITenantStore TenantStore { get; } |
|
||||
protected ICurrentTenant CurrentTenant { get; } |
|
||||
protected ICurrentUser CurrentUser { get; } |
|
||||
|
|
||||
public TenantSwitchViewComponent( |
|
||||
ITenantStore tenantStore, |
|
||||
ICurrentTenant currentTenant, |
|
||||
ICurrentUser currentUser) |
|
||||
{ |
|
||||
TenantStore = tenantStore; |
|
||||
CurrentTenant = currentTenant; |
|
||||
CurrentUser = currentUser; |
|
||||
} |
|
||||
|
|
||||
public async Task<IViewComponentResult> InvokeAsync() |
|
||||
{ |
|
||||
var model = new TenantSwitchViewModel |
|
||||
{ |
|
||||
CurrentUser = CurrentUser |
|
||||
}; |
|
||||
|
|
||||
if (CurrentTenant.Id.HasValue) |
|
||||
{ |
|
||||
model.Tenant = await TenantStore.FindAsync(CurrentTenant.GetId()); |
|
||||
} |
|
||||
|
|
||||
return View("~/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Components/TenantSwitch/Default.cshtml", model); |
|
||||
} |
|
||||
|
|
||||
public class TenantSwitchViewModel |
|
||||
{ |
|
||||
public TenantConfiguration Tenant { get; set; } |
|
||||
|
|
||||
public ICurrentUser CurrentUser { get; set; } |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,3 +0,0 @@ |
|||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
|
||||
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap |
|
||||
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bundling |
|
||||
@ -1,9 +1,11 @@ |
|||||
{ |
{ |
||||
"culture": "en", |
"culture": "en", |
||||
"texts": { |
"texts": { |
||||
"GivenTenantIsNotAvailable": "Given tenant is not available: {0}", |
"GivenTenantIsNotAvailable": "Given tenant is not available: {0}", |
||||
"SwitchTenant": "Switch tenant", |
"Tenant": "Tenant", |
||||
|
"Switch": "Switch", |
||||
"Name": "Name", |
"Name": "Name", |
||||
"SwitchTenantHint": "Leave the name field blank to switch to the host side." |
"SwitchTenantHint": "Leave the name field blank to switch to the host side.", |
||||
|
"NotSelected": "Seçili değil" |
||||
} |
} |
||||
} |
} |
||||
@ -1,21 +0,0 @@ |
|||||
using System.Threading.Tasks; |
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy.Components.TenantSwitch; |
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars; |
|
||||
|
|
||||
namespace Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy |
|
||||
{ |
|
||||
public class MultiTenancyToolbarContributor : IToolbarContributor |
|
||||
{ |
|
||||
public Task ConfigureToolbarAsync(IToolbarConfigurationContext context) |
|
||||
{ |
|
||||
if (context.Toolbar.Name != StandardToolbars.Main) |
|
||||
{ |
|
||||
return Task.CompletedTask; |
|
||||
} |
|
||||
|
|
||||
context.Toolbar.Items.Add(new ToolbarItem(typeof(TenantSwitchViewComponent), TenantSwitchViewComponent.Order)); |
|
||||
|
|
||||
return Task.CompletedTask; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue