fix: populate default created_by and add not-null constraint in templates (#2290)

This commit is contained in:
Abhineet Jain
2022-06-13 17:25:06 +00:00
committed by GitHub
parent 49f857806f
commit a91482cb25
12 changed files with 28 additions and 31 deletions
+1 -1
View File
@@ -247,7 +247,7 @@ export interface Template {
readonly description: string
readonly max_ttl_ms: number
readonly min_autostart_interval_ms: number
readonly created_by_id?: string
readonly created_by_id: string
readonly created_by_name: string
}
@@ -23,12 +23,3 @@ UsedByMany.args = {
},
activeVersion: Mocks.MockTemplateVersion,
}
export const UnknownCreator = Template.bind({})
UnknownCreator.args = {
template: {
...Mocks.MockTemplate,
created_by_name: "",
},
activeVersion: Mocks.MockTemplateVersion,
}
@@ -14,7 +14,6 @@ const Language = {
userPlural: "users",
userSingular: "user",
createdByLabel: "Created by",
defaultTemplateCreator: "<unknown>",
}
export interface TemplateStatsProps {
@@ -50,7 +49,7 @@ export const TemplateStats: FC<TemplateStatsProps> = ({ template, activeVersion
<div className={styles.statsDivider} />
<div className={styles.statItem}>
<span className={styles.statsLabel}>{Language.createdByLabel}</span>
<span className={styles.statsValue}>{template.created_by_name || Language.defaultTemplateCreator}</span>
<span className={styles.statsValue}>{template.created_by_name}</span>
</div>
</div>
)
@@ -50,7 +50,6 @@ export const Language = {
templateTooltipText: "With templates you can create a common configuration for your workspaces using Terraform.",
templateTooltipLink: "Manage templates",
createdByLabel: "Created by",
defaultTemplateCreator: "<unknown>",
}
const TemplateHelpTooltip: React.FC = () => {
@@ -140,7 +139,7 @@ export const TemplatesPageView: FC<TemplatesPageViewProps> = (props) => {
<TableCell>{Language.developerCount(template.workspace_owner_count)}</TableCell>
<TableCell data-chromatic="ignore">{dayjs().to(dayjs(template.updated_at))}</TableCell>
<TableCell>{template.created_by_name || Language.defaultTemplateCreator}</TableCell>
<TableCell>{template.created_by_name}</TableCell>
<TableCell>
<div className={styles.arrowCell}>
<KeyboardArrowRight className={styles.arrowRight} />