Skip to content

Commit

Permalink
CORE-442 Hide description field on menu link content form
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Nov 8, 2024
1 parent f6d9161 commit 3e2d5d3
Show file tree
Hide file tree
Showing 10 changed files with 7,622 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ class SimplePreview extends PreviewUrlGeneratorBase {
* {@inheritdoc}
*/
public function generate(NextSiteInterface $next_site, EntityInterface $entity, string $resource_version = NULL): ?Url {
return Url::fromUri($next_site->getPreviewUrl(), [
'query' => [
'slug' => $entity->toUrl()->toString(TRUE)->getGeneratedUrl(),
'secret' => $next_site->getPreviewSecret(),
],
]);
try {
return Url::fromUri($next_site->getPreviewUrl(), [
'query' => [
'slug' => $entity->toUrl()->toString(TRUE)->getGeneratedUrl(),
'secret' => $next_site->getPreviewSecret(),
],
]);
}
catch (\Throwable $e) {
}
return NULL;
}

/**
Expand Down
1 change: 1 addition & 0 deletions modules/stanford_profile_admin/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
1 change: 1 addition & 0 deletions modules/stanford_profile_admin/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
1 change: 1 addition & 0 deletions modules/stanford_profile_admin/dist/css/menu_link_form.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#edit-menu-link-description{display:none}
13 changes: 13 additions & 0 deletions modules/stanford_profile_admin/lib/scss/menu_link_form.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@charset 'UTF-8';

// Remove this variable if you are not using assets directly out of Decanter
// that need to be included in the webpack build.
$su-image-path: '~decanter-assets';
$fa-font-path: '~fa-fonts';

// Import Decanter Library:
@import 'decanter/core/src/scss/decanter-no-markup';

#edit-menu-link-description {
display: none;
}
31 changes: 31 additions & 0 deletions modules/stanford_profile_admin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "stanford_starter",
"version": "1.0.0",
"description": "Changelog: [CHANGELOG.md](CHANGELOG.md)",
"main": "webpack.config.js",
"scripts": {
"watch": "NODE_ENV=production webpack --watch",
"build": "NODE_ENV=production webpack"
},
"author": "",
"license": "ISC",
"dependencies": {
"@babel/core": "^7.26.0",
"@babel/preset-env": "^7.26.0",
"babel-loader": "^9.2.1",
"css-loader": "^7.1.2",
"decanter": "^6.3.3",
"filemanager-webpack-plugin": "^8.0.0",
"mini-css-extract-plugin": "^2.9.2",
"node-sass": "^9.0.0",
"optimize-css-assets-webpack-plugin": "^6.0.1",
"postcss-loader": "^8.1.1",
"postcss-preset-env": "^10.0.9",
"sass-loader": "^16.0.3",
"style-loader": "^4.0.0",
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4",
"webpack-remove-empty-scripts": "^1.0.4"
},
"packageManager": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
menu_link_form:
css:
theme:
dist/css/menu_link_form.css: {}
9 changes: 9 additions & 0 deletions modules/stanford_profile_admin/stanford_profile_admin.module
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Contains stanford_profile_admin.module.
*/

use \Drupal\Core\Form\FormStateInterface;

/**
* Implements hook_link_alter().
*/
Expand All @@ -16,3 +18,10 @@ function stanford_profile_admin_link_alter(&$variables) {
$variables['text'] = 'Users';
}
}

/**
* Implements hook_form_BASE_FORM_ID_alter().
*/
function stanford_profile_admin_form_menu_link_content_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$form['#attached']['library'][] = 'stanford_profile_admin/menu_link_form';
}
106 changes: 106 additions & 0 deletions modules/stanford_profile_admin/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@

const path = require("path");
const glob = require('glob')
const Webpack = require("webpack");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');
const FileManagerPlugin = require('filemanager-webpack-plugin');
const autoprefixer = require('autoprefixer')({ grid: true });

const config = {
isProd: process.env.NODE_ENV === "production",
hmrEnabled: process.env.NODE_ENV !== "production" && !process.env.NO_HMR,
distFolder: path.resolve(__dirname, "./dist/css"),
wdsPort: 3001,
};

const entryPoints = glob.sync('./lib/scss/**/*.scss').reduce((acc, filePath) => {
const filePathParts = filePath.replace('./lib/scss/', '').split('/');
let fileName = filePathParts.pop();
if (fileName.indexOf('_') === 0) {
return acc;
}
if (fileName === 'index.scss') {
fileName = filePathParts.pop();
}
const entry = filePathParts.length >= 1 ? filePathParts.join('/') + '/' + fileName : fileName;
acc[entry.replace('.scss', '')] = filePath
return acc
}, {});

var webpackConfig = {
entry: entryPoints,
output: {
path: config.distFolder,
filename: '[name].js',
assetModuleFilename: '../assets/[name][ext][query]'
},
mode: config.isProd ? "production" : "development",
resolve: {
alias: {
'decanter-assets': path.resolve('node_modules', 'decanter/core/src/img'),
'decanter-src': path.resolve('node_modules', 'decanter/core/src'),
'@fortawesome': path.resolve('node_modules', '@fortawesome'),
'fa-fonts': path.resolve('node_modules', '@fortawesome/fontawesome-free/webfonts')
}
},
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
},
},
{
test: /\.(sa|sc|c)ss$/,
use: [
config.isProd ? { loader: MiniCssExtractPlugin.loader } : 'style-loader',
{loader:'css-loader', options: {}},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
sourceMap: true,
plugins: [autoprefixer],
},
}
},
{loader:'sass-loader', options: {}}
]
},
{
test: /\.(png|jpg|gif|svg)$/i,
type: "asset"
}
]
},
plugins: [
new RemoveEmptyScriptsPlugin(),
new MiniCssExtractPlugin({
filename: '[name].css',
}),
new FileManagerPlugin({
events: {
onStart: {
delete: ['dist'],
},
},
}),
],
optimization: {
minimizer: [
new OptimizeCSSAssetsPlugin(),
]
}
};

if (config.hmrEnabled) {
webpackConfig.plugins.push(new Webpack.HotModuleReplacementPlugin());
}
module.exports = webpackConfig;
Loading

0 comments on commit 3e2d5d3

Please sign in to comment.