Skip to content

Commit

Permalink
🚧 Temporary optimistic merge of several features branches during the …
Browse files Browse the repository at this point in the history
…christmas period
  • Loading branch information
danyx23 committed Jan 9, 2025
3 parents e954517 + d6ca1b8 + be8aa57 commit 5c47981
Show file tree
Hide file tree
Showing 58 changed files with 4,988 additions and 3,873 deletions.
2 changes: 1 addition & 1 deletion adminSiteClient/AdminSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const AdminSidebar = (): React.ReactElement => (
{chartViewsFeatureEnabled && (
<li>
<Link to="/chartViews">
<FontAwesomeIcon icon={faPanorama} /> Narrative views
<FontAwesomeIcon icon={faPanorama} /> Narrative charts
</Link>
</li>
)}
Expand Down
4 changes: 2 additions & 2 deletions adminSiteClient/ChartEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,15 @@ export class ChartEditor extends AbstractChartEditor<ChartEditorManager> {
)
}

async saveAsNarrativeView(): Promise<void> {
async saveAsChartView(): Promise<void> {
const { patchConfig, grapher } = this

const chartJson = omit(patchConfig, CHART_VIEW_PROPS_TO_OMIT)

const suggestedName = grapher.title ? slugify(grapher.title) : undefined

const name = prompt(
"Please enter a programmatic name for the narrative view. Note that this name cannot be changed later.",
"Please enter a programmatic name for the narrative chart. Note that this name cannot be changed later.",
suggestedName
)

Expand Down
5 changes: 3 additions & 2 deletions adminSiteClient/ChartViewEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
References,
type EditorTab,
} from "./AbstractChartEditor.js"
import { ENV } from "../settings/clientSettings.js"
import { BAKED_BASE_URL, ENV } from "../settings/clientSettings.js"
import {
CHART_VIEW_PROPS_TO_OMIT,
CHART_VIEW_PROPS_TO_PERSIST,
Expand All @@ -16,7 +16,8 @@ import { diffGrapherConfigs, omit, pick } from "@ourworldindata/utils"
// Don't yet show chart views in the admin interface
// This is low-stakes - if it shows up anyhow (e.g. on staging servers), it's not a big deal.
// TODO: Remove this flag once we're launching this feature
export const chartViewsFeatureEnabled = ENV === "development"
export const chartViewsFeatureEnabled =
ENV === "development" || BAKED_BASE_URL.includes("narrative-")

export interface Chart {
id: number
Expand Down
6 changes: 3 additions & 3 deletions adminSiteClient/ChartViewIndexPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AdminAppContext } from "./AdminAppContext.js"
import { Timeago } from "./Forms.js"
import { ColumnsType } from "antd/es/table/InternalTable.js"
import { ApiChartViewOverview } from "../adminShared/AdminTypes.js"
import { BAKED_GRAPHER_URL } from "../settings/clientSettings.js"
import { GRAPHER_DYNAMIC_THUMBNAIL_URL } from "../settings/clientSettings.js"
import { Link } from "./Link.js"
import {
buildSearchWordsFromSearchString,
Expand All @@ -28,7 +28,7 @@ function createColumns(
width: 200,
render: (chartConfigId) => (
<img
src={`${BAKED_GRAPHER_URL}/by-uuid/${chartConfigId}.svg`}
src={`${GRAPHER_DYNAMIC_THUMBNAIL_URL}/by-uuid/${chartConfigId}.svg`}
style={{ maxWidth: 200, maxHeight: 200 }}
/>
),
Expand Down Expand Up @@ -135,7 +135,7 @@ export function ChartViewIndexPage() {
}, [admin])

return (
<AdminLayout title="Narrative views">
<AdminLayout title="Narrative charts">
<main className="ChartViewIndexPage">
<Flex justify="space-between">
<Input
Expand Down
2 changes: 1 addition & 1 deletion adminSiteClient/EditorReferencesTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const ReferencesSection = (props: {

const chartViews = !!props.references?.chartViews?.length && (
<>
<p>Narrative views based on this chart</p>
<p>Narrative charts based on this chart</p>
<ul className="list-group">
{props.references.chartViews.map((chartView) => (
<li key={chartView.id} className="list-group-item">
Expand Down
20 changes: 13 additions & 7 deletions adminSiteClient/ImagesIndexPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,13 @@ function createColumns({
title: "Filename",
dataIndex: "filename",
key: "filename",
width: 300,
width: 200,
},
{
title: "Alt text",
dataIndex: "defaultAlt",
key: "defaultAlt",
width: "auto",
sorter: (a, b) =>
a.defaultAlt && b.defaultAlt
? a.defaultAlt.localeCompare(b.defaultAlt)
Expand All @@ -309,7 +310,7 @@ function createColumns({
a.originalWidth && b.originalWidth
? a.originalWidth - b.originalWidth
: 0,
width: 100,
width: 50,
},
{
title: "Height",
Expand All @@ -319,13 +320,13 @@ function createColumns({
a.originalHeight && b.originalHeight
? a.originalHeight - b.originalHeight
: 0,
width: 100,
width: 50,
},
{
title: "Last updated",
dataIndex: "updatedAt",
key: "updatedAt",
width: 150,
width: 50,
defaultSortOrder: "descend",
sorter: (a, b) =>
a.updatedAt && b.updatedAt ? a.updatedAt - b.updatedAt : 0,
Expand All @@ -334,7 +335,7 @@ function createColumns({
{
title: "Owner",
key: "userId",
width: 200,
width: 100,
filters: [
{
text: "Unassigned",
Expand Down Expand Up @@ -375,7 +376,7 @@ function createColumns({
{
title: "Action",
key: "action",
width: 100,
width: 50,
render: (_, image) => {
const isDeleteDisabled = !!(usage && usage[image.id]?.length)
return (
Expand Down Expand Up @@ -657,7 +658,12 @@ export function ImageIndexPage() {
/>
<PostImageButton postImage={api.postImage} />
</Flex>
<Table columns={columns} dataSource={filteredImages} />
<Table
size="small"
columns={columns}
dataSource={filteredImages}
rowKey={(x) => x.id}
/>
</main>
</NotificationContext.Provider>
</AdminLayout>
Expand Down
8 changes: 4 additions & 4 deletions adminSiteClient/SaveButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class SaveButtonsForChart extends Component<{
void this.props.editor.saveAsNewGrapher()
}

@action.bound onSaveAsNarrativeView() {
void this.props.editor.saveAsNarrativeView()
@action.bound onSaveAsChartView() {
void this.props.editor.saveAsChartView()
}

@action.bound onPublishToggle() {
Expand Down Expand Up @@ -120,10 +120,10 @@ class SaveButtonsForChart extends Component<{
<div className="mt-2">
<button
className="btn btn-primary"
onClick={this.onSaveAsNarrativeView}
onClick={this.onSaveAsChartView}
disabled={isSavingDisabled}
>
Save as narrative view
Save as narrative chart
</button>
</div>
)}
Expand Down
8 changes: 8 additions & 0 deletions adminSiteClient/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,14 @@ main:not(.ChartEditorPage):not(.GdocsEditPage) {
}

.ImageIndexPage {
@media (max-width: 1300px) {
padding-left: 0 !important;
padding-right: 0 !important;
.ant-table-cell {
padding-left: 4px !important;
padding-right: 4px !important;
}
}
.ImageIndexPage__delete-user-button {
border-radius: 50%;
margin-left: 8px;
Expand Down
Loading

0 comments on commit 5c47981

Please sign in to comment.