Skip to content

feat(events-v2): Support custom column widths for each view #13714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const ALL_VIEWS = deepFreeze([
'user.ip',
'environment',
],
columnWidths: ['3fr', '80px', '1fr', '1fr', '1.5fr'],
},
{
id: 'errors',
Expand All @@ -42,6 +43,7 @@ export const ALL_VIEWS = deepFreeze([
orderby: ['-last_seen', '-issue.id'],
},
tags: ['error.type', 'project.name'],
columnWidths: ['3fr', '70px', '70px', '1fr', '1.5fr'],
},
{
id: 'csp',
Expand All @@ -58,6 +60,7 @@ export const ALL_VIEWS = deepFreeze([
'os.name',
'effective-directive',
],
columnWidths: ['3fr', '70px', '70px', '1fr', '1.5fr'],
},
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class Table extends React.Component {
}

return data.map((row, idx) => (
<Row key={idx} className={getGridStyle(fields.length)}>
<Row key={idx} className={getGridStyle(view)}>
{fields.map(field => {
const target = {
pathname: `/organizations/${organization.slug}/events/`,
Expand Down Expand Up @@ -91,7 +91,7 @@ export default class Table extends React.Component {

return (
<Panel>
<TableHeader className={getGridStyle(fields.length)}>
<TableHeader className={getGridStyle(view)}>
{fields.map(field => (
<HeaderItem key={field}>
{SPECIAL_FIELDS.hasOwnProperty(field)
Expand All @@ -110,10 +110,14 @@ export default class Table extends React.Component {
}
}

function getGridStyle(colCount) {
function getGridStyle(view) {
const cols = Array.isArray(view.columnWidths)
? view.columnWidths.join(' ')
: `3fr repeat(${view.data.fields.length - 1}, 1fr)`;

return css`
display: grid;
grid-template-columns: 3fr repeat(${colCount - 1}, 1fr);
grid-template-columns: ${cols};
grid-gap: ${space(1)};
`;
}
Expand Down