Skip to content
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

fix: move slack channel to top of table description #1446

Merged
merged 14 commits into from
May 8, 2024
Merged
Changes from 3 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 @@ -82,6 +82,24 @@ function useRefreshMetastore(table: IDataTable) {
return [handleRefreshTable, isRefreshing] as const;
}

function createChannelLinkDOM(customProperties) {
const channelsKey = 'channels';
const channelsValue = customProperties[channelsKey]?.toString() ?? '';
const channelsName = channelsValue.slice(1);
const channelLink = `https://pinterest.slack.com/app_redirect?channel=${channelsName}`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is too Pinterest specific for the opensource repo and need a better solution for it. let's not add a link for now. maybe can add link in the properties when syncing from pincat

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed link for now


return channelsValue === '' ? null : (
<KeyContentDisplay
key={channelsKey}
keyString={titleize(channelsKey, '_', ' ')}
>
<Link to={channelLink} newTab>
{channelsValue}
</Link>
</KeyContentDisplay>
);
}

export interface IQuerybookTableViewOverviewProps {
table: IDataTable;
tableName: string;
Expand Down Expand Up @@ -151,22 +169,30 @@ export const DataTableViewOverview: React.FC<
);
});

const customPropertiesDOM = Object.entries(
table.custom_properties ?? {}
).map(([key, value]) => {
const valueStr = value?.toString() ?? '';
return (
<KeyContentDisplay key={key} keyString={titleize(key, '_', ' ')}>
{valueStr && /https?:\/\/[^\s]+/.test(valueStr.trim()) ? (
<Link to={valueStr} newTab>
{valueStr}
</Link>
) : (
valueStr
)}
</KeyContentDisplay>
);
});
const customProperties = table.custom_properties ?? {};
const channelsDOM = createChannelLinkDOM(customProperties);

const customPropertiesDOM = Object.entries(customProperties)
.filter(([key, value]) => {
return key !== 'channels';
})
.map(([key, value]) => {
const valueStr = value?.toString() ?? '';
return (
<KeyContentDisplay
key={key}
keyString={titleize(key, '_', ' ')}
>
{valueStr && /https?:\/\/[^\s]+/.test(valueStr.trim()) ? (
<Link to={valueStr} newTab>
{valueStr}
</Link>
) : (
valueStr
)}
</KeyContentDisplay>
);
});

const rawMetastoreInfoDOM = table.hive_metastore_description ? (
<pre className="raw-metastore-info">
Expand Down Expand Up @@ -209,6 +235,7 @@ export const DataTableViewOverview: React.FC<
);
const detailsSection = (
<DataTableViewOverviewSection title="Details">
{channelsDOM}
{detailsDOM}
{customPropertiesDOM}
</DataTableViewOverviewSection>
Expand Down
Loading