Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit59a80d7

Browse files
authored
feat: show organization information on templates page (#14224)
1 parent9715ae5 commit59a80d7

File tree

7 files changed

+63
-17
lines changed

7 files changed

+63
-17
lines changed

‎site/src/modules/dashboard/DashboardProvider.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ import type {
1313
import{ErrorAlert}from"components/Alert/ErrorAlert";
1414
import{Loader}from"components/Loader/Loader";
1515
import{useEmbeddedMetadata}from"hooks/useEmbeddedMetadata";
16+
import{selectFeatureVisibility}from"./entitlements";
1617

1718
exportinterfaceDashboardValue{
1819
entitlements:Entitlements;
1920
experiments:Experiments;
2021
appearance:AppearanceConfig;
2122
organizations:Organization[];
23+
showOrganizations:boolean;
2224
}
2325

2426
exportconstDashboardContext=createContext<DashboardValue|undefined>(
@@ -52,13 +54,19 @@ export const DashboardProvider: FC<PropsWithChildren> = ({ children }) => {
5254
return<Loaderfullscreen/>;
5355
}
5456

57+
consthasMultipleOrganizations=organizationsQuery.data.length>1;
58+
constorganizationsEnabled=
59+
experimentsQuery.data.includes("multi-organization")&&
60+
selectFeatureVisibility(entitlementsQuery.data).multiple_organizations;
61+
5562
return(
5663
<DashboardContext.Provider
5764
value={{
5865
entitlements:entitlementsQuery.data,
5966
experiments:experimentsQuery.data,
6067
appearance:appearanceQuery.data,
6168
organizations:organizationsQuery.data,
69+
showOrganizations:hasMultipleOrganizations||organizationsEnabled,
6270
}}
6371
>
6472
{children}

‎site/src/modules/navigation.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import{useEffectEvent}from"hooks/hookPolyfills";
66
importtype{DashboardValue}from"./dashboard/DashboardProvider";
7-
import{selectFeatureVisibility}from"./dashboard/entitlements";
87
import{useDashboard}from"./dashboard/useDashboard";
98

109
typeLinkThunk=(state:DashboardValue)=>string;
@@ -27,13 +26,7 @@ export const linkToUsers = withFilter("/users", "status:active");
2726

2827
exportconstlinkToTemplate=
2928
(organizationName:string,templateName:string):LinkThunk=>
30-
(dashboard)=>{
31-
consthasMultipleOrganizations=dashboard.organizations.length>1;
32-
constorganizationsEnabled=
33-
dashboard.experiments.includes("multi-organization")&&
34-
selectFeatureVisibility(dashboard.entitlements).multiple_organizations;
35-
36-
returnhasMultipleOrganizations||organizationsEnabled
29+
(dashboard)=>
30+
dashboard.showOrganizations
3731
?`/templates/${organizationName}/${templateName}`
3832
:`/templates/${templateName}`;
39-
};

‎site/src/pages/ManagementSettingsPage/ManagementSettingsLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { DeploySettingsContext } from "../DeploySettingsPage/DeploySettingsLayou
1313
import{Sidebar}from"./Sidebar";
1414

1515
typeOrganizationSettingsValue={
16-
organizations:Organization[]|undefined;
16+
organizations:Organization[];
1717
};
1818

1919
exportconstuseOrganizationSettings=():OrganizationSettingsValue=>{

‎site/src/pages/TemplatesPage/TemplatesPage.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import { Helmet } from "react-helmet-async";
33
import{useQuery}from"react-query";
44
import{templateExamples,templates}from"api/queries/templates";
55
import{useAuthenticated}from"contexts/auth/RequireAuth";
6+
import{useDashboard}from"modules/dashboard/useDashboard";
67
import{pageTitle}from"utils/page";
78
import{TemplatesPageView}from"./TemplatesPageView";
89

910
exportconstTemplatesPage:FC=()=>{
1011
const{ permissions}=useAuthenticated();
12+
const{ showOrganizations}=useDashboard();
1113

1214
consttemplatesQuery=useQuery(templates());
1315
constexamplesQuery=useQuery({
@@ -23,6 +25,7 @@ export const TemplatesPage: FC = () => {
2325
</Helmet>
2426
<TemplatesPageView
2527
error={error}
28+
showOrganizations={showOrganizations}
2629
canCreateTemplates={permissions.createTemplates}
2730
examples={examplesQuery.data}
2831
templates={templatesQuery.data}

‎site/src/pages/TemplatesPage/TemplatesPageView.stories.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ export const WithTemplates: Story = {
6969
},
7070
};
7171

72+
exportconstMultipleOrganizations:Story={
73+
args:{
74+
...WithTemplates.args,
75+
showOrganizations:true,
76+
},
77+
};
78+
7279
exportconstEmptyCanCreate:Story={
7380
args:{
7481
canCreateTemplates:true,

‎site/src/pages/TemplatesPage/TemplatesPageView.tsx

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ const TemplateHelpTooltip: FC = () => {
8181
};
8282

8383
interfaceTemplateRowProps{
84+
showOrganizations:boolean;
8485
template:Template;
8586
}
8687

87-
constTemplateRow:FC<TemplateRowProps>=({ template})=>{
88+
constTemplateRow:FC<TemplateRowProps>=({showOrganizations,template})=>{
8889
constgetLink=useLinks();
8990
consttemplatePageLink=getLink(
9091
linkToTemplate(template.organization_name,template.name),
@@ -120,7 +121,23 @@ const TemplateRow: FC<TemplateRowProps> = ({ template }) => {
120121
</TableCell>
121122

122123
<TableCellcss={styles.secondary}>
123-
{Language.developerCount(template.active_user_count)}
124+
{showOrganizations ?(
125+
<Stack
126+
spacing={0}
127+
css={{
128+
width:"100%",
129+
}}
130+
>
131+
<spancss={styles.cellPrimaryLine}>
132+
{template.organization_display_name}
133+
</span>
134+
<spancss={styles.cellSecondaryLine}>
135+
Used by{Language.developerCount(template.active_user_count)}
136+
</span>
137+
</Stack>
138+
) :(
139+
Language.developerCount(template.active_user_count)
140+
)}
124141
</TableCell>
125142

126143
<TableCellcss={styles.secondary}>
@@ -156,16 +173,18 @@ const TemplateRow: FC<TemplateRowProps> = ({ template }) => {
156173

157174
exportinterfaceTemplatesPageViewProps{
158175
error?:unknown;
176+
showOrganizations:boolean;
177+
canCreateTemplates:boolean;
159178
examples:TemplateExample[]|undefined;
160179
templates:Template[]|undefined;
161-
canCreateTemplates:boolean;
162180
}
163181

164182
exportconstTemplatesPageView:FC<TemplatesPageViewProps>=({
165-
templates,
166183
error,
167-
examples,
184+
showOrganizations,
168185
canCreateTemplates,
186+
examples,
187+
templates,
169188
})=>{
170189
constisLoading=!templates;
171190
constisEmpty=templates&&templates.length===0;
@@ -209,7 +228,9 @@ export const TemplatesPageView: FC<TemplatesPageViewProps> = ({
209228
<TableHead>
210229
<TableRow>
211230
<TableCellwidth="35%">{Language.nameLabel}</TableCell>
212-
<TableCellwidth="15%">{Language.usedByLabel}</TableCell>
231+
<TableCellwidth="15%">
232+
{showOrganizations ?"Organization" :Language.usedByLabel}
233+
</TableCell>
213234
<TableCellwidth="10%">{Language.buildTimeLabel}</TableCell>
214235
<TableCellwidth="15%">{Language.lastUpdatedLabel}</TableCell>
215236
<TableCellwidth="1%"></TableCell>
@@ -225,7 +246,11 @@ export const TemplatesPageView: FC<TemplatesPageViewProps> = ({
225246
/>
226247
) :(
227248
templates?.map((template)=>(
228-
<TemplateRowkey={template.id}template={template}/>
249+
<TemplateRow
250+
key={template.id}
251+
showOrganizations={showOrganizations}
252+
template={template}
253+
/>
229254
))
230255
)}
231256
</TableBody>
@@ -276,6 +301,15 @@ const styles = {
276301
actionCell:{
277302
whiteSpace:"nowrap",
278303
},
304+
cellPrimaryLine:(theme)=>({
305+
color:theme.palette.text.primary,
306+
fontWeight:600,
307+
}),
308+
cellSecondaryLine:(theme)=>({
309+
fontSize:13,
310+
color:theme.palette.text.secondary,
311+
lineHeight:"150%",
312+
}),
279313
secondary:(theme)=>({
280314
color:theme.palette.text.secondary,
281315
}),

‎site/src/testHelpers/storybook.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const withDashboardProvider = (
4141
experiments,
4242
appearance:MockAppearanceConfig,
4343
organizations:[MockDefaultOrganization],
44+
showOrganizations:false,
4445
}}
4546
>
4647
<Story/>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp